Fandom

Vim Tips Wiki

Preloading registers

Redirected from VimTip792

1,624pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Tip 792 Printable Monobook Previous Next

created 2004 · complexity basic · author zzapper · version 5.7


There never seem to be enough spare keys for maps.

It's possible however to preload Vim's registers in vimrc with your frequent commands, for example:

let @m=":'a,'bs/"
let @s=":%!sort -u"

Here's a twisted one

let @y='yy@"'

The command is executed by doing a @m

You can overwrite them of course when doing a recording or a plain yank; I prefer to leave registers a-q for yanks or recordings and preload the others.

CommentsEdit

> Never seems to be enough keys to map

Why not use prefix and/or virtual keys like gnu-emacs? Then refer to it by the virtual name.

Also I think Gvim supports 5 Xmodifiers as in gnu-emacs, (C-M-S-H-s-A-<key>) = (2^6 * 40) 2500 should be enough?

All your mappings go into ,<key> (personally I like named keys) and in emacs, I can invoke by name with completions, if I forget the mapping.


I already have 96 maps many with two character combinations using , and <Leader>.Preloading registers is just a possible alternative, and maybe avoids some of the syntaxical restrictions of maps,as they contain command sequences just as you would type them ie a recording'.


Also on Fandom

Random Wiki