0
Is there a way to bind a key by document type?
For example, if the document is a .tex file, I want f5 to call PdfLatex
, but it is a .c file, I want it to call make
0
Is there a way to bind a key by document type?
For example, if the document is a .tex file, I want f5 to call PdfLatex
, but it is a .c file, I want it to call make
1
You can use the <buffer>
option to the map
command to specify that a mapping be used only in the current buffer, then apply that mapping only in buffers of a particular file type using an autocommand, like this.
au FileType tex map <buffer> <F5> :PdfLatex<CR>
au FileType c map <buffer> <F5> :make<CR>
For more, see
:help map-<buffer>
:help autocmd.txt