Skip to content

Commit 21ae737

Browse files
Ben JohnsonBruno Sutic
authored andcommitted
Add g:vim_man_cmd to change default man command
Closes #24, closes #32
1 parent 308bece commit 21ae737

File tree

6 files changed

+13
-4
lines changed

6 files changed

+13
-4
lines changed

autoload/man.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function! s:manpage_exists(sect, page)
4444
return 0
4545
endif
4646
let find_arg = man#helpers#find_arg()
47-
let where = system('/usr/bin/man '.find_arg.' '.man#helpers#get_cmd_arg(a:sect, a:page))
47+
let where = system(g:vim_man_cmd.' '.find_arg.' '.man#helpers#get_cmd_arg(a:sect, a:page))
4848
if where !~# '^\s*/'
4949
" result does not look like a file path
5050
return 0

autoload/man/grep.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function! man#grep#command(path_glob, insensitive_flag, pattern)
126126
" xargs is used to feed manpages one-by-one
127127
let command .= 'xargs -I{} -n1 sh -c "manpage={};'
128128
" inner variables execute within a shell started by xargs
129-
let command .= '/usr/bin/man \$manpage 2>/dev/null|col -b|'
129+
let command .= g:vim_man_cmd.' \$manpage 2>/dev/null|col -b|'
130130
" if the first manpage line is blank, remove it (stupid semicolons are required)
131131
let command .= "sed '1 {;/^\s*$/d;}'|"
132132
let command .= 'grep '.a:insensitive_flag.' -nE '.a:pattern.'|'

autoload/man/grep/vanilla.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function! man#grep#vanilla#run(bang, insensitive, pattern, files)
1515
let $MANWIDTH = man#helpers#manwidth()
1616
let insensitive_flag = a:insensitive ? '-i' : ''
1717
for file in a:files
18-
let output_manfile = '/usr/bin/man '.file.' | col -b |'
18+
let output_manfile = g:vim_man_cmd.' '.file.' | col -b |'
1919
let trim_whitespace = "sed '1 {; /^\s*$/d; }' |"
2020
let grep = 'grep '.insensitive_flag.' -n -E '.a:pattern
2121
let matches = systemlist(output_manfile . trim_whitespace . grep)

autoload/man/helpers.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function! man#helpers#load_manpage_text(page, section)
6969
setlocal modifiable
7070
silent keepj norm! 1GdG
7171
let $MANWIDTH = man#helpers#manwidth()
72-
silent exec 'r!/usr/bin/man '.man#helpers#get_cmd_arg(a:section, a:page). ' 2>/dev/null | col -b'
72+
silent exec 'r!'.g:vim_man_cmd.' '.man#helpers#get_cmd_arg(a:section, a:page). ' 2>/dev/null | col -b'
7373
call s:remove_blank_lines_from_top_and_bottom()
7474
setlocal filetype=man
7575
setlocal nomodifiable

doc/man.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ in your |vimrc|:
110110
>
111111
map <leader>v <Plug>(Vman)
112112
<
113+
OPTIONS *man-options*
113114

115+
Default man command is '/usr/bin/man', but it can be changed:
116+
>
117+
let g:vim_man_cmd = 'LANG=ja_JP.UTF-8 /usr/bin/man'
118+
<
114119
CONTRIBUTING *man-contributing* *man-bugs*
115120

116121
Contributing and bug fixes are welcome. If you have an idea for a new feature

plugin/man.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ let g:loaded_man = 1
66
let s:save_cpo = &cpo
77
set cpo&vim
88

9+
if !exists('g:vim_man_cmd')
10+
let g:vim_man_cmd='/usr/bin/man'
11+
endif
12+
913
command! -nargs=* -bar -complete=customlist,man#completion#run Man call man#get_page('horizontal', <f-args>)
1014
command! -nargs=* -bar -complete=customlist,man#completion#run Sman call man#get_page('horizontal', <f-args>)
1115
command! -nargs=* -bar -complete=customlist,man#completion#run Vman call man#get_page('vertical', <f-args>)

0 commit comments

Comments
 (0)