0

Is it possible to remap comma in select mode to exit select mode, enter insert mode, [optionally: go the end of the last selection (which the cursor seems to be for ultisnips)] and append a comma? This can be very useful while using a ultisnips snippet below to quickly add new items to a opt=val type argument list: new ,opt1=val1,opt2=val2,opt3=val3

snippet , "add one more item" i
,${1:option}=${2:value}
endsnippet

I tried something like this:

smap , <Esc><Esc>a,

but it doesn't do that, and ends up deleting the last selection.

1

You must use snoremap as your mappings' RHS contains LHS. And this is a good habit anyway.

exit select mode, enter insert mode, [optionally: go the end of the last selection (which the cursor seems to be for ultisnips)] and append a comma?

For simplicity, let's assume that :h 'selection' is inclusive. Then we have

snoremap , <Esc>g`>a,
1
  • Thanks, actually I needed to add this let g:UltiSnipsRemoveSelectModeMappings = 0 to my .vimrc as ultinips plugin overwrites users select mode mappings. There is apparently a way to disable only few mappings, though I didn't try that.
    – reportaman
    Mar 6 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.