Some questions on .vimrc and vim configuration

回眸只為那壹抹淺笑 提交于 2019-12-04 02:40:06

Vim has built functionality for this:

:se exrc
Enables the reading of .vimrc, .exrc and .gvimrc in the current
directory.  If you switch this option on you should also consider
setting the 'secure' option (see |initialization|).  Using a local
.exrc, .vimrc or .gvimrc is a potential security leak, use with care!
also see |.vimrc| and |gui-init|.

See http://damien.lespiau.name/blog/2009/03/18/per-project-vimrc/

For proper project support, there are several plugins have similar features. (which I don't use, so I can't recommend any).

If this is really a question of having different settings for different filetypes (rather than different locations on disk), then the correct thing to do is to put these files in ~/.vim/ftplugin. For example, this is the contents of my ~/.vim/ftplugin/haskell.vim:

setlocal autoindent
setlocal noexpandtab
setlocal tabstop=4
setlocal softtabstop=4
setlocal shiftwidth=4

To find out the right name for the script, simply open the kind of file you want to edit and use the :set ft? command (short for :set filetype?). Much more information is available via :help ftplugin.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!