Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How do I set the filetype option for files with names matching a particular pattern or depending on the file extension?

0
Posted

How do I set the filetype option for files with names matching a particular pattern or depending on the file extension?

0

‘filetype’ option for files with names matching a particular pattern using an autocmd. For example, to set the ‘filetype’ option to ‘c’ for all files with extension ‘.x’, you can use the following autocmd: autocmd! BufRead,BufNewFile *.x setfiletype c A better alternative to the above approach is to create a filetype.vim file in the ~/.vim directory (or in one of the directories specified in the ‘runtimepath’ option) and add the following lines: ” my filetype file if exists(“did_load_filetypes”) finish endif augroup filetypedetect au! BufRead,BufNewFile *.x setfiletype c augroup END For more information, read :help new-filetype :help 43.2 :help :setfiletype ============================================================================= SECTION 27 – EDITING PROGRAM FILES 27.1. How do I enable automatic indentation for C/C++ files? You can enable file-type based indentation using: :filetype indent on If you want to only enable automatic C indentation, then use: :set cindent For more inform

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123