Reputation: 13347
in vimrc if I do
iab YBK \left<\right><Left><Left><Left><Left><Left><Left><Left>
then when I type YBK
I will have
\left<
_\right>
where _
is the where the cursor stays. This is pretty much what I want except that vim automatically generates a line break before the cursor position, as what I want is
\left< _ \right>
So, how to avoid the nuisance of line break? thanks.
Upvotes: 1
Views: 215
Reputation: 393114
look at surround.vim. I think you can extend it with your own 'open/close' pairs. It has this behaviour builting for several types of pairs already. Two examples to spark your interest:
vS
C-] (wraps in {
... }
with newlines around it and indenting according to the filetype indent settings
vS
C-<para
Enter (wraps in <para>
... </para>
), example:
.
the quick fox jumped over
(position cursor on the q
in quick, press v2eS
C-<para
Enter
Result:
the <para>
quick fox
</para> jumped over
Edit
It appears that maybe you wanted this the other way around - without linebreaks. Well then, use vs<para
Enter or vS{
respectively, which by default don't insert linebreaks
Upvotes: 2