I want to map braces to input opening braces to have this effect
int main(void){
//缩进了
}
I can achieve the effect by modifying the .vimrc in the home directory. The problem is that this setting is effective for all files.
C I want to have such an effect, but other languages (such as python/lua) I don't want to have such a mapping. How can I set up vim for a certain language?
Which file do you want to modify?
習慣沉默2017-07-03 11:44:28
is also written in .vimrc
, but the file type must be specified:
filetype indent on
autocmd FileType cpp setlocal ......
# 后面省略号为具体设置,空格分隔,缩写见下表
Variable name | Abbreviation | Meaning |
---|---|---|
(no)autoindent |
ai |
Auto-indent, which automatically adds the same indentation to new lines as the current line. |
(no)cindent |
ci |
Similar to the indentation of C language programs |
(no)smartindent |
si |
Some improvements based on autoindent |
tabstop=X |
ts |
How many spaces does one TAB character occupy during editing? |
shiftwidth=X |
sw |
Use the number of spaces per level of indentation. |
(no)expandtab |
(no)et |
Whether to automatically expand the input TAB into spaces. To enter TAB after opening, you need Ctrl-V<TAB> |
softtabstop=X |
sts |
It is convenient to use the backspace (BACKSPACE) key after opening et. Each time you backspace, X spaces will be deleted |
(no)smarttab |
(no)sta |
When turned on, pressing TAB at the beginning of the line will add sw spaces, otherwise ts spaces will be added. |