I would like to use something like Shift + Enter to create a new line in Vim.
So if |
is the cursor, here is what I would like to do:
<%= some.code("in here") | %>
Now, press Shift + Enter (or something similar) and get this as output:
<%= some.code("in here") %> and my new line here |
Is this possible?
If you want to type in text, you need to be in Insert mode. To move from Command mode to Insert mode, press "i" (no quotes). To move from Insert mode to Command mode, press "ESC" (the Escape key). NOTE: If your terminal doesn't have an ESC key, or the ESC key doesn't work, use Ctrl-[ instead.
Home in insert mode. Esc + i to exit insert mode and enter it again, effectively going to the beginning of line.
Using search and replace In the substitute command, the find pattern is empty, so the last search is used; in the replacement, \r inserts a newline and & inserts the search hit (see search and replace). Use :%s//\r&/g if you want to replace all occurrences in all lines.
If you want a new line at the top of the current line then press CTRL + SHIFT + ENTER. If you want a new line at the bottom of the current line then press CTRL+ ENTER.
There are probably a number of ways to do what you want, but one option is to use CTRL-O to escape to normal mode to insert the line. For example CTRL-O o will open a new line below the current line and place your cursor there in insert mode.
If you want to map this rather than use it as a one-off, you can use an imap to set your mnemonic of choice. For example:
:imap \nn <C-O>o
will create an insert-mode mapping for \nn that will do the same thing.
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