问题描述
如何使vim将光标放在大括号内,从新行开始,即使用| |.表示光标位置:
How do I get vim to place the cursor within the braces starting on a new line, ie with | denoting the cursor position :
class {
|
}
现在使用我的设置,它只能执行此操作
right now with my settings it only does this
class {
|}
我在.vimrc文件中得到了这个设置autoindent shiftwidth = 2 tabstop = 2 noexpandtab
I got this in my .vimrc fileset autoindent shiftwidth=2 tabstop=2 noexpandtab
基本上,我只想普通的IDE对其进行缩进.
Basically I just want how a normal IDE would indent it.
更新:
我发现了如何使用inoremap { {<CR>}<Esc>O
推荐答案
将其放在您的.vimrc中:
Put this in your .vimrc :
imap <C-Return> <CR><CR><C-o>k<Tab>
假设autoindent
和smartindent
的设置正确,在括号之间键入Ctrl + Return
会将光标放在想要的位置.
Assuming autoindent
and smartindent
are set correctly, typing Ctrl + Return
between braces will put your cursor where you want it to be.
这篇关于Vim自动缩进换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!