Tip #650: abbreviation that prompts whether to expand it or not
tip karma |
Rating 5/5, Viewed by 406
|
created: |
|
February 4, 2004 7:13 |
|
complexity: |
|
basic |
author: |
|
Yakov Lerner |
|
as of Vim: |
|
6.0 |
You can define abbreviation in such a way that it will ask whether to expand it or not. The trick is to define it as insert-mode mapping with special body, not as abbreviation.
Here is how to define it:
function! MyExpand(abbr,expansion)
let answer=confirm("Expand '".a:abbr."' [y] ", "&Yes;\n&No;")
if answer==2
exec "normal! a".a:abbr
else
exec "normal! a".a:expansion
endif
endfunction
imap ABC <esc>:call AskExpand("ABC","...expansion for ABC ...")<cr>a
imap XYZ <esc>:call AskExpand("XYZ","...expansion for XYZ ...")<cr>a
<<expand existing abbreviation |
Edit gnupg-encrypted files. >>
Additional Notes
|