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 that the *.vim
file inside it must be named after the filetype of the files you would like to match.
The ftplugin
scripts must always match a specific filetype, you can't really create a script in that directory to apply to all files you edit, regardless of filetype...
The culprit was /usr/share/nvim/runtime/ftplugin/
Yes, but which script inside ftplugin/
? The scripts on that directory will only be loaded based on the filetype of the buffer you're currently editing.
You can use the command :set ft?
to find which filetype is set to the current buffer, so you can use it in your ftplugin/
override.
which contains set incsearch ignorecase smartcase number relativenumber autoindent shiftwidth=8 tabstop=8 softtabstop=8 expandtab showbreak=¶ notimeout
. I am mainly concerned about the tabstop.
Note that you should typically use setlocal
instead of set
in an ftplugin
script. Since it's loaded for each buffer, based on the filetype, you'll want to make sure you only define buffer-local settings and mappings, so that they only affect buffers of that specific filetype and not others.
(One final subtlety of ftplugin
scripts is that you might want to define a b:undo_ftplugin
variable, with commands that can be used to undo its actions. This is used if you ever change filetypes of a buffer, in which case Vim will be able to undo the changes from the previous filetype before applying the ones for the next filetype.)