Vim Tips Wiki
No edit summary
 
m (Undo revision 22208 by Luc Hermitte (talk): no category has been defined yet ; comments still need to be merged into a See Also §)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=1071
 
|id=1071
  +
|previous=1070
|title=Simple placeholders
 
  +
|next=1072
|created=December 9, 2005 0:01
+
|created=December 9, 2005
 
|complexity=basic
 
|complexity=basic
|author=gabriel dot j at telia dot com
+
|author=gabriel
 
|version=5.7
 
|version=5.7
 
|rating=5/6
 
|rating=5/6
  +
|category1=
|text=
 
  +
|category2=
I was very impressed with the functionality of placeholders in the Latex-Suite
 
 
}}
 
I was very impressed with the functionality of placeholders in the Latex-Suite {{script|id=475}}, so I decided to add a similiar functionality to my vimrc.
   
  +
<pre>
scripts [/scripts/script.php?script_id=475 vimscript &#35;475]
 
 
" A syntax for placeholders
 
" Pressing Control-j jumps to the next match.
  +
inoremap <c-j> <Esc>/<++><CR><Esc>cf>
  +
</pre>
   
  +
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.
so I decided to add a similiar functionality to my .vimrc. I can't really say if it's done in a healthy way, I don't have that much experience with vim.
 
   
  +
<pre>
 
" Completions using placeholders
 
inoremap ( ()<++><Esc>F)i
 
inoremap [ []<++><Esc>F]i
 
inoremap { {}<++><Esc>F}i
  +
</pre>
   
 
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.
   
 
==Comments==
" A syntax for placeholders
 
 
Similar to this is markjump.vim {{script|id=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.
 
" Pressing Control-j jumps to the next match.
 
 
inoremap &lt;c-j&gt; &lt;ESC&gt;/&lt;++&gt;&lt;CR&gt;&lt;ESC&gt;cf&gt;
 
 
 
 
You could of course use any key-sequence for this.
 
 
I use it with my code for () completion.
 
 
It can be equaly well used with templates and other abbreviations.
 
 
 
 
" Completions using placeholders
 
 
"
 
 
inoremap ( ()&lt;++&gt;&lt;ESC&gt;F)i
 
 
inoremap [ []&lt;++&gt;&lt;ESC&gt;F]i
 
 
inoremap { {}&lt;++&gt;&lt;ESC&gt;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 aught to not expand. But I find it helpfull none the less.
 
 
 
 
If someone has better ways to do any of this I'd be much obliged. =)
 
 
I'm quite sure there is one.
 
}}
 
 
== Comments ==
 
Similar to this is markjump.vim (which is [/scripts/script.php?script_id=485 vimscript &#35;485]) in addition to others (the names of which escape me for now to my dismay). Markjup in particular conifers a few advantages to this method such as not mangling the search pattern and providing previous and next jumps... in addition to too many ways of entering the markers, for what it is worth (=
 
   
sreny--AT--srenyqernzf.pbz (Rot13ed)
 
, December 9, 2005 4:06
 
 
----
 
----
You may have a look at what I produced in the API plugin [/scripts/script.php?script_id=50 vimscript&#35;50]. It already takes cares of what you are rewriting and much more ; see also [/scripts/script.php?script_id=336 vimscript&#35;336], and mu-template (the fork I'm maintening provides a better integration of markers/placeholders) that fully integrate the bracketing system
+
You may have a look at what I produced in the API plugin {{script|id=50}}. It already takes cares of what you are rewriting and much more. See also {{script|id=336}} and mu-template (the fork I'm maintening provides a better integration of markers/placeholders) that fully integrate the bracketing system.
At this time, a much more recent version is available on my web site.
 
   
hermitte {at} free {dot} fr
 
, December 9, 2005 6:40
 
 
----
 
----
<!-- parsed by vimtips.py in 0.620257 seconds-->
 

Latest revision as of 15:07, 3 March 2009

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.

Comments[]

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.