Auto Indent + 1 in insert mode or normal

2 views
Skip to first unread message

Tim Johnson

unread,
Nov 18, 2008, 10:09:04 PM11/18/08
to vim_use
Using vim 7.1 (huge version) on Kubuntu 7.10

I would like to be able to type <enter> or Ctrl-J
in insert mode and open a new line indented one
more tab than the previous:
example - type "block: []"
move cursor between the braces
type Ctrl-J
result might be:
block: [
]
alternatively, a normal mode approach would be as desirable.

Any references to discussions on this topic, Help commands
or plugins would be welcome.
thanks
tim

fritzophrenic

unread,
Nov 19, 2008, 11:12:28 AM11/19/08
to vim_use
I would first suggest using an indentexpr or the indent ftplugin for
your file type. See :help 'indentexpr' and :help :filetype-indent-on

If this doesn't work for you, a simple mapping will suffice.

I would suggest:
:imap <C-CR> <CR><C-I>
:imap <C-S-CR> <CR><C-D>

This will allow you to press CTRL-ENTER for a new line with more
indent, and CTRL-SHIFT-ENTER for a new line with less indent.

These keys are not taken by any built-in functionality that I can find.

Tim Johnson

unread,
Nov 19, 2008, 1:55:31 PM11/19/08
to vim...@googlegroups.com
On Wednesday 19 November 2008, fritzophrenic wrote:
> I would first suggest using an indentexpr or the indent ftplugin for
> your file type. See :help 'indentexpr' and :help :filetype-indent-on
>
> If this doesn't work for you, a simple mapping will suffice.
Great! I was looking for some references...

> I would suggest:
> :imap <C-CR> <CR><C-I>
> :imap <C-S-CR> <CR><C-D>
And this is a great start.

> This will allow you to press CTRL-ENTER for a new line with more
> indent, and CTRL-SHIFT-ENTER for a new line with less indent.
>
> These keys are not taken by any built-in functionality that I can find.
Thanks
Tim

Reply all
Reply to author
Forward
0 new messages