Vim

From The System Administrator Zone

How do I use a custom syntax file?

# create a directory for them
> mkdir -p ~/.vim/syntax
# copy the .vim files there...
> vim
:set syntax=mine <-- where mine is the name of the syntax file mine.vim

I want Vim to detect the type of file!

# during your vim session
:!mkdir ~/.vim/ftdetect
# create a one line file with an autodetect command

au BufRead,BufNewFile *.mine set filetype=mine
:w ~/.vim/ftdetect/mine.vim


Sort a section of the file

If you want to sort the lines of a section of the file, place a blank line at the end of the section you want to sort, then place your cursor at the beginning of that section.

Type;

!}sort	

The will feed everything from the place you typed the exclamation mark to the first blank line through the sort command.


Format a paragraph to 72 character lines

To format a paragraph, joining and filling lines to produce output lines of up to 72 characters in length, type;

!}fmt	

Using Virtual Block

  • Ctr-v #Starts Virtual Block mode
    • Shift-i # Insert text before selected
    • "c" # Change selected
    • "d" # Deletes selected