From af0ca25ba9a87bdaa5e854a09094afc97ff964ef Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 23 Sep 2015 04:11:04 -0400 Subject: [PATCH 1/2] man.vim: avoid creating extra blank buffers. --- runtime/autoload/man.vim | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index cfd0d35a71..d481d9eaf0 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -48,8 +48,9 @@ function man#get_page(...) abort exec 'let s:man_tag_col_'.s:man_tag_depth.' = '.col('.') let s:man_tag_depth = s:man_tag_depth + 1 - " Use an existing "man" window if it exists, otherwise open a new one. - if !invoked_from_man + let editcmd = 'edit' + " Use an existing 'man' window, else open a new one. + if &filetype !=# 'man' let thiswin = winnr() wincmd b if winnr() > 1 @@ -64,13 +65,13 @@ function man#get_page(...) abort endif endwhile endif - if !invoked_from_man - tabnew - let invoked_from_man = 1 + + if &filetype !=# 'man' + let editcmd = 'tabnew' endif endif - silent exec 'edit man://'.page.(empty(sect)?'':'('.sect.')') + silent exec editcmd.' man://'.page.(empty(sect)?'':'('.sect.')') setlocal modifiable silent keepjumps norm! 1G"_dG @@ -86,7 +87,7 @@ function man#get_page(...) abort setlocal nomodified setlocal filetype=man - if invoked_from_man + if invoked_from_man || editcmd ==# 'tabnew' call s:set_window_local_options() endif endfunction From 399864dc28498496bb82cdeb7b4aeae935cd667d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 25 Sep 2015 21:49:44 -0400 Subject: [PATCH 2/2] man.vim: Prevent sourcing in startup. It is common practice for Vim users to :runtime! ftplugin/man.vim in order to get the :Man command. That will cause weird settings for non-man files. --- runtime/ftplugin/man.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runtime/ftplugin/man.vim b/runtime/ftplugin/man.vim index 38b55e6a83..133a28e626 100644 --- a/runtime/ftplugin/man.vim +++ b/runtime/ftplugin/man.vim @@ -2,6 +2,10 @@ " Language: man " Maintainer: SungHyun Nam +if has('vim_starting') && &filetype !=# 'man' + finish +endif + " Only do this when not done yet for this buffer if exists('b:did_ftplugin') finish