I am Vim newbie, and I'm using MacVim on OSX Snow Leopard. One of the most common actions I have to take is to move the cursor to a new line but also move the text after the cursor to the new line. I know that pressing 'o' in normal or visual mode moves the cursor to a new line and switches the mode to insert.
What I'd like to do is move the cursor to a new line, and move the text after the cursor to that new line as well, preferably staying in the normal mode? Is this possible? How can I accomplish this task?
Move the text cursor to where you want the new line to begin, press the Enter key, hold down the Shift key, and then press Enter again. You can continue to press Shift + Enter to move to each new line, and when ready to move to the next paragraph, press Enter .
If you are talking about moving the cursor to next line on screen when you are at command prompt then you can use the key combination ctrl+enter to add a line break and reach next line.
Jump to a specific line number ↩Press Ctrl+G, or select Goto > Goto Line, to open the Goto Line palette. Type in the number to which you want to jump. Press Enter, & your cursor will now be on that line.
I know that pressing 'o' in normal or visual mode moves the cursor to a new line and switches the mode to insert.
If the cursor is on a <space>
as in ([]
marks the cursor):
lorem ipsum[ ]dolor sit amet
the simplest is to do r<CR>
, that is "replace the current character with a linebreak".
Otherwise, use @knittl's solution.
So you want to move everything in the current line, which comes after the cursor to the next line? Read: insert a line break??
(move cursor)
i (or a)
<return>
<esc> (or ^C)
To map this sequence of keystrokes to a single key, follow @thb's suggestion and use the :map
command:
:map <F2> i<CR><ESC>
:map <F2> i<CR>
This keeps vi in insert mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With