[vim]update man ftplugin

This commit is contained in:
Mathieu Maret 2015-07-07 14:19:34 +02:00
parent 299de4078f
commit 063c081b25
1 changed files with 16 additions and 6 deletions

View File

@ -1,7 +1,7 @@
" Vim filetype plugin file
" Language: man
" Maintainer: Nam SungHyun <namsh@kldp.org>
" Last Change: 2007 Nov 30
" Maintainer: SungHyun Nam <goweol@gmail.com>
" 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 <buffer> <c-t> :call <SID>PopPage()<CR>
endif
let b:undo_ftplugin = "setlocal iskeyword<"
endif
if exists(":Man") != 2
@ -55,7 +63,9 @@ endtry
func <SID>PreGetPage(cnt)
if a:cnt == 0
let old_isk = &iskeyword
setl iskeyword+=(,)
if &ft == 'man'
setl iskeyword+=(,)
endif
let str = expand("<cword>")
let &l:iskeyword = old_isk
let page = substitute(str, '(*\(\k\+\).*', '\1', '')
@ -143,16 +153,16 @@ func <SID>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