The cpp ftplugin that comes with vim has the following line:
runtime! ftplugin/c.vim ftplugin/c_*.vim ftplugin/c/*.vim
Which means it is going to source the ~/.vim/ftplugin/c.vim
.
A way to overcome this is to put your mappings in ~/.vim/after/ftplugin/cpp.vim
and ~/.vim/after/ftplugin/c.vim
files.
But your problems don't stop there:
- You are using
:map
where you probably want to at least supply a mode.nmap
- You also should probably be using
noremap
so it would becomennoremap
- Your mapping is global so it will stomp over your
<f5>
everytime you open acpp
and switch to ac
file. You should make it local to the specific buffer.nnoremap <buffer>
- You should probably also be setting
makeprg
accordingly so you can take advantage of:make
and the quickfix list. e.g.setlocal makprg clang\ %\ -o\ %:r.out
For more help see:
:h :map
:h :map-local
:h 'makeprg'
:h :make
:h quickfix