Can you have file type-specific key bindings in Vim?

后端 未结 6 1661
攒了一身酷
攒了一身酷 2020-12-04 10:54

In my .vimrc file, I have a key binding for commenting out that inserts double slashes (//) at the start of a line:

" the mappi         


        
6条回答
  •  没有蜡笔的小新
    2020-12-04 11:37

    The ftdetect folder is for scripts of filetype detection. Filetype plugins must be inside the ftplugin folder. The filetype must be included in the file name in one of the following three forms:

    • .../ftplugin/.vim
    • .../ftplugin/_foo.vim
    • .../ftplugin//foo.vim

    For instance, you can map comments for the cpp filetype putting the following inside the .../ftplugin/cpp_mine.vim:

    :map   :s/^/\/\//
    :map   :s/\/\/// 
    

提交回复
热议问题