How to set syntax specific settings in my VIMRC?
5,358
Solution 1
Use the FileType
autocommand event. See :h autocmd.txt
for details.
au Filetype python source ~/.vim/scripts/python.vim
Solution 2
ft-plugins are what you are looking for.
See the following answers:
- Vim Hotkeys For Specific File
- https://stackoverflow.com/questions/1404515/gvim-and-multiple-programming-languages/1404570#1404570
Related videos on Youtube
Author by
sa125
Updated on September 17, 2022Comments
-
sa125 over 1 year
I work with several languages and markups in vim every day (ruby, python, javascript, CSS, HTML, etc), and would like to have different settings for each buffer when I fire up my editor. How can I detect which syntax is loaded in the current buffer?
Specifically, I really prefer python indent to be 4 spaces, while other languages are find with 2. I've envisioned something like this in my
.vimrc
file:if syntax == 'python' set softtabstop=4 set shiftwidth=4 else if syntax == 'html' " ... endif
Anything like that in vim? thanks.
-
Luc Hermitte over 13 yearsWhy creating non standard directories ? -> ~/.vim/ftplugin !