Vim registers standards
-
11-12-2019 - |
سؤال
I was thinking of setting my registers to equal common coding techniques. For example, I was thinking of doing this:
:let @i = "int i=0;"
Then I would set f
for for loop, w
for while loop etc. Is this a bad technique or is there a better way of doing this?
المحلول
I think that you could use snippets instead. Try to look at snipmate plugin http://www.vim.org/scripts/script.php?script_id=2540
You can just type "inti TAB" and it'll expand to "int i=0;" if you wish.
It already has a lot of snippets to many languages but you can configure it to do what you want.
نصائح أخرى
For simple expansions, the built-in abbreviations will suffice:
:iab ii int i=0;
If you want parameter expansion, different "stops" to fill in data, and other advanced features, various snippets plugins (on http://www.vim.org/) offer this functionality; one of the first and broadly used ones is snipMate.