diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-06-17 00:38:10 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-06-17 00:38:10 +1200 |
commit | 054fd12294d979b66ca757bd2e6a80138ce45ef1 (patch) | |
tree | 31bc3de29f425966139d9f6efcdf13f0f09660d1 /vim | |
parent | Update markdown_autoformat.vim (diff) | |
download | dotfiles-054fd12294d979b66ca757bd2e6a80138ce45ef1.tar.gz dotfiles-054fd12294d979b66ca757bd2e6a80138ce45ef1.zip |
Arrange for tidiers to hold window position
Diffstat (limited to 'vim')
-rw-r--r-- | vim/after/ftplugin/html/tidy.vim | 9 | ||||
-rw-r--r-- | vim/after/ftplugin/perl/tidy.vim | 9 |
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' |