Reputation: 2283
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?
Upvotes: 25
Views: 29441
Reputation: 1618
As @alex-shwarc points out, <C-o> o
(CTRL-o) gets you the behavior you want natively (and conversely <C-o> O
to create a new line above and insert into it). <C-o>
is really useful, see :help i_CTRL-O
.
Upvotes: 0
Reputation: 84343
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.
Upvotes: 36
Reputation: 13143
<ESC> o
- To open a line below
<ESc> Shift + o
- To open a line above.
Upvotes: 31