sponsor Vim development Vim logo Vim Book Ad

basic Tip #481: abbreviations only on shortcut

 tip karma   Rating 14/11, Viewed by 988 

created:   June 3, 2003 15:44      complexity:   basic
author:   maurice      as of Vim:   6.0

Actually, this is just a more flexible completion.

I made the following (example) to have a unique abbreviation:

  iabbrev date^A  <c-r>=strftime("%F")<cr>

Note that ^A is Control-A (insert with <c-v><c-a>).
This is to avoid the completion if you really want to write 'date'.

And now this mapping:

  inoremap <c-b> <c-v><c-a><c-[>a

Now type date<c-b> in insert-mode and you will get the date.

 rate this tip  Life Changing Helpful Unfulfilling 

<<editing files on an ftp server listening  on a non-standard port | Use VIM as an organizer of Memos, bookmarks, todo, etc. >>

Additional Notes

salmanhalim at hotmail.com, May 5, 2004 21:28
So why not just use this?

iabbrev date^B  <c-r>=strftime("%F")<cr>

Admittedly, it requires you to do something after the control-b (such as another key or escape), but you would do precisely the same thing anyway with the original procedure.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo