Tuesday, 21 July 2009

 

VIM : Register Tricks

When you use the useful ct" (change till " character) (:help t - motion command) it can be annoying that you cannot . repeat it if the limiting character is not a "

Well not to worry the last text you inserted is still in the . register and can thus be retrieved with a <C-R>.

ie ct'<C-R>.

Don't forget it's brother the small delete register -

Or the other special registers which you can display with the following command

:reg "/-.:%*

Nor forget how to dump your numeric registers

"1p....... (normal mode)

Labels: , , ,


Wednesday, 1 July 2009

 

VIM: Creating Your Own Commands with a Map or a Recording

Customizing your own commands using a map or recording.

A Map is generally used for stored commands.

A Recording is used for one off jobs.

Recordings are more intuitive ie you simply record a sequence of commands.

Maps require a little more knowledge of map special characters <CR><ESC> etc

While it is possible to "save" a recording for future use it's a little tricky

:let @w="<C-R>q" ie read recording q (same as register q) and store in register w, which if put in your .vimrc will be preserved for future use

With experience you should find yourself preferring to create disposable recordings and relying less and less on maps; one well known Vimmer (Peppe) has a practically empty .vimrc.

Labels: , , ,


This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]