1

I have this keybinding in .vimrc:

map + :put=''<cr>
map - dd

I find it really useful for fast layout and source file cleaning with + and -.

But using :put=""<cr> adds a line after the current cursor line, whereas dd removes a line at the current cursor.

I'd rather have my + keybinding insert a line rather than add it after. What command should I try ?

2

Edit: Reading it again I gather I misunderstood. But, what about:

-put

It inserts line above current.

Edit:

As do:

 put!

To insert at mark (m[a-z]) one can say 'aput=xx, 'bput=xx etc.

  • after your correction -put is ok. However I don't have understood the difference between .put and put. – Stephane Rolland Mar 13 '13 at 22:44
  • 1
    @StephaneRolland: AFAIK they are the same. As is +0put and -0put. If you do not know one also have $put as last line, 0put to NNput for line specific. +1put two down, +2put three down -3put three up etc. Believe one can also put on marks, but have to check that. – Runium Mar 13 '13 at 22:51
3

Why not O<Esc>?

:map + O<Esc>
  • ...but it also makes vim switch and reswitch of mode. – Stephane Rolland Mar 13 '13 at 23:40
  • @StephaneRolland, So does :put. (normal <-> cmd), why does that matter? – Stéphane Chazelas Mar 13 '13 at 23:41
  • just because I thought vim was slow to change of mode, but I have just checked, and that doesn't seem to be the case. – Stephane Rolland Mar 13 '13 at 23:44

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.