5

Does something like this exist? In Vim this is called an autocommand. The relevant help topic can be found by typing :h autocommand (sic!) An example code to put into vimrc: augroup typescript_save | au! autocmd BufWritePost *.ts !tsc <afile>:p:S augroup end


3

You can use multiple filetype names separated with . # in your personal filetype.vim augroup filetypedetect au! BufRead,BufNewFile *.usenet setfiletype mail.usenet augroup END All mail filetype plugins and syntax files will be applied before usenet filetype plugins and syntax files. All mail related stuff (abbreviations, snippets, balabalas) should work ...


3

To enable filetype detection, add the following command to your vimrc: filetype on Then, for each filetype you want settings for, create a Vimscript file in the following location: ~/.vim/after/ftplugin/ Name the file with the filetype you want it to apply to, so for e.g. a Python settings file, create: ~/.vim/after/ftplugin/python.vim For more details,...


3

As discussed in the comments, this behaviour is caused by cindent. You can check what's setting this with the command: :verbose set cindent?


2

What you are missing is the (highly subjective) organization. Ideally each of the lines would be in separate files, which makes debugging easier and helps you to group things together. In other words, do you immediately know what filetypes you overrule by looking at the name ftdetect/mine.vim? What about ftdetect/vim_test.vim and ftdetect/h_test.vim? As ...


2

First as a general advice, :h :verbose is a good way to debug stuff with Vim: *:verb* *:verbose* :[count]verb[ose] {command} Execute {command} with 'verbose' set to [count]. If [count] is omitted one is used. ":0verbose" can be used to set 'verbose' to zero. So using :verbose set ft? in the ...


2

Create a syntax/usenet.vim with the contents: " Quit when a syntax file was already loaded if exists("b:current_syntax") finish endif runtime! syntax/mail.vim let b:current_syntax = "usenet" In short, just source the file you want to inherit syntax from. If you want any customizations for usenet, just make them after you've sourced syntax/mail.vim.


2

Add to ~/.vim/ftdetect/sage.vim (create if not present): au BufNewFile,BufRead *.sage setfiletype python cf. Learn Vimscript the Hard Way, which directs to appropriate help pages.


2

Vim 8.1.2250 does not ship with filetype detection for solidity. (One can confirm with :edit $VIMRUNTIME/filetype.vim and then :global /sol/.) ALE has Solidity linters, but they require the filetype to be set. The simplest solution is to create ~/.vim/ftdetect/solidity.vim and add au BufNewFile,BufRead *.sol setfiletype solidity However, this plugin ...


2

Change your FileType autocommand to autocmd Filetype txt ++nested colorscheme NiceTheme to allow for nesting (by default, they do not nest). See :h autocmd-nested (and thanks to Matt for the tip).


1

The fact that you are getting this message on your verbose log file is expected. The Vim source code has an explicit comment about that: /* * When using ":silent! cmd" ignore error messages. * But do write it to the redirection file. */ I linked to the code in Vim 7.4, but Vim 8.2 still has the same exact snippet and exhibits the same behavior. I ...


1

To avoid false positives with a pattern like *markdown*, use * and then filter in the code that you run from the autocmd: autocmd FileType * call s:CheckMarkdown() function s:CheckMarkdown() if match(&filetype, '\v<markdown>') != -1 return endif " ... run your desired side-effects endfunction


Only top voted, non community-wiki answers of a minimum length are eligible