aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vim/after/ftplugin/html/tidy.vim9
-rw-r--r--vim/after/ftplugin/perl/tidy.vim9
2 files changed, 16 insertions, 2 deletions
diff --git a/vim/after/ftplugin/html/tidy.vim b/vim/after/ftplugin/html/tidy.vim
index e0c43f01..5a8ded7e 100644
--- a/vim/after/ftplugin/html/tidy.vim
+++ b/vim/after/ftplugin/html/tidy.vim
@@ -20,6 +20,13 @@ let b:did_ftplugin_html_tidy = 1
let b:undo_ftplugin = b:undo_ftplugin
\ . '|unlet b:did_ftplugin_html_tidy'
+" Plugin function
+function s:HtmlTidy()
+ let l:view = winsaveview()
+ %!tidy -quiet
+ call winrestview(l:view)
+endfunction
+
" Stop here if the user doesn't want ftplugin mappings
if exists('g:no_plugin_maps') || exists('g:no_html_maps')
finish
@@ -28,7 +35,7 @@ endif
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>HtmlTidy
- \ :<C-U>%!tidy -quiet<CR>
+ \ :<C-U>call <SID>HtmlTidy()<CR>
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>HtmlTidy'
diff --git a/vim/after/ftplugin/perl/tidy.vim b/vim/after/ftplugin/perl/tidy.vim
index 01ca0210..f6744f3a 100644
--- a/vim/after/ftplugin/perl/tidy.vim
+++ b/vim/after/ftplugin/perl/tidy.vim
@@ -15,6 +15,13 @@ let b:did_ftplugin_perl_tidy = 1
let b:undo_ftplugin = b:undo_ftplugin
\ . '|unlet b:did_ftplugin_perl_tidy'
+" Plugin function
+function s:PerlTidy()
+ let l:view = winsaveview()
+ %!perltidy
+ call winrestview(l:view)
+endfunction
+
" Stop here if the user doesn't want ftplugin mappings
if exists('g:no_plugin_maps') || exists('g:no_perl_maps')
finish
@@ -23,7 +30,7 @@ endif
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>PerlTidy
- \ :<C-U>%!perltidy<CR>
+ \ :<C-U>call <SID>PerlTidy()<CR>
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>PerlTidy'