Simple completion for "template" on vim a la sublime ( potentially using YouCompleteMe )?

50 Views Asked by At

I didn't understand how to use YouCompleteMe to create nice templates like stuff I used to have on sublime.

Two basic examples I would like to achieve:

typing "log" being completed to

console.log "\$1"

typing "fori" being completed to

for \$1 in \$2
  \$3

So basically expanding the template then allowing me to quickly filled the spaces and end up on the last "cue".

From what I understood YouCompleteMe does anything you need including mocha late and milkshakes, but I still have no clue how to do this simple thing.

1

There are 1 best solutions below

0
On

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.