Skip to content

Commit 30c7943

Browse files
committed
Implement PR vim-utils#44 and Pr vim-utils#31
1 parent cfdc78f commit 30c7943

File tree

3 files changed

+40
-24
lines changed

3 files changed

+40
-24
lines changed

doc/man.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ Default man command is '/usr/bin/man', but it can be changed:
116116
>
117117
let g:vim_man_cmd = 'LANG=ja_JP.UTF-8 /usr/bin/man'
118118
<
119+
120+
121+
man_split_type *g:man_split_type*
122+
Change the default split type when using |:Man|. Valid values are
123+
'horizontal', 'vertical', or 'tab'
124+
125+
>
126+
let g:man_split_type = 'horizontal'
127+
<
128+
119129
CONTRIBUTING *man-contributing* *man-bugs*
120130

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

ftplugin/man.vim

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,30 @@ setlocal noswapfile
3232
" }}}
3333
" mappings {{{1
3434

35-
nnoremap <silent> <buffer> K :call man#get_page_from_cword('horizontal', v:count)<CR>
36-
" all tag mappings are defined for completeness and they all perform the same action
37-
nnoremap <silent> <buffer> <C-]> :call man#get_page_from_cword('horizontal', v:count)<CR>
38-
nnoremap <silent> <buffer> g<C-]> :call man#get_page_from_cword('horizontal', v:count)<CR>
39-
nnoremap <silent> <buffer> g] :call man#get_page_from_cword('horizontal', v:count)<CR>
40-
nnoremap <silent> <buffer> <C-W>] :call man#get_page_from_cword('horizontal', v:count)<CR>
41-
nnoremap <silent> <buffer> <C-W><C-]> :call man#get_page_from_cword('horizontal', v:count)<CR>
42-
nnoremap <silent> <buffer> <C-W>g<C-]> :call man#get_page_from_cword('horizontal', v:count)<CR>
43-
nnoremap <silent> <buffer> <C-W>g] :call man#get_page_from_cword('horizontal', v:count)<CR>
44-
nnoremap <silent> <buffer> <C-W>} :call man#get_page_from_cword('horizontal', v:count)<CR>
45-
nnoremap <silent> <buffer> <C-W>g} :call man#get_page_from_cword('horizontal', v:count)<CR>
46-
47-
nnoremap <silent> <buffer> <C-T> :call man#pop_page()<CR>
48-
49-
nnoremap <silent> <buffer> [[ :<C-U>call man#section#move('b', 'n', v:count1)<CR>
50-
nnoremap <silent> <buffer> ]] :<C-U>call man#section#move('' , 'n', v:count1)<CR>
51-
xnoremap <silent> <buffer> [[ :<C-U>call man#section#move('b', 'v', v:count1)<CR>
52-
xnoremap <silent> <buffer> ]] :<C-U>call man#section#move('' , 'v', v:count1)<CR>
53-
54-
nnoremap <silent> <buffer> q :q<CR>
55-
nnoremap <buffer> g/ /^\s*\zs
35+
if !exists('g:no_plugin_maps') && !exists('g:no_man_maps')
36+
nnoremap <silent> <buffer> K :call man#get_page_from_cword('horizontal', v:count)<CR>
37+
" all tag mappings are defined for completeness and they all perform the same action
38+
nnoremap <silent> <buffer> <C-]> :call man#get_page_from_cword('horizontal', v:count)<CR>
39+
nnoremap <silent> <buffer> g<C-]> :call man#get_page_from_cword('horizontal', v:count)<CR>
40+
nnoremap <silent> <buffer> g] :call man#get_page_from_cword('horizontal', v:count)<CR>
41+
nnoremap <silent> <buffer> <C-W>] :call man#get_page_from_cword('horizontal', v:count)<CR>
42+
nnoremap <silent> <buffer> <C-W><C-]> :call man#get_page_from_cword('horizontal', v:count)<CR>
43+
nnoremap <silent> <buffer> <C-W>g<C-]> :call man#get_page_from_cword('horizontal', v:count)<CR>
44+
nnoremap <silent> <buffer> <C-W>g] :call man#get_page_from_cword('horizontal', v:count)<CR>
45+
nnoremap <silent> <buffer> <C-W>} :call man#get_page_from_cword('horizontal', v:count)<CR>
46+
nnoremap <silent> <buffer> <C-W>g} :call man#get_page_from_cword('horizontal', v:count)<CR>
47+
48+
nnoremap <silent> <buffer> <C-T> :call man#pop_page()<CR>
49+
50+
nnoremap <silent> <buffer> [[ :<C-U>call man#section#move('b', 'n', v:count1)<CR>
51+
nnoremap <silent> <buffer> ]] :<C-U>call man#section#move('' , 'n', v:count1)<CR>
52+
xnoremap <silent> <buffer> [[ :<C-U>call man#section#move('b', 'v', v:count1)<CR>
53+
xnoremap <silent> <buffer> ]] :<C-U>call man#section#move('' , 'v', v:count1)<CR>
54+
55+
nnoremap <silent> <buffer> q :q<CR>
56+
nnoremap <silent> <buffer> <esc> :q<CR>
57+
nnoremap <buffer> g/ /^\s*\zs
58+
endif
5659

5760
" }}}
5861

plugin/man.vim

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@ if !exists('g:vim_man_cmd')
1010
let g:vim_man_cmd='/usr/bin/man'
1111
endif
1212

13-
command! -nargs=* -bar -complete=customlist,man#completion#run Man call man#get_page('horizontal', <f-args>)
13+
if !exists('g:man_split_type')
14+
let g:man_split_type = 'horizontal'
15+
endif
16+
17+
command! -nargs=* -bar -complete=customlist,man#completion#run Man call man#get_page(g:man_split_type, <f-args>)
1418
command! -nargs=* -bar -complete=customlist,man#completion#run Sman call man#get_page('horizontal', <f-args>)
1519
command! -nargs=* -bar -complete=customlist,man#completion#run Vman call man#get_page('vertical', <f-args>)
1620
command! -nargs=* -bar -complete=customlist,man#completion#run Tman call man#get_page('tab', <f-args>)
1721

1822
command! -nargs=+ -bang Mangrep call man#grep#run(<bang>0, <f-args>)
1923

2024
" map a key to open a manpage for word under cursor, example: map ,k <Plug>(Man)
21-
nnoremap <silent> <Plug>(Man) :<C-U>call man#get_page_from_cword('horizontal', v:count)<CR>
25+
nnoremap <silent> <Plug>(Man) :<C-U>call man#get_page_from_cword(g:man_split_type, v:count)<CR>
2226
nnoremap <silent> <Plug>(Sman) :<C-U>call man#get_page_from_cword('horizontal', v:count)<CR>
2327
nnoremap <silent> <Plug>(Vman) :<C-U>call man#get_page_from_cword('vertical', v:count)<CR>
24-
nnoremap <silent> <Plug>(Tman) :<C-U>call man#get_page_from_cword('tab', v:count)<CR>
2528
2629
let &cpo = s:save_cpo
2730
unlet s:save_cpo

0 commit comments

Comments
 (0)