I want to make a filetype plugin(in fact asm) of vim. After Searching for a while on the Internet, i found that i should add a asm.vim in ~/.vim/ftplugin folder. So I added that new file asm.vim in that folder and wrote the following codes:
map <F7> oTest<CR><Esc>
a very simple vim script, only output the Test string in the next line. but i failed, when i opened an xxx.asm file and pressed <F7> button, nothing happened. Anything wrong with the code? any help appreciated!
You need to ensure that Vim actually detects the filetype; asm is defined in $VIMRUNTIME/filetype.vim, and there is a syntax, but no filetype plugin yet. Check that
:set filetype?
outputs asm. If not, you need to work on the detection.
You also need to have :filetype plugin on (in your ~/.vimrc); otherwise, no filetype plugin scripts aren't loaded. Check with :scriptnames.
Also note that you should not define global mappings or commands in a filetype plugin. Use :noremap <buffer> <F7> ....
You can check your mapping exists with :verbose map <F7>.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With