Abbreviations add spaces when they shouldn't
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I'm trying to create an abbreviations to insert a comment and to insert a TODO
comment. I wrote them as following:
iab co /*__*/<Left><Left><Left>
This one produces the following (where it has three spaces)
/*__|_*/
And for the TODO
comment, I wrote it like this:
iab td /*_TODO:_*/<Left><Left><Left>
This one produces
/* TODO:____|_*/
For some reason, vim adds extra spaces when interpreting the abbreviations. Could someone tell me why does it do this and how can I solve it?
Note: I replaced spaces with underscores for clarity.
abbreviations
add a comment |Â
up vote
1
down vote
favorite
I'm trying to create an abbreviations to insert a comment and to insert a TODO
comment. I wrote them as following:
iab co /*__*/<Left><Left><Left>
This one produces the following (where it has three spaces)
/*__|_*/
And for the TODO
comment, I wrote it like this:
iab td /*_TODO:_*/<Left><Left><Left>
This one produces
/* TODO:____|_*/
For some reason, vim adds extra spaces when interpreting the abbreviations. Could someone tell me why does it do this and how can I solve it?
Note: I replaced spaces with underscores for clarity.
abbreviations
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm trying to create an abbreviations to insert a comment and to insert a TODO
comment. I wrote them as following:
iab co /*__*/<Left><Left><Left>
This one produces the following (where it has three spaces)
/*__|_*/
And for the TODO
comment, I wrote it like this:
iab td /*_TODO:_*/<Left><Left><Left>
This one produces
/* TODO:____|_*/
For some reason, vim adds extra spaces when interpreting the abbreviations. Could someone tell me why does it do this and how can I solve it?
Note: I replaced spaces with underscores for clarity.
abbreviations
I'm trying to create an abbreviations to insert a comment and to insert a TODO
comment. I wrote them as following:
iab co /*__*/<Left><Left><Left>
This one produces the following (where it has three spaces)
/*__|_*/
And for the TODO
comment, I wrote it like this:
iab td /*_TODO:_*/<Left><Left><Left>
This one produces
/* TODO:____|_*/
For some reason, vim adds extra spaces when interpreting the abbreviations. Could someone tell me why does it do this and how can I solve it?
Note: I replaced spaces with underscores for clarity.
abbreviations
abbreviations
asked 4 hours ago
Salahuddin Ahmed
1545
1545
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
This happens usually, because the abbreviation is triggered once you type a final space after the characters that trigger the abbreviation, e.g. after tdSpace, so that the final space gets added at the cursor position after your expanded abbreviation.
One way around it is to make use of the Eatchar
function mentioned at the help (there is no actual helptag for it, you can do :helpgrep Eatchar
to find it).
Here is the definition from the help together with your TODO abbreviation.
func Eatchar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunc
iab td /* TODO: */<Left><Left><Left><c-r>=Eatchar('s')<cr>
Super. You clarified it very well. For me it added more spaces because I was hitting tab after the trigger and not space. Now I modified the abbreviation so that the added space is considered in the abbreviation. Thank you
– Salahuddin Ahmed
2 hours ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
This happens usually, because the abbreviation is triggered once you type a final space after the characters that trigger the abbreviation, e.g. after tdSpace, so that the final space gets added at the cursor position after your expanded abbreviation.
One way around it is to make use of the Eatchar
function mentioned at the help (there is no actual helptag for it, you can do :helpgrep Eatchar
to find it).
Here is the definition from the help together with your TODO abbreviation.
func Eatchar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunc
iab td /* TODO: */<Left><Left><Left><c-r>=Eatchar('s')<cr>
Super. You clarified it very well. For me it added more spaces because I was hitting tab after the trigger and not space. Now I modified the abbreviation so that the added space is considered in the abbreviation. Thank you
– Salahuddin Ahmed
2 hours ago
add a comment |Â
up vote
3
down vote
accepted
This happens usually, because the abbreviation is triggered once you type a final space after the characters that trigger the abbreviation, e.g. after tdSpace, so that the final space gets added at the cursor position after your expanded abbreviation.
One way around it is to make use of the Eatchar
function mentioned at the help (there is no actual helptag for it, you can do :helpgrep Eatchar
to find it).
Here is the definition from the help together with your TODO abbreviation.
func Eatchar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunc
iab td /* TODO: */<Left><Left><Left><c-r>=Eatchar('s')<cr>
Super. You clarified it very well. For me it added more spaces because I was hitting tab after the trigger and not space. Now I modified the abbreviation so that the added space is considered in the abbreviation. Thank you
– Salahuddin Ahmed
2 hours ago
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
This happens usually, because the abbreviation is triggered once you type a final space after the characters that trigger the abbreviation, e.g. after tdSpace, so that the final space gets added at the cursor position after your expanded abbreviation.
One way around it is to make use of the Eatchar
function mentioned at the help (there is no actual helptag for it, you can do :helpgrep Eatchar
to find it).
Here is the definition from the help together with your TODO abbreviation.
func Eatchar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunc
iab td /* TODO: */<Left><Left><Left><c-r>=Eatchar('s')<cr>
This happens usually, because the abbreviation is triggered once you type a final space after the characters that trigger the abbreviation, e.g. after tdSpace, so that the final space gets added at the cursor position after your expanded abbreviation.
One way around it is to make use of the Eatchar
function mentioned at the help (there is no actual helptag for it, you can do :helpgrep Eatchar
to find it).
Here is the definition from the help together with your TODO abbreviation.
func Eatchar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunc
iab td /* TODO: */<Left><Left><Left><c-r>=Eatchar('s')<cr>
answered 3 hours ago


Christian Brabandt
14.5k2443
14.5k2443
Super. You clarified it very well. For me it added more spaces because I was hitting tab after the trigger and not space. Now I modified the abbreviation so that the added space is considered in the abbreviation. Thank you
– Salahuddin Ahmed
2 hours ago
add a comment |Â
Super. You clarified it very well. For me it added more spaces because I was hitting tab after the trigger and not space. Now I modified the abbreviation so that the added space is considered in the abbreviation. Thank you
– Salahuddin Ahmed
2 hours ago
Super. You clarified it very well. For me it added more spaces because I was hitting tab after the trigger and not space. Now I modified the abbreviation so that the added space is considered in the abbreviation. Thank you
– Salahuddin Ahmed
2 hours ago
Super. You clarified it very well. For me it added more spaces because I was hitting tab after the trigger and not space. Now I modified the abbreviation so that the added space is considered in the abbreviation. Thank you
– Salahuddin Ahmed
2 hours ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f17692%2fabbreviations-add-spaces-when-they-shouldnt%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password