Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 ?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
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. –  Sukminder Mar 13 '13 at 22:51
add comment

Why not O<Esc>?

:map + O<Esc>
share|improve this answer
    
...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? –  Stephane 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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