JumpForward & JumpBackward triggers defined only during snippet expansion
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
UltiSnips |
Fix Committed
|
Wishlist
|
Unassigned |
Bug Description
When using the default configuration the keys <c-k> and <c-j> are mapped to jump between the placeholders. But as these mappings are always defined, they interfere with the normal function of these keys.
For instance, in insert mode the dictionary completion (:h i_CTRL-X_CTRL-K) doesn't work due to the <c-k> mapping created after a snippet is expanded.
Of course changing the value of g:UltiSnipsJump
Instead it would be nice if the mappings are defined only when expanding the snippet. I've tried to do this with the following functions:
function! UltiSnips_
" TODO: use maparg() to save current mapping (if any) to these keys, which
" can be restored on UltiSnips_
if g:UltiSnipsExpa
exec "inoremap <silent> " . g:UltiSnipsJump
exec "snoremap <silent> " . g:UltiSnipsJump
endif
exec "inoremap <silent> " . g:UltiSnipsJump
exec "snoremap <silent> " . g:UltiSnipsJump
endf
function! UltiSnips_
if g:UltiSnipsExpa
exec "iunmap " . g:UltiSnipsJump
exec "sunmap " . g:UltiSnipsJump
endif
exec "iunmap " . g:UltiSnipsJump
exec "sunmap " . g:UltiSnipsJump
endf
Removing the mappings definition from UltiSnips_MapKeys() and placing calls to function UltiSnips_
_
Is it possible? Do you see any downsides on this approach or a better solution?
I think it should be possible to do that. Vim users are also used to modes - so they might take to this idea naturally. However I personally would hate to try to use the feauture my muscle memory expects from this key just to realize that it now jumps forward inside - instead of doing that other thing that it does outside of the snippet.
So in general I am not very fond of the idea. If you provide and implementation including good test coverage I will include it into UltiSnips though - it is optional for users - people like myself will just map to keys that are not overloaded, others might use this feature without even realizing.