Skip to main content
14 votes
Accepted

Difference between adding "vim/after/ftplugin" vs "vim/ftplugin"

You are looking for :h ftplugin-overrule: If a global filetype plugin does not do exactly what you want, there are three ways to change this: 1. Add a few settings. You must create a new filetype ...
statox's user avatar
  • 50.6k
4 votes
Accepted

Cypher syntax file asks about commentstring on open

But then again, I don't even know what this message is trying to tell me in order for me to know where to fix it This line in ftplugin/cypher.vim is responsible for this: let b:undo_ftplugin = '...
Maxim Kim's user avatar
  • 13.9k
4 votes
Accepted

Neovim automatically run command when opening a filetype from ftplugin file

You don't need to use an autocmd or anything, because the scripts under ftplugin are already loaded by an autocmd triggered when the filetype is actually set. For example, for filetype markdown, the ...
filbranden's user avatar
  • 29.9k
3 votes
Accepted

How to properly set up ftplugin files for working with different filetypes in different windows?

The :set command sets both local and global option values. So after your ftplugin was applied it also affects all new buffers as "the new default". Therefore one normally does :setlocal and ...
Matt's user avatar
  • 21.7k
3 votes
Accepted

Open buffer without loading ftplugins

Most “core” filetype features are covered by autocommands, so disabling them will have the effect that you want. But we only want to disable them when opening a particular file, so :noautocmd edit {...
D. Ben Knoble's user avatar
  • 27.7k
3 votes
Accepted

Why are files in after/ftplugin/ run on every save, and can I work around it?

In the end, the comments above were very helpful in narrowing down the problem - thanks, everyone! I've resolved it now, and the filetype is only set once. To summarize, there were several issues here:...
Andrew Ferrier's user avatar
3 votes
Accepted

How can I make vim ignore a filetype plugin's makeprg setting?

Assuming that the plugin is using the standard scheme for filetype specific configuration... Probably the simplest way to override is by creating a file in $MYVIMDIR/after/ftplugin with filename that ...
B Layer's user avatar
  • 20.1k
2 votes
Accepted

Why do FileType autocommands not appear to work when using multiple filetypes?

It turns out, there is a subtle interaction between FileType events and the actual ftplugin mechanism. When the filetype is changed, all matching FileType events are run. As near as I can tell, this ...
D. Ben Knoble's user avatar
  • 27.7k
2 votes

ftdetect, ftplugin not working as advertised -- what am I missing?

Everything is "working as advertised". To expand on @Matt's answer… There are two ways to execute commands, set options, etc. for a given filetype. One is to use autocommands on the ...
romainl's user avatar
  • 42.3k
2 votes
Accepted

ftdetect, ftplugin not working as advertised -- what am I missing?

Do not prepend autocmd Set cindent option Do not set syntax option
Matt's user avatar
  • 21.7k
2 votes
Accepted

How to prevent Vim from loading a specific system-wide ftplugin?

Introduce systemd2 What you could do is selecting another filetype for systemd (e.g. systemd2) by having a ftdetect/systemd2.vim that set it. ~/vimfiles/ftdetect/systemd2.vim " Systemd unit files ...
Vivian De Smedt's user avatar
1 vote

How to test ftplugins?

As far as I'm concerned, filetype plugin indent on should appear in a .vimrc and nowhere else. Also I see an explicit loading of the plugin script. This is fishy. If your plugin isn't in the ...
Luc Hermitte's user avatar
  • 17.8k
1 vote
Accepted

Remaps to move across windows do not work when in netrw window

The reason is that the netrw buffer defines a buffer mapping for <C-h>. The solution is to override that buffer mapping: autocmd! FileType netrw nnoremap <buffer> <C-h> <C-w>h ...
Vivian De Smedt's user avatar
1 vote

What options shall be set for loading ftplugins?

Your question really boils down to: Why is my custom command :MyCommand working fine when I start Vim normally and not when I start Vim with -u NONE? A question that will be difficult to answer ...
romainl's user avatar
  • 42.3k
1 vote
Accepted

How do I position cursor according to filetype (gitcommit)?

Even though Vim saves the last known cursor position into viminfo file upon exit, it doesn't restore it by default. Instead, there is a piece of VimScript code at :h restore-cursor (also in defaults....
Matt's user avatar
  • 21.7k
1 vote

Setting variables in file in ftplugin directory

Filetype plugins are meant to set buffer local stuff. All your variables are global. IMO, It doesn't make sense to set, and reset, and reset them again and again every time you open a new C file. Even ...
Luc Hermitte's user avatar
  • 17.8k
1 vote
Accepted

Setting variables in file in ftplugin directory

The ftplugin intention is to replace the autocmd FileType calls. The corresponding file is executed after the filetype is set and before the corresponding distribution file is executed. It is not too ...
Vivian De Smedt's user avatar
1 vote

How to search standard library files in languages without include expressions?

Include search is done in the current and included files. If your language doesn't let you explicitly include a file, then all Vim can do is search in the current file, which makes using include ...
romainl's user avatar
  • 42.3k
1 vote

How to combine identical ftplugin files?

May be you could move that code into a plugin file and in the autocommand, you test for the existence of &ft key in your g:plugins_some_var global variable. If so, you call the function.
Luc Hermitte's user avatar
  • 17.8k
1 vote

Why is there an ftplugin directory for each plugin?

Context At the beginning there were only one ftplugin folder and siblings (e.g. ftdetect). All the plugins were sharing these folders. The consequences were that: Plugins installation lead to ...
Vivian De Smedt's user avatar
1 vote
Accepted

How can I make `.vim/after/ftplugin/markdown.vim` take effect immediately?

Your best option is probably to trigger the autocommands which are triggered when you set the filetype. To do so you can use :h :doautocmd with the event FileType: :doautocmd filetype For example: ...
statox's user avatar
  • 50.6k
1 vote

Open buffer without loading ftplugins

Remove the plugin. Seriously. "Huge and slow" = "trash bin". If you're brave enough then go and re-implement all required functionality yourself. Remove/rename/comment out ftdetect ...
Matt's user avatar
  • 21.7k
1 vote
Accepted

Execute normal command after opening email in Mutt

Interesting situation. Let's first address debugging it. It seems your experience with adding a normal iABCDE to the .vim/ftplugin/mail.vim and seeing it twice really suggests this file is being ...
filbranden's user avatar
  • 29.9k
1 vote

Where should I put filetype specific options for indentation?

When in doubt look into the standard Vim runtime files. ts sts et sw should be set by after/ftplugin. sta is basically no-op, as you have &sw == &sts anyway. si ai are basically no-op as you ...
Matt's user avatar
  • 21.7k
1 vote
Accepted

Highlight group in `.vim/after/ftplugin` not highlighting patterns

It is normal, you are not using the correct directory. See :h mysyntaxfile-add: If you are mostly satisfied with an existing syntax file, but would like to add a few items or change the highlighting, ...
statox's user avatar
  • 50.6k
1 vote
Accepted

Why won't vim source my ftplugin_after.vim file?

I have a file called ~/.config/nvim/after/ftplugin_after.vim The correct path you're looking for is actually: ~/.config/nvim/ftplugin/filetype.vim Note that ftplugin needs to be a directory, and ...
filbranden's user avatar
  • 29.9k
1 vote
Accepted

Buffer opened when compiling succeeds

So what opens this additional buffer is your command exe ":botright copen", :h :copen is used to open the quickfix window. As you use it no matter how the compilation went, when the ...
statox's user avatar
  • 50.6k
1 vote

pluging value to override vimrc

I'm sorry I don't understand the specifics of your question. At best I guess you want to cache the previous user choice, that could have been done in the ftplugin or the user .vimrc. get(g:, 'varname',...
Luc Hermitte's user avatar
  • 17.8k

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