From e6bfb8f7065ded88ebc1af4dec865a715f33f03f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 3 Nov 2017 22:55:39 +1300 Subject: Use direct :write !cmd instead of shellescape() This is a much better method of calling external programs on the buffer's contents, not just because it avoids the mess of :execute evaluation but also because it doesn't require that there actually be a filename for the current buffer. This drastically simplifies the HTML tidy(1) call in particular. --- vim/ftplugin/html.vim | 7 +------ vim/ftplugin/perl.vim | 17 ++++++----------- 2 files changed, 7 insertions(+), 17 deletions(-) (limited to 'vim/ftplugin') diff --git a/vim/ftplugin/html.vim b/vim/ftplugin/html.vim index d705bd71..4d3991f3 100644 --- a/vim/ftplugin/html.vim +++ b/vim/ftplugin/html.vim @@ -1,10 +1,5 @@ " Run tidy -eq -utf8 on file for the current buffer -if exists('*shellescape') - function s:HTMLTidy() - execute '!tidy -eq -utf8 ' . shellescape(expand('%')) - endfunction - nnoremap v :execute :call HTMLTidy() -endif +nnoremap v :write !tidy -eq -utf8 " Make a bare URL into a link to itself function! s:UrlLink() diff --git a/vim/ftplugin/perl.vim b/vim/ftplugin/perl.vim index 310ffe7e..eeed2bb7 100644 --- a/vim/ftplugin/perl.vim +++ b/vim/ftplugin/perl.vim @@ -1,11 +1,6 @@ -" External commands for Perl files -if exists('*shellescape') - - " Run perl -c on file for the current buffer - nnoremap pc :execute "!perl -c " . shellescape(expand("%")) - " Run perlcritic on the file for the current buffer - nnoremap pl :execute "!perlcritic " . shellescape(expand("%")) - " Run the current buffer through perltidy - nnoremap pt :%!perltidy - -endif +" Run perl -c on file for the current buffer +nnoremap pc :write !perl -c +" Run perlcritic on the file for the current buffer +nnoremap pl :write !perlcritic +" Run the current buffer through perltidy +nnoremap pt :%!perltidy -- cgit v1.2.3