vim tips     
Vim

format file: :%!fmt

format range of lines :5,40!fmt

format a paragraph: :!}fmt

delete a line w/ regex: :g/[regex]/d

ctrl-a increments the next number it finds by one

convert capital words (HTML tags) to lowercase :%s/[A-Z][A-Z][A-Z]*/\L&/g

to record macro: qq, type commands to be recorded to the q buffer,
hit q again to end the recording of commands, then use @q to run the macro.

set expandtab and run :retab to convert all tabs to spaces

to see the ascii, hex and octal value of a character, move over the character and type 'ga'

to see the command history (useful for complex commands that you want to alter)
type 'q:'

to open another file within the current vim, use :edit [filename]

convert text to upper case with gU, lowercase with gu and swap case with g~
for example, to convert the rest of the line to upper case, use gU$
Or, to convert an entire line use gU, gu or g~

View your search history:
/ Ctrl-F (:q to exit)

Restore the cursor to the file position in previous editing session (vim.org tip)
Put this line in .vimrc:

au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

On FreeBSD, to get syntax color highlighting add this to .vimrc
set ttytype=xterm-color

I remember seeing a way to search and replace for a range (like a paragraph)
but I can't find it now.

To convert line endings between Windows and Linux, use fileformat (ff)
set ff=unix
set ff=dos

Updated Jun 14, 2010

Number of readers
home
about me
blog archives
- docs
acroread
firefox
java
linux
mysql
perl
rpm
shell
vim
win

entertainment
experiences
funny lists
humor
intellectual
interests
metafilter
music
opinions
photos
web designs
tools
software
webmaster help

Sign up
Enter your email address to be notified of new posts




Search the site







Random quote
(View all quotes)
"It is nice to be important, but more important to be nice."










(?) Choose theme:  X X X X X X