Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim split line command [duplicate]

Tags:

vim

Possible Duplicate:
How do I insert a linebreak where the cursor is without entering into insert mode in Vim?

In vim, J joins the next line to the current line. Is there a similar one-key (or relatively short) command to split a line at a given cursor position? I know it be done with a simple macro, but it seems like if the J-command exists there should be a similar function. I've tried searching for it, but can't seem to find an answer.

like image 845
dburke Avatar asked Mar 09 '09 02:03

dburke


People also ask

How do I split one line into multiple lines in Vim?

The easiest way I've found to split lines in Vim is the normal mode command gq (type both letters in quick succession in normal or visual mode). In visual mode, it will split whatever is selected, in normal mode, you follow gq with a motion. For example, gql will split one line to the currently set width.

How do you repeat a line in Vim?

Press the ESC key to be sure you are in vi Command mode. Place the cursor on the first line of the text you wish to copy. Type 12yy to copy the 12 lines. Move the cursor to the place where you wish to insert the copied lines.

How do I go down multiple lines in Vim?

In normal mode or in insert mode, press Alt-j to move the current line down, or press Alt-k to move the current line up. After visually selecting a block of lines (for example, by pressing V then moving the cursor down), press Alt-j to move the whole block down, or press Alt-k to move the block up.

How do I insert multiple lines at the beginning of Vim?

vim Inserting text Insert text into multiple lines at once Press Ctrl + v to enter into visual block mode. Use ↑ / ↓ / j / k to select multiple lines. Press Shift + i and start typing what you want. After you press Esc , the text will be inserted into all the lines you selected.


1 Answers

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

like image 94
Michael Kristofik Avatar answered Sep 24 '22 02:09

Michael Kristofik