diff --git a/.vim/ftplugin/man.vim b/.vim/ftplugin/man.vim index a58d297..28b7e24 100644 --- a/.vim/ftplugin/man.vim +++ b/.vim/ftplugin/man.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: man -" Maintainer: Nam SungHyun -" Last Change: 2007 Nov 30 +" Maintainer: SungHyun Nam +" Last Change: 2014 Dec 29 " To make the ":Man" command available before editing a manual page, source " this script from your startup vimrc file. @@ -15,6 +15,12 @@ if &filetype == "man" endif let b:did_ftplugin = 1 + " Ensure Vim is not recursively invoked (man-db does this) + " when doing ctrl-[ on a man page reference. + if exists("$MANPAGER") + let $MANPAGER = "" + endif + " allow dot and dash in manual page name. setlocal iskeyword+=\.,- @@ -29,6 +35,8 @@ if &filetype == "man" nnoremap :call PopPage() endif + let b:undo_ftplugin = "setlocal iskeyword<" + endif if exists(":Man") != 2 @@ -55,7 +63,9 @@ endtry func PreGetPage(cnt) if a:cnt == 0 let old_isk = &iskeyword - setl iskeyword+=(,) + if &ft == 'man' + setl iskeyword+=(,) + endif let str = expand("") let &l:iskeyword = old_isk let page = substitute(str, '(*\(\k\+\).*', '\1', '') @@ -143,16 +153,16 @@ func GetPage(...) " Avoid warning for editing the dummy file twice setl buftype=nofile noswapfile - setl ma + setl ma nonu nornu nofen silent exec "norm 1GdG" let $MANWIDTH = winwidth(0) silent exec "r!/usr/bin/man ".s:GetCmdArg(sect, page)." | col -b" " Remove blank lines from top and bottom. while getline(1) =~ '^\s*$' - silent norm ggdd + silent keepj norm ggdd endwhile while getline('$') =~ '^\s*$' - silent norm Gdd + silent keepj norm Gdd endwhile 1 setl ft=man nomod