Vim split line command [duplicate]

Solution 1:

rEnter while on whitespace will do it. That's two keystrokes.

Solution 2:

I don't think that there is a single key command for this. The best you can do with stock vim is probably i Enter Esc.

Solution 3:

My solution was to remap the K key since I never use the default action (look up the word under cursor with "man"), and my previous editor used Alt+j and Alt+k to join and split lines, respectively.

:nnoremap K i<CR><Esc>

This rolls those three annoying keystrokes into one.

There's probably a more sophisticated way to also eliminate any trailing whitespace, but I prefer to strip all trailing whitespace on write.

Solution 4:

No. I've now read enough answers to conclude that there is no such command.

Easy answer: Pressing 'Enter' while in insert will do it; but you're right, there oughtta be a key for it in command mode. I've wondered, too.

Since everyone has a favorite workaround, I will share mine. The assumption is that I will do anything to avoid having to reach for the Esc key.

ylprX ... where 'X' is the inserted character, which can even be a newline.

So, 'yl' is yank on char to the right, 'p' = paste the char, 'r' is replace that char; then you just type the new char. That's how much I hate using Escape.

(That was 'l', as in "move right", BTW)

Solution 5:

Old thread, but I dont use "K" for the man page lookup or whatever magic it does. So I have this mapping in my .vimrc:

map K i<Enter><Esc>

I figured since "J" is join, "K" can be krack or something. :)