Using VIM (MacVim to be specific) I've been trying to add a number of shortcuts to my .vimrc file that have different syntax in different languages.
I'm using autocmd to add different keymappings depending on the filetype, but the javascript and perl filetypes .js and .pl don't get the mappings.
My attempt to have a / comment out a visually selected block (and ? to uncomment it):
autocmd FileType php,js,java,cpp vnoremap <buffer> / :s/^/\/\/ /<cr>gv
autocmd FileType php,js,java,cpp vnoremap <buffer> ? :s/^\s*\/\/ \?//<cr>gv
autocmd FileType sql vnoremap <buffer> / :s/^/-- /<cr>gv
autocmd FileType sql vnoremap <buffer> ? :s/^--\s\?//<cr>gv
autocmd FileType pl vnoremap <buffer> / :s/^/## /<cr>gv
autocmd FileType pl vnoremap <buffer> ? :s/^\s*##\s\?//<cr>gv
This works for the php, java, cpp and sql files, but not for pl and js files.