How vim adopts different key mappings for different languages
伊谢尔伦
伊谢尔伦 2017-07-03 11:42:28
0
1
1204

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?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
習慣沉默

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.
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template