Vim Tips Wiki

Simple placeholders

Redirected from VimTip1071

1,624pages on
this wiki
Add New Page
Talk0 Share
Tip 1071 Printable Monobook Previous Next

created December 9, 2005 · complexity basic · author gabriel · version 5.7

I was very impressed with the functionality of placeholders in the Latex-Suite script#475, so I decided to add a similiar functionality to my vimrc.

" A syntax for placeholders
" Pressing Control-j jumps to the next match.
inoremap <c-j> <Esc>/<++><CR><Esc>cf>

You could of course use any key-sequence for this. I use it with my code for () completion. It can be equally well used with templates and other abbreviations.

" Completions using placeholders
inoremap ( ()<++><Esc>F)i
inoremap [ []<++><Esc>F]i
inoremap { {}<++><Esc>F}i

This doesn't care if the code is entered free or if it's inside a block of text. In which case I think it should not expand. But I find it helpful none the less. Unlike the scripts pointed to by the comments this tip is just what it advertises. Simple.


Similar to this is markjump.vim script#485, in addition to others (the names of which escape me for now). Markjump adds a few advantages to this method such as not mangling the search pattern and providing previous and next jumps.

You may have a look at what I produced in the API plugin script#50. It already takes cares of what you are rewriting and much more. See also script#336 and mu-template (the fork I'm maintening provides a better integration of markers/placeholders) that fully integrate the bracketing system.

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.

Also on Fandom

Random Wiki