home | codereading | contact | math | misc | patches | tech


Vim notes

See information about a character under cursor

:he ascii

Inserting a special character in vim

To insert a special character in vim, in the insert mode, type Control-v and the combination of keys that produce that special character.

For example: To insert a Control-M (^M), enter at the insert mode, type Control-v and then Control-m.

Fold lines that begin with *

# vim: set fdm=expr:
# vim: set foldexpr=getline(v\:lnum)=~'^\\*.*$'&&getline(v\:lnum+1)!~'^\\*.*$'?'>1'\:1:

Change case of a string matched by a regexp

The substitution (:s) command in vim has very useful features. To see some special replacement see ":he sub-replace-special".

In a HTML file, to make all tags and their parameters lowercase, type:

:%s/<[^>]*>/\L&\E/g

Vim doesn't show errors for formatexpr, foldexpr (etc.) functions

According to this thread, you should check your 'debug' option. :he debug for more details.