Search code examples
perlvimperl-tidy

How to enable map command in vim?


How to enable map command only when filetype is 'perl'?

something like:

if(&ft=='perl')
  map ,pt <ESC>:%! perltidy<CR>
endif

but it doesn't work.


Solution

  • I found the shorter way.

    Add this line to your ~/.vimrc

    au FileType perl nnoremap <buffer> _t <ESC>:%! perltidy<CR>