in my project I have different kinds of files. For every filetype I created a ~/.vim/syntax/[type].vim file for e.g. highlighting and key mappings. In every filetype I have a footer line with

 # vim:syn=[type]

Now I switch from VIM 7.3.547 to 8.0.707. When I now open a file vim shows me on startup all key mappings I defined in the syntax file.

map <silent> <C-F>    :!/home/www-data/.vim/syntax/layout-formater.pl<CR>
Press ENTER or type command to continue

Then I have to press the Enter key before I can edit the file. It shows only the mappings, not the highlight definition or other thing I defined in the syntax file. And only the mappings from the syntax file, not the mappings in my ~/.vimrc file.

Does anyone know, how I can avoid this?

Thanks for any help!

  • Can you give an example of one your syntax files? Also, syntax files are meant to be exclusively for highlighting; local maps, options, etc are meant to be placed in ftplugins (i typically use after/ftplugin). You may also find with your upgrade that you don’t need some of your syntax files, as vim comes with many
    – D. Ben Knoble
    Commented Jun 25, 2019 at 12:38

1 Answer 1


You could avoid this by using the right files: :h ftplugin

*41.12* Writing a filetype plugin   *write-filetype-plugin* *ftplugin*

A filetype plugin is like a global plugin, except that it sets options and
defines mappings for the current buffer only.  See |add-filetype-plugin| for
how this type of plugin is used.

So keep your command related to syntax in your syntax file and your mappings to your ftplugin ~/.vim/after/ftplugin/[type].vim.

Also if I understand your mapping properly you probably want to read :h 'formatprg' or :h 'equalprg', it's always better to use the built-in mechanisms to do this kind of things. And you also should not use map: Always use the non recursive version noremap and specify the mode nnoremap (unless you know what you are doing) it might save you a lot of debugging in the futur.

  • Thank you for your answer! That was the right approach to the solution. But my vim won't read the filetype plugins in ~/.vim/after/ftplugin. It needs the directory ~/.vim/after/plugin or ~/.vim/plugin. But now it works perfect. Thanks again!
    – irata73
    Commented Jun 27, 2019 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.