annotate runtime/ftplugin/man.vim @ 13619:41ed86454233

Added tag v8.0.1681 for changeset ea4f2a8040b4ab7111c02c71aa587e2ac121aa6b
author Christian Brabandt <cb@256bit.org>
date Tue, 10 Apr 2018 12:45:07 +0200
parents 371ceeebbdaa
children e751b5c9dff3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim filetype plugin file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: man
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1623
diff changeset
3 " Maintainer: SungHyun Nam <goweol@gmail.com>
13125
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
4 " Last Change: 2018 Jan 15
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " To make the ":Man" command available before editing a manual page, source
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " this script from your startup vimrc file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " If 'filetype' isn't "man", we must have been called to only define ":Man".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 if &filetype == "man"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 " Only do this when not done yet for this buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 if exists("b:did_ftplugin")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 let b:did_ftplugin = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 " allow dot and dash in manual page name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 setlocal iskeyword+=\.,-
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 " Add mappings, unless the user didn't want this.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 if !exists("no_plugin_maps") && !exists("no_man_maps")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 if !hasmapto('<Plug>ManBS')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 nmap <buffer> <LocalLeader>h <Plug>ManBS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 endif
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 7
diff changeset
26 nnoremap <buffer> <Plug>ManBS :%s/.\b//g<CR>:setl nomod<CR>''
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 nnoremap <buffer> <c-]> :call <SID>PreGetPage(v:count)<CR>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 nnoremap <buffer> <c-t> :call <SID>PopPage()<CR>
7272
17333ebd2bbd commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents: 6476
diff changeset
30 nnoremap <buffer> <silent> q :q<CR>
17333ebd2bbd commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents: 6476
diff changeset
31 endif
17333ebd2bbd commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents: 6476
diff changeset
32
17333ebd2bbd commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents: 6476
diff changeset
33 if exists('g:ft_man_folding_enable') && (g:ft_man_folding_enable == 1)
17333ebd2bbd commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents: 6476
diff changeset
34 setlocal foldmethod=indent foldnestmax=1 foldenable
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3410
94601b379f38 Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents: 3082
diff changeset
37 let b:undo_ftplugin = "setlocal iskeyword<"
94601b379f38 Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents: 3082
diff changeset
38
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 if exists(":Man") != 2
13125
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
42 com -nargs=+ -complete=shellcmd Man call s:GetPage(<f-args>)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 nmap <Leader>K :call <SID>PreGetPage(0)<CR>
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9326
diff changeset
44 nmap <Plug>ManPreGetPage :call <SID>PreGetPage(0)<CR>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 " Define functions only once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 if !exists("s:man_tag_depth")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 let s:man_tag_depth = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
1623
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
52 let s:man_sect_arg = ""
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
53 let s:man_find_arg = "-w"
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
54 try
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
55 if !has("win32") && $OSTYPE !~ 'cygwin\|linux' && system('uname -s') =~ "SunOS" && system('uname -r') =~ "^5"
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
56 let s:man_sect_arg = "-s"
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
57 let s:man_find_arg = "-l"
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
58 endif
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
59 catch /E145:/
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
60 " Ignore the error in restricted mode
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
61 endtry
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 func <SID>PreGetPage(cnt)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 if a:cnt == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 let old_isk = &iskeyword
6369
c5d53d4c3e2e Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5220
diff changeset
66 if &ft == 'man'
c5d53d4c3e2e Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5220
diff changeset
67 setl iskeyword+=(,)
c5d53d4c3e2e Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5220
diff changeset
68 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 let str = expand("<cword>")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 let &l:iskeyword = old_isk
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 let page = substitute(str, '(*\(\k\+\).*', '\1', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 let sect = substitute(str, '\(\k\+\)(\([^()]*\)).*', '\2', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 if match(sect, '^[0-9 ]\+$') == -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 let sect = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 if sect == page
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 let sect = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 let sect = a:cnt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 let page = expand("<cword>")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 call s:GetPage(sect, page)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 endfunc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 func <SID>GetCmdArg(sect, page)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 if a:sect == ''
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 return a:page
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 return s:man_sect_arg.' '.a:sect.' '.a:page
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 endfunc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 func <SID>FindPage(sect, page)
10734
523cd59d6db0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
94 let where = system("man ".s:man_find_arg.' '.s:GetCmdArg(a:sect, a:page))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 if where !~ "^/"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 if matchstr(where, " [^ ]*$") !~ "^ /"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 return 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 endfunc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 func <SID>GetPage(...)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 if a:0 >= 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 let sect = a:1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 let page = a:2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 elseif a:0 >= 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 let sect = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 let page = a:1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 return
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 " To support: nmap K :Man <cword>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 if page == '<cword>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 let page = expand('<cword>')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 if sect != "" && s:FindPage(sect, page) == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 let sect = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 if s:FindPage(sect, page) == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 echo "\nCannot find a '".page."'."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 return
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 exec "let s:man_tag_buf_".s:man_tag_depth." = ".bufnr("%")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 exec "let s:man_tag_lin_".s:man_tag_depth." = ".line(".")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 exec "let s:man_tag_col_".s:man_tag_depth." = ".col(".")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 let s:man_tag_depth = s:man_tag_depth + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 " Use an existing "man" window if it exists, otherwise open a new one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 if &filetype != "man"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 let thiswin = winnr()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 exe "norm! \<C-W>b"
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 816
diff changeset
135 if winnr() > 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 exe "norm! " . thiswin . "\<C-W>w"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 while 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 if &filetype == "man"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 exe "norm! \<C-W>w"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 if thiswin == winnr()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 endif
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 816
diff changeset
147 if &filetype != "man"
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
148 if exists("g:ft_man_open_mode")
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
149 if g:ft_man_open_mode == "vert"
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
150 vnew
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
151 elseif g:ft_man_open_mode == "tab"
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
152 tabnew
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
153 else
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
154 new
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
155 endif
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
156 else
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
157 new
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
158 endif
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 816
diff changeset
159 setl nonu fdc=0
96cd8222a819 updated for version 7.1a
vimboss
parents: 816
diff changeset
160 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 silent exec "edit $HOME/".page.".".sect."~"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 " Avoid warning for editing the dummy file twice
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 7
diff changeset
164 setl buftype=nofile noswapfile
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165
5220
050893d44c33 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
166 setl ma nonu nornu nofen
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 silent exec "norm 1GdG"
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
168 let unsetwidth = 0
7992
78106b0f2c56 commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents: 7272
diff changeset
169 if empty($MANWIDTH)
78106b0f2c56 commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents: 7272
diff changeset
170 let $MANWIDTH = winwidth(0)
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
171 let unsetwidth = 1
7992
78106b0f2c56 commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents: 7272
diff changeset
172 endif
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
173
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
174 " Ensure Vim is not recursively invoked (man-db does this) when doing ctrl-[
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
175 " on a man page reference by unsetting MANPAGER.
13125
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
176 " Some versions of env(1) do not support the '-u' option, and in such case
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
177 " we set MANPAGER=cat.
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
178 if !exists('s:env_has_u')
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
179 call system('env -u x true')
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
180 let s:env_has_u = (v:shell_error == 0)
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
181 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
182 let env_cmd = s:env_has_u ? 'env -u MANPAGER' : 'env MANPAGER=cat'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
183 let man_cmd = env_cmd . ' man ' . s:GetCmdArg(sect, page) . ' | col -b'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
184 silent exec "r !" . man_cmd
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
185
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
186 if unsetwidth
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
187 let $MANWIDTH = ''
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
188 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 " Remove blank lines from top and bottom.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 while getline(1) =~ '^\s*$'
6476
11d78e58a487 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6369
diff changeset
191 silent keepj norm ggdd
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 while getline('$') =~ '^\s*$'
6476
11d78e58a487 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6369
diff changeset
194 silent keepj norm Gdd
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 setl ft=man nomod
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 setl bufhidden=hide
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 setl nobuflisted
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
200 setl noma
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 endfunc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 func <SID>PopPage()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 if s:man_tag_depth > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 let s:man_tag_depth = s:man_tag_depth - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 exec "let s:man_tag_buf=s:man_tag_buf_".s:man_tag_depth
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 exec "let s:man_tag_lin=s:man_tag_lin_".s:man_tag_depth
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 exec "let s:man_tag_col=s:man_tag_col_".s:man_tag_depth
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 exec s:man_tag_buf."b"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 exec s:man_tag_lin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 exec "norm ".s:man_tag_col."|"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 exec "unlet s:man_tag_buf_".s:man_tag_depth
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 exec "unlet s:man_tag_lin_".s:man_tag_depth
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 exec "unlet s:man_tag_col_".s:man_tag_depth
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 unlet s:man_tag_buf s:man_tag_lin s:man_tag_col
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 endfunc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
221 " vim: set sw=2 ts=8 noet: