The Vim text editor (or the older Vi) is standard on Linux/*NIX computers or servers. It has a high learning curve, but allows for extremely efficient work once learned, in both writing and programming.
Whenever you're editing a file and think Gee, it'd be nice if you could...
rest assured that someone, somewhere has thought of this before you, and added it to Vim.
After committing some time to learn the unituitive vi, I had a shift in thinking. vi felt difficult to learn initially, but was much faster to use once I had learned it. I realized I was very willing to invest a little time in learning to use my text editor especially if it was going to repay me many-times over in efficiency later.
Vi Referencecard also listed here.
While available for most operating systems, Vim is strongest in a Linux shell, because it can take advantage of command-line power-user options. For example, you can open files in a hierarchy matching a certain text or filename pattern using:
vim `grep -rnil 'pattern' *`
vim `find . name '*.php'`
Or you can automate Vim's search and replace on files (again, recursively), with some simple shell scripting:
for i in `find . -name '*.txt'`; do vim -c "%s/[aeiou]/*/g | w | q" "$i"; done
(Obviously, do NOT execute that exact command, or anything like it, unless you know what you're doing.)
The nicest thing about VIM is that you can change the command keys to do pretty much whatever you like. For example, I recently toyed with having the backspace key erase a word instead of a character. Anything you set can be made permanent by adding it to your ~/.vimrc (the invisible VIM control file in your home directory). My current favourite Vim trick is using Mozilla Firebird's Mozex extension to start up gvim (the graphical version) when editing text in a web page form (thus giving me spell-checking, shell access, HTML markup shortcuts, automated text formatting, and so on).
" --------------------------------------------------------------
" SUMMARY OF SHORTCUTS (Control keys)
" --------------------------------------------------------------
" C-O open a file with file explorer (split screen)
" C-I open notes.txt (split screen), e.g. for notes
" C-F toggle nice formatting (kill during cut & paste)
" C-G toggle indent-based page folding (nice & compact)
" C-J rewrap a paragraph or a program comment
" C-L spell check a document
" C-E edit my ~/.vimrc settings (splitscreen)
" C-U update (reload) my ~/.vimrc settings
" C-Space cycle through split screens (maximize each)
" Q quit a file without writing
" S write a file back to disk
" C-N cycle through multiple open files (next)
" C-P cycle through multiple open files (previous)
" e.g. when using vim `grep -rnil 'pattern' *`
" --------------------------------------------------------------
" expedite ~/.vimrc edit & reload
map <C-e> :split ~/.vimrc <CR>
map <C-u> :source ~/.vimrc <CR>
" navigation
map <C-o> :split . <CR>
map <C-e> :split notes.txt <CR>
map <C-p> :prev <CR>
map <C-n> :next <CR>
" editing
map S :w <CR>
map Q :q <CR>
" block editing
map <S-Left> {
map <S-Right> }
map <S-Up> zk
map <S-Down> zj
" move between split screens
map <C-Space> <C-w><C-w><C-w>_<C-w>5-
" make it easy to grab HTML tags
map ] f>
map [ F<
" general settings
set incsearch
set ignorecase
set smartcase
set history=100
set shiftwidth=4
set tabstop=4
set expandtab
" C-f to toggle formatting
map <C-f> :set number! <CR> :set autoindent! <CR>
" other formatting options
map <C-g> :set foldenable! <CR>
map <C-j> gqap
map <C-h> :noh <CR>
" for email: wrap text to 72
map <C-m> :set textwidth=72
" initialise formatting
set number
set autoindent
syntax on
" auto-complete PHP tags (Ctrl-X Ctrl-K)
set dictionary=~/php.dictionary
set filetype=php
" folding
set foldenable
set foldmethod=indent
" Integrate aspell spelling checker
set autowrite
map <C-l> <Esc>:!aspell -c --dont-backup "%"<CR>:e! "%"<CR><CR>
Copyright: ©2000-07, Nigel Chapman · License: Creative Commons (some rights reserved) · Generator: TopicTree 0.8 · Generated: 07 Oct 2008, 09:32 pm AEST · Page maintained by Kalessin · Last modified: 29 March 2007, 08:35 PM AEST · 8 ms · Found in human likeness...