vimcode-snippetsftplugin

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 can quickly add it to your filetype.vim-file in the ftplugin directory without having to start looking at filetypes and spending time pulling up the correct ftplugin file.

I am not that good at customizing vim yet, but if someone can give some pointers that would be cool.


Solution

  • If I understood it correctly, you want a way to edit the corresponding ftplugin to the buffer you're working on. You can get the filetype with the expression &filetype, so one way to do it is to get this in a command with controlR and = (insert from the expression register, see help files for c_CTRL-R)

    :e ~/.vim/ftplugin/<C-R>=&filetype<CR>.vim<CR>
    

    This can be easily converted into a map to be placed in your .vimrc:

    nnoremap <leader>ef :e ~/.vim/ftplugin/<C-R>=&filetype<CR>.vim<CR>
    

    Or a command:

    com! EditFTPlugin exe 'e ~/.vim/ftplugin/' . &filetype . '.vim'