Questions tagged [ftplugin]

ftplugin is the Vim editor's mechanism for running a set of commands based on the filetype of the file being edited (for instance, html, C, javascript, etc).

A file type plugin (ftplugin) is a script that is run automatically when Vim detects the type of file when the file is created or opened. The type can be detected from the file name (for example, file sample.c has file type c), or from the file contents.

Source: Vim The Editor: File type plugins

33 questions
48
votes
1 answer

Best way to organize filetype settings in .vim and .vimrc?

I'm going through my vim dotfiles to tidy them up. I've noticed that through time I've added various filetype specific settings in various inconsistent ways. Let's suppose I'm customizing for Python: au BufRead,BufNewFile *.py (do something). I…
dimatura
  • 1,230
  • 1
  • 11
  • 14
15
votes
5 answers

How to manually load an ftplugin after startup in Vim?

Say I load a .txt file into Vim. Then I want to change the filetype=html but I also want an associated ftplugin loaded. How can I do this? I've tried stuff like: :set filetype plugin on and :set filtype plugin_name on and also :filetype plugin_name…
Rob
  • 4,093
  • 5
  • 44
  • 54
13
votes
2 answers

How to edit HTML in Vim?

I'm new to Vim and I'm trying to get used to it. I just created a .vimrc file and got Vim to display line numbers and do incremental searching. I also enabled syntax highlighting. Now I want to enable things to make writing HTML easier. I searched…
mrm8
  • 155
  • 1
  • 1
  • 4
6
votes
1 answer

VIM - ftplugin doesn't seem to work

I'm using spf13's vim distribution https://github.com/spf13/spf13-vim. I have been trying to use 2 spaces instead of 4 spaces for .js files, for that reason I have created a js.vim in ~/.vim/ftplugin. Am I doing it wrong? js.vim set shiftwidth=2…
5
votes
6 answers

Disabling autocommenting for all filetypes

I turned on filetype plugin for some rails vim plugins I added, but a side effect of this seems to be that now autocommenting has been enabled in all filetypes (for instance, if I start a line with #, the next line, either by Enter in insert mode or…
Daniel Vandersluis
  • 91,582
  • 23
  • 169
  • 153
4
votes
3 answers

slimv not loading on *.lisp files in vim

I installed slimv.vim (first through yaourt on Archlinux and then through vimana) and via both methods, slimv.vim doesn't load when I open a lisp file. I've scoured google results for debugging help, and here's what I have checked so…
YakBarber
  • 51
  • 4
4
votes
2 answers

Vim ftplugin executes c.vim instead of cpp.vim for C++ files

I am learing Vim and I want have set it up as IDE by mapping F5 key to compilation command which is decided by the filetype. My ~/.vim/ftplugin/c.vim: map :w:!clang % -o %:r.out && ./%:r.out My ~/.vim/ftplugin/cpp.vim: map
Babken Vardanyan
  • 14,090
  • 13
  • 68
  • 87
3
votes
3 answers

Are plugins loaded by vimrc or afterwards?

I'm confused about the order in which Vim loads plugin files, and seem to be finding mixed answers online. Some answers seem to suggest that vimrc is loaded before plugins, while others suggest that they are loaded during the sourcing of vimrc, at…
Kvass
  • 8,294
  • 12
  • 65
  • 108
2
votes
1 answer

Neovim vim.opt:remove doesn't actually change the option

I came across some problem in my neovim settings, and something weird happens when I use vim.opt:remove to change the formatoptions. First, my default formatoptions is jcroql, because I run :verbose set formatoptions? and it returns: …
Gorun
  • 134
  • 6
2
votes
1 answer

How can I override configurations from the built-in ftplugins?

I would like to set commentstring for C files like so: autocmd FileType c setlocal commentstring=//\ %s But when I open a C file, I notice that setting has been overridden. I believe this line from /usr/share/nvim/runtime/ftplugin/c.vim is to…
Jack O'Connor
  • 10,068
  • 4
  • 48
  • 53
2
votes
1 answer

Where to put system-wide language-specific Vim ftplugin .vim files

I've put some language-agnostic baseline settings in /etc/vimrc, which serve as default for users unless a user overrides them. Where is the canonical system-wide place to put the respective {language}.vim files? On a per-user basis, I've always put…
Brad Solomon
  • 38,521
  • 31
  • 149
  • 235
2
votes
1 answer

ftplugin default configuration

I have found several topics that come close to matching my issue but, does not completely solve my problem. I have read about, and tried researching, the .vim/ftplugin/ and .vim/after/ftplugin/ methods of dealing with several filetypes and…
jrb
  • 23
  • 5
2
votes
1 answer

Open buffer with ftplugin file for current filetype?

I found no answers or questions to this after some Google searches, but hopefully somebody else might see the use for this aswell. I think it would be quite nice to have as you come up with new filetype specific iabbrevs as you are working. Then you…
hollaboi
  • 25
  • 5
2
votes
2 answers

Autocommand for new file of specific filetype

I want to run some vim commands anytime I create a new file of a specific file type, sort of combination of the BufNewFile and FileType autocommand events. I have BufNewFile autocommands setup in filetype.vim to set the filetype based on the file…
brianmearns
  • 9,581
  • 10
  • 52
  • 79
2
votes
3 answers

Pathogen ignoring ftplugin scripts

I'm trying to use Pathogen to manage Vim plugins. I had a couple of scripts I made in .vim/ftplugins. I installed Pathogen but now none of the scripts in ftplugins runs. I tried adding a directory inside .vim/bundle with the scripts but it didn't…
Facundo Casco
  • 10,065
  • 8
  • 42
  • 63
1
2 3