Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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