Question

I use c.vim plugin for vim. Different hotkeys generate part of code which should be quickly modifiable. For example (there in no cursor tag, it's the place where cursor is located after hotkey):

for (*<cursor>* ; {+CONDITION+}; {+INCREMENT+} ) { }

How to quickly modify things in curly braces?

Était-ce utile?

La solution

If you like the automatic snippet insertion, there are now a couple of general plugins which are not limited to C files (but many ship with built-in snippets for C, C++, Java, etc., and all of them are extensible by you). Those may be a more powerful alternative.

snippets are like the built-in :abbreviate on steroids, usually with parameter insertions, mirroring, and multiple stops inside them. One of the first, very famous (and still widely used) Vim plugins is snipMate (inspired by the TextMate editor); unfortunately, it's not maintained any more; though there is a fork. A modern alternative (that requires Python though) is UltiSnips. There are more, see this list on the Vim Tips Wiki.

There are three things to evaluate: First, the features of the snippet engine itself, second, the quality and breadth of snippets provided by the author or others; third, how easy it is to add new snippets.

Autres conseils

If the cursor is on or in {+CONDITION+} you can use ci{ or ca{ for change inner block or change a block.

Change inner block leaves the curly brackets and change a block does not.

Take a look at :h text-objects and :h i{

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top