4

I code mainly in 2 languages python and HTML. I currently have the indenting configured for python in my neovim configuration file but I would to know how to make neovim auto-detect the type of file and change the indenting script for that specific type of language...in this case HTML. Any help would be greatly appreciated!

1
  • Apparently I need to create a question/answer pair we can use for dupes; see this or this for starters, and understand the tab settings (theres a vimcast on it...) to set what you want.
    – D. Ben Knoble
    Commented Feb 25, 2018 at 9:39

1 Answer 1

2

Here is an example from the faq

You can create filetype plugins to set different options for different types of files. You should first enable filetype plugins using the command:

  :filetype plugin on

A filetype plugin is a vim script that is loaded whenever Vim opens or creates a file of that type. For example, to ensure that the 'textwidth' option is set to 80 when editing a C program (filetype 'c'), create one of the following files:

          ~/.vim/ftplugin/c.vim (Unix)
          %HOME%\vimfiles\ftplugin\c.vim (Windows)

with the following text in it:

          setlocal textwidth=80

You can also use autocommands to set specific options when editing specific type of files. For example, to set the 'textwidth' option to 75 for only *.txt files, you can use the following autocmd:

  autocmd BufRead *.txt setlocal textwidth=80

For more information, read

:help filetype-plugin

:help add-filetype-plugin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.