vim: would like it to turn settings on only for certain file types

后端 未结 3 1346
既然无缘
既然无缘 2021-02-18 15:52

I\'ve looked at this but it wasn\'t too much help. Maybe I didn\'t read it too well.

Basically what I want is when I open a .txt file the settings:

set          


        
3条回答
  •  孤城傲影
    2021-02-18 16:28

    A good solution to this is the "after" directory. You can add an rc file for anything you want in there, syntax highlighting, file types, etc. These configurations are run after all other configurations are run, so after the system configs and after your .vimrc. So you can create, on a unix type system, an file called ~/.vim/after/ftplugin/text.vim and add the two lines you want in there. They options will be set for the text file type, but not for other file types. You can have different files in each of those directories for other filetypes, such as perl.vim.

    Since you are not in a unix environment, you will need to find your [runtime directory][1] by checking the [runtimepath][2] option. You would create your "after" directory and the files there.

    NOTE:

    The links are not working for me, probable because of the anchors:

    • After directories are briefly mentioned here: http://www.vim.org/htmldoc/usr_43.html#43.2
    • Runtime directories: http://www.vim.org/htmldoc/usr_43.html#your-runtime-dir
    • Runtime path: http://www.vim.org/htmldoc/options.html#'runtimepath'

提交回复
热议问题