Skip to main content
Changed subject to be a bit more generally accessible
Link
B Layer
  • 20.1k
  • 2
  • 32
  • 59

Delete (big-)Word in insert mode: How to prevent cursor shift when using <C-o>dB map failsO>{delete cmd} at the end of a line?

Became Hot Network Question
Source Link
usretc
  • 384
  • 1
  • 12

Delete (big-)Word in insert mode: <C-o>dB map fails at end of line

<C-w> deletes a (small-)word in insert mode, but I often want to delete the Word (to last whitespace) I've most recently typed. I tried

inoremap <C-_> <C-o>dB

which kind-of works -- except that at the end of the line, <C-o> moves the cursor left one character (and so the last character survives the deletion).

Other options? More generally, how do I use <C-o> in insert-mode mappings without the end-of-line off-by-one problem? Can the normal-mode cursor (which is what <C-o> summons) be placed "temporarily" beyond the line-end?