Start anew
[msysgit.git] / share / vim / vim58 / optwin.vim
blobe6c7ee49f4fbdf945da67c4186d18c487fc108fb
1 " These commands create the option window.
3 " Maintainer:   Bram Moolenaar <Bram@vim.org>
4 " Last Change:  2000 Jul 05
6 " Make sure the '<' flag is not included in 'cpoptions', otherwise <CR> would
7 " not be recognized.  See ":help 'cpoptions'".
8 let optwin_cpo_save = &cpo
9 let &cpo = ""
11 " function to be called when <CR> is hit in the option-window
12 fun! OW_CR()
14   " If on a continued comment line, go back to the first comment line
15   let lnum = line(".")
16   let line = getline(lnum)
17   while line[0] == "\t"
18     let lnum = lnum - 1
19     let line = getline(lnum)
20   endwhile
22   " <CR> on a "set" line executes the option line
23   if match(line, "^set ") >= 0
25     " For a local option: go to the previous window
26     " If this is a help window, go to the window below it
27     let thiswin = winnr()
28     let local = OW_Find(lnum)
29     if local >= 0
30       exe line
31       call OW_Update(lnum, line, local, thiswin)
32     endif
34   " <CR> on a "option" line shows help for that option
35   elseif match(line, "^[a-z]") >= 0
36     let name = substitute(line, '\([^\t]*\).*', '\1', "")
37     exe "help '" . name . "'"
39   " <CR> on an index line jumps to the group
40   elseif match(line, '^ \=[0-9]') >= 0
41     exe "norm! /" . line . "\<CR>zt"
42   endif
43 endfun
45 " function to be called when <Space> is hit in the option-window
46 fun! OW_Space()
48   let lnum = line(".")
49   let line = getline(lnum)
51   " <Space> on a "set" line refreshes the option line
52   if match(line, "^set ") >= 0
54     " For a local option: go to the previous window
55     " If this is a help window, go to the window below it
56     let thiswin = winnr()
57     let local = OW_Find(lnum)
58     if local >= 0
59       call OW_Update(lnum, line, local, thiswin)
60     endif
62   endif
63 endfun
65 " find the window in which the option applies
66 " returns 0 for global option, 1 for local option, -1 for error
67 fun! OW_Find(lnum)
68     if getline(a:lnum - 1) =~ "(local to"
69       let local = 1
70       let thiswin = winnr()
71       exe "norm! \<C-W>p"
72       if exists("b:current_syntax") && b:current_syntax == "help"
73         exe "norm! \<C-W>j"
74         if winnr() == thiswin
75           exe "norm! \<C-W>j"
76         endif
77       endif
78     else
79       let local = 0
80     endif
81     if local && (winnr() == thiswin || (exists("b:current_syntax")
82         \ && b:current_syntax == "help"))
83       echo "Don't know in which window"
84       let local = -1
85     endif
86     return local
87 endfun
89 " Update a "set" line in the option window
90 fun! OW_Update(lnum, line, local, thiswin)
91   " get the new value of the option and update the option window line
92   if match(a:line, "=") >= 0
93     let name = substitute(a:line, '^set \([^=]*\)=.*', '\1', "")
94   else
95     let name = substitute(a:line, '^set \(no\)\=\([a-z]*\).*', '\2', "")
96   endif
97   exe "let val = substitute(&" . name . ', "[ \\t\\\\\"|]", "\\\\\\0", "g")'
98   if a:local
99     exe "norm! " . a:thiswin . "\<C-W>w"
100   endif
101   if match(a:line, "=") >= 0 || (val != "0" && val != "1")
102     call setline(a:lnum, "set " . name . "=" . val)
103   else
104     if val
105       call setline(a:lnum, "set " . name . "\tno" . name)
106     else
107       call setline(a:lnum, "set no" . name . "\t" . name)
108     endif
109   endif
110   set nomodified
111 endfun
113 " Reset 'title' and 'icon' to make it work faster.
114 let old_title = &title
115 let old_icon = &icon
116 let old_sc = &sc
117 let old_ru = &ru
118 set notitle noicon nosc noru
120 " If the current window is a help window, try finding a non-help window.
121 " Relies on syntax highlighting to be switched on.
122 let OW_thiswin = winnr()
123 while exists("b:current_syntax") && b:current_syntax == "help"
124   exe "norm! \<C-W>w"
125   if OW_thiswin == winnr()
126     break
127   endif
128 endwhile
129 unlet OW_thiswin
131 " Open the window
132 new option-window
133 set ts=15 tw=0
135 " Insert help and a "set" command for each option.
136 call append(0, 'Each "set" line shows the current value of an option (on the left).')
137 call append(1, 'Hit <CR> on a "set" line to execute it.')
138 call append(2, '           A boolean option will be toggled.')
139 call append(3, '           For other options you can edit the value.')
140 call append(4, 'Hit <CR> on a help line to open a help window on this option.')
141 call append(5, 'Hit <CR> on an index line to jump there.')
142 call append(6, 'Hit <Space> on a "set" line to refresh it.')
144 " These functions are called often below.  Keep them fast!
145 fun! OW_BinOption(name)
146   exe "norm! \<C-W>p"
147   exe "let val = &" . a:name
148   exe "norm! \<C-W>p"
149   call append("$", substitute(substitute("set " . val . a:name . "\t" .
150         \!val . a:name, "0", "no", ""), "1", "", ""))
151 endfun
153 fun! OW_BinOptionL(name, val)
154   call append("$", substitute(substitute("set " . a:val . a:name . "\t" .
155         \!a:val . a:name, "0", "no", ""), "1", "", ""))
156 endfun
158 fun! OW_Option(name)
159   exe "norm! \<C-W>p"
160   exe "let val = substitute(&" . a:name . ', "[ \\t\\\\\"|]", "\\\\\\0", "g")'
161   exe "norm! \<C-W>p"
162   call append("$", "set " . a:name . "=" . val)
163 endfun
165 fun! OW_OptionL(name, val)
166   call append("$", "set " . a:name . "=" . substitute(a:val, "[ \\t\\\\\"|]",
167         \"\\\\\\0", "g"))
168 endfun
170 let OW_idx = 1
171 let OW_lnum = line("$")
172 call append("$", "")
174 fun! OW_Header(text)
175   let line = g:OW_idx . " " . a:text
176   if g:OW_idx < 10
177     let line = " " . line
178   endif
179   call append("$", "")
180   call append("$", line)
181   call append("$", "")
182   call append(g:OW_lnum, line)
183   let g:OW_idx = g:OW_idx + 1
184   let g:OW_lnum = g:OW_lnum + 1
185 endfun
187 " Restore the previous value of 'cpoptions' here, it's used below.
188 let &cpo = optwin_cpo_save
190 " List of all options, organized by function.
191 " The text should be sufficient to know what the option is used for.
193 call OW_Header("important")
194 call append("$", "compatible\tbehave very Vi compatible (not advisable)")
195 call OW_BinOptionL("cp", &cp)
196 call append("$", "cpoptions\tlist of flags to specify Vi compatibility")
197 call OW_OptionL("cpo", &cpo)
198 call append("$", "insertmode\tuse Insert mode as the default mode")
199 call OW_BinOptionL("im", &im)
200 call append("$", "paste\tpaste mode, insert typed text literally")
201 call OW_BinOptionL("paste", &paste)
202 call append("$", "pastetoggle\tkey sequence to toggle paste mode")
203 call OW_OptionL("pt", &pt)
204 call append("$", "helpfile\tname of the main help file")
205 call OW_OptionL("hf", &hf)
208 call OW_Header("moving around, searching and patterns")
209 call append("$", "whichwrap\tlist of flags specifying which commands wrap to another line")
210 call append("$", "\t(local to window)")
211 call OW_Option("ww")
212 call append("$", "startofline\tmany jump commands move the cursor to the first non-blank")
213 call append("$", "\tcharacter of a line")
214 call OW_BinOptionL("sol", &sol)
215 call append("$", "paragraphs\tnroff macro names that separate paragraphs")
216 call OW_OptionL("para", &para)
217 call append("$", "sections\tnroff macro names that separate sections")
218 call OW_OptionL("sect", &sect)
219 call append("$", "path\tlist of directory names used for file searching")
220 call OW_OptionL("pa", &pa)
221 call append("$", "wrapscan\tsearch commands wrap around the end of the buffer")
222 call OW_BinOptionL("ws", &ws)
223 call append("$", "incsearch\tshow match for partly typed search command")
224 call OW_BinOptionL("is", &is)
225 call append("$", "magic\tchange the way backslashes are used in search patterns")
226 call OW_BinOptionL("magic", &magic)
227 call append("$", "ignorecase\tignore case when using a search pattern")
228 call OW_BinOptionL("ic", &ic)
229 call append("$", "smartcase\toverride 'ignorecase' when pattern has upper case characters")
230 call OW_BinOptionL("scs", &scs)
231 call append("$", "define\tpattern for a macro definition line")
232 call OW_OptionL("def", &def)
233 call append("$", "include\tpattern for an include-file line")
234 call OW_OptionL("inc", &inc)
237 call OW_Header("tags")
238 call append("$", "tagbsearch\tuse binary searching in tags files")
239 call OW_BinOptionL("tbs", &tbs)
240 call append("$", "taglength\tnumber of significant characters in a tag name or zero")
241 call append("$", "set tl=" . &tl)
242 call append("$", "tags\tlist of file names to search for tags")
243 call OW_OptionL("tag", &tag)
244 call append("$", "tagrelative\tfile names in a tags file are relative to the tags file")
245 call OW_BinOptionL("tr", &tr)
246 call append("$", "showfulltag\twhen completing tags in Insert mode show more info")
247 call OW_BinOptionL("sft", &sft)
248 if has("cscope")
249   call append("$", "cscopeprg\tcommand for executing cscope")
250   call OW_OptionL("csprg", &csprg)
251   call append("$", "cscopetag\tuse cscope for tag commands")
252   call OW_BinOptionL("cst", &cst)
253   call append("$", "cscopetagorder\t0 or 1; the order in which \":cstag\" performs a search")
254   call append("$", "set csto=" . &csto)
255   call append("$", "cscopeverbose\tgive messages when adding a cscope database")
256   call OW_BinOptionL("csverb", &csverb)
257 endif
260 call OW_Header("displaying text")
261 call append("$", "scroll\tnumber of lines to scroll for CTRL-U and CTRL-D")
262 call append("$", "\t(local to window)")
263 call OW_Option("scr")
264 call append("$", "scrolloff\tnumber of screen lines to show around the cursor")
265 call append("$", "set so=" . &so)
266 call append("$", "wrap\tlong lines wrap")
267 call OW_BinOptionL("wrap", &wrap)
268 call append("$", "linebreak\twrap long lines at a character in 'breakat'")
269 call append("$", "\t(local to window)")
270 call OW_BinOption("lbr")
271 call append("$", "breakat\twhich characters might cause a line break")
272 call OW_OptionL("brk", &brk)
273 call append("$", "showbreak\tstring to put before wrapped screen lines")
274 call OW_OptionL("sbr", &sbr)
275 call append("$", "sidescroll\tminimal number of columns to scroll horizontally")
276 call append("$", "set ss=" . &ss)
277 call append("$", "display\twhen \"lastline\": show the last line even if it doesn't fit")
278 call OW_OptionL("dy", &dy)
279 call append("$", "cmdheight\tnumber of lines used for the command-line")
280 call append("$", "set ch=" . &ch)
281 call append("$", "columns\twidth of the display")
282 call append("$", "set co=" . &co)
283 call append("$", "lines\tnumber of lines in the display")
284 call append("$", "set lines=" . &lines)
285 call append("$", "lazyredraw\tdon't redraw while executing macros")
286 call OW_BinOptionL("lz", &lz)
287 call append("$", "writedelay\tdelay in msec for each char written to the display")
288 call append("$", "\t(for debugging)")
289 call append("$", "set wd=" . &wd)
290 call append("$", "list\tshow <Tab> as ^I and end-of-line as $")
291 call append("$", "\t(local to window)")
292 call OW_BinOption("list")
293 call append("$", "listchars\tlist of strings used for list mode")
294 call OW_OptionL("lcs", &lcs)
295 call append("$", "number\tshow the line number for each line")
296 call append("$", "\t(local to window)")
297 call OW_BinOption("nu")
300 call OW_Header("syntax and highlighting")
301 call append("$", "background\t\"dark\" or \"light\"; the background color brightness")
302 call OW_OptionL("bg", &bg)
303 if has("autocmd")
304   call append("$", "filetype\ttype of file; triggers the FileType event when set")
305   call append("$", "\t(local to buffer)")
306   call OW_Option("ft")
307 endif
308 if has("syntax")
309   call append("$", "syntax\tname of syntax highlighting used")
310   call append("$", "\t(local to buffer)")
311   call OW_Option("syn")
312 endif
313 call append("$", "highlight\twhich highlighting to use for various occasions")
314 call OW_OptionL("hl", &hl)
315 call append("$", "hlsearch\thighlight all matches for the current search pattern")
316 call OW_BinOptionL("hls", &hls)
319 call OW_Header("multiple windows")
320 call append("$", "laststatus\t0, 1 or 2; when to use a status line for the last window")
321 call append("$", "set ls=" . &ls)
322 if has("statusline")
323   call append("$", "statusline\talternate format to be used for a status line")
324   call OW_OptionL("stl", &stl)
325 endif
326 call append("$", "equalalways\tmake all windows the same size when adding/removing windows")
327 call OW_BinOptionL("ea", &ea)
328 call append("$", "winheight\tminimal number of lines used for the current window")
329 call append("$", "set wh=" . &wh)
330 call append("$", "winminheight\tminimal number of lines used for any window")
331 call append("$", "set wmh=" . &wmh)
332 call append("$", "helpheight\tinitial height of the help window")
333 call append("$", "set hh=" . &hh)
334 call append("$", "previewheight\tdefault height for the preview window")
335 call append("$", "set pvh=" . &pvh)
336 call append("$", "hidden\tdon't unload a buffer when no longer shown in a window")
337 call OW_BinOptionL("hid", &hid)
338 call append("$", "switchbuf\t\"useopen\" and/or \"split\"; which window to use when jumping")
339 call append("$", "\tto a buffer")
340 call OW_OptionL("swb", &swb)
341 call append("$", "splitbelow\ta new window is put below the current one")
342 call OW_BinOptionL("sb", &sb)
343 if has("scrollbind")
344   call append("$", "scrollbind\tthis window scrolls together with other bound windows")
345   call append("$", "\t(local to window)")
346   call OW_BinOption("scb")
347   call append("$", "scrollopt\t\"ver\", \"hor\" and/or \"jump\"; list of options for 'scrollbind'")
348   call OW_OptionL("sbo", &sbo)
349 endif
352 call OW_Header("terminal")
353 call append("$", "term\tname of the used terminal")
354 call OW_OptionL("term", &term)
355 call append("$", "ttytype\talias for 'term'")
356 call OW_OptionL("tty", &tty)
357 call append("$", "ttybuiltin\tcheck built-in termcaps first")
358 call OW_BinOptionL("tbi", &tbi)
359 call append("$", "ttyfast\tterminal connection is fast")
360 call OW_BinOptionL("tf", &tf)
361 call append("$", "weirdinvert\tterminal that requires extra redrawing")
362 call OW_BinOptionL("wiv", &wiv)
363 call append("$", "esckeys\trecognize keys that start with <Esc> in Insert mode")
364 call OW_BinOptionL("ek", &ek)
365 call append("$", "scrolljump\tminimal number of lines to scroll at a time")
366 call append("$", "set sj=" . &sj)
367 call append("$", "ttyscroll\tmaximum number of lines to use scrolling instead of redrawing")
368 call append("$", "set tsl=" . &tsl)
369 if has("gui") || has("msdos") || has("win32")
370   call append("$", "guicursor\tspecifies what the cursor looks like in different modes")
371   call OW_OptionL("gcr", &gcr)
372 endif
373 if has("title")
374   let &title = old_title
375   call append("$", "title\tshow info in the window title")
376   call OW_BinOptionL("title", &title)
377   set notitle
378   call append("$", "titlelen\tpercentage of 'columns' used for the window title")
379   call append("$", "set titlelen=" . &titlelen)
380   call append("$", "titlestring\twhen not empty, string to be used for the window title")
381   call OW_OptionL("titlestring", &titlestring)
382   call append("$", "titleold\tstring to restore the title to when exiting Vim")
383   call OW_OptionL("titleold", &titleold)
384   let &icon = old_icon
385   call append("$", "icon\tset the text of the icon for this window")
386   call OW_BinOptionL("icon", &icon)
387   set noicon
388   call append("$", "iconstring\twhen not empty, text for the icon of this window")
389   call OW_OptionL("iconstring", &iconstring)
390 endif
391 if has("win32")
392   call append("$", "restorescreen\trestore the screen contents when exiting Vim")
393   call OW_BinOptionL("rs", &rs)
394 endif
397 call OW_Header("using the mouse")
398 call append("$", "mouse\tlist of flags for using the mouse")
399 call OW_OptionL("mouse", &mouse)
400 if has("gui")
401   call append("$", "mousefocus\tthe window with the mouse pointer becomes the current one")
402   call OW_BinOptionL("mousef", &mousef)
403   call append("$", "mousehide\thide the mouse pointer while typing")
404   call OW_BinOptionL("mh", &mh)
405 endif
406 call append("$", "mousemodel\t\"extend\", \"popup\" or \"popup_setpos\"; what the right")
407 call append("$", "\tmouse button is used for")
408 call OW_OptionL("mousem", &mousem)
409 call append("$", "mousetime\tmaximum time in msec to recognize a double-click")
410 call append("$", "set mouset=" . &mouset)
411 call append("$", "ttymouse\t\"xterm\", \"xterm2\", \"dec\" or \"netterm\"; type of mouse")
412 call OW_OptionL("ttym", &ttym)
415 if has("gui")
416   call OW_Header("GUI")
417   call append("$", "guifont\tlist of font names to be used in the GUI")
418   call OW_OptionL("gfn", &gfn)
419   call append("$", "guioptions\tlist of flags that specify how the GUI works")
420   call OW_OptionL("go", &go)
421   if has("gui_gtk")
422     call append("$", "toolbar\t\"icons\", \"text\" and/or \"tooltips\"; how to show the toolbar")
423     call OW_OptionL("tb", &tb)
424     call append("$", "guiheadroom\troom (in pixels) left above/below the window")
425     call append("$", "set ghr=" . &ghr)
426   endif
427   call append("$", "guipty\tuse a pseudo-tty for I/O to external commands")
428   call OW_BinOptionL("guipty", &guipty)
429   if has("xfontset")
430     call append("$", "guifontset\tpair of fonts to be used, for multibyte editing")
431     call OW_OptionL("gfs", &gfs)
432   endif
433   if has("browse")
434     call append("$", "browsedir\t\"last\", \"buffer\" or \"current\": which directory used for the file browser")
435     call OW_OptionL("bsdir", &bsdir)
436   endif
437   if has("winaltkeys")
438     call append("$", "winaltkeys\t\"no\", \"yes\" or \"menu\"; how to use the ALT key")
439     call OW_OptionL("wak", &wak)
440   endif
441 endif
444 call OW_Header("messages and info")
445 call append("$", "terse\tadd 's' flag in 'shortmess' (don't show search message)")
446 call OW_BinOptionL("terse", &terse)
447 call append("$", "shortmess\tlist of flags to make messages shorter")
448 call OW_OptionL("shm", &shm)
449 call append("$", "showcmd\tshow (partial) command keys in the status line")
450 let &sc = old_sc
451 call OW_BinOptionL("sc", &sc)
452 set nosc
453 call append("$", "showmode\tdisplay the current mode in the status line")
454 call OW_BinOptionL("smd", &smd)
455 call append("$", "ruler\tshow cursor position below each window")
456 let &ru = old_ru
457 call OW_BinOptionL("ru", &ru)
458 set noru
459 if has("statusline")
460   call append("$", "rulerformat\talternate format to be used for the ruler")
461   call OW_OptionL("ruf", &ruf)
462 endif
463 call append("$", "report\tthreshold for reporting number of changed lines")
464 call append("$", "set report=" . &report)
465 call append("$", "verbose\tthe higher the more messages are given")
466 call append("$", "set vbs=" . &vbs)
467 call append("$", "more\tpause listings when the screen is full")
468 call OW_BinOptionL("more", &more)
469 if has("dialog_con") || has("dialog_gui")
470   call append("$", "confirm\tstart a dialog when a command fails")
471   call OW_BinOptionL("cf", &cf)
472 endif
473 call append("$", "errorbells\tring the bell for error messages")
474 call OW_BinOptionL("eb", &eb)
475 call append("$", "visualbell\tuse a visual bell instead of beeping")
476 call OW_BinOptionL("vb", &vb)
479 call OW_Header("selecting text")
480 call append("$", "selection\t\"old\", \"inclusive\" or \"exclusive\"; how selecting text behaves")
481 call OW_OptionL("sel", &sel)
482 call append("$", "selectmode\t\"mouse\", \"key\" and/or \"cmd\"; when to start Select mode")
483 call append("$", "\tinstead of Visual mode")
484 call OW_OptionL("slm", &slm)
485 if has("clipboard")
486   call append("$", "clipboard\t\"unnamed\" to use the * register like unnamed register")
487   call append("$", "\t\"autoselect\" to always put selected text on the clipboard")
488   call OW_OptionL("cb", &cb)
489 endif
490 call append("$", "keymodel\t\"startsel\" and/or \"stopsel\"; what special keys can do")
491 call OW_OptionL("km", &km)
494 call OW_Header("editing text")
495 call append("$", "undolevels\tmaximum number of changes that can be undone")
496 call append("$", "set ul=" . &ul)
497 call append("$", "modified\tchanges have been made and not written to a file")
498 call append("$", "\t(local to buffer)")
499 call OW_BinOption("mod")
500 call append("$", "readonly\tbuffer is not to be written")
501 call append("$", "\t(local to buffer)")
502 call OW_BinOption("ro")
503 call append("$", "textwidth\tline length above which to break a line")
504 call append("$", "\t(local to buffer)")
505 call OW_Option("tw")
506 call append("$", "wrapmargin\tmargin from the right in which to break a line")
507 call append("$", "\t(local to buffer)")
508 call OW_Option("wm")
509 call append("$", "backspace\t0, 1 or 2; what <BS> can do in Insert mode")
510 call append("$", "set bs=" . &bs)
511 call append("$", "comments\tdefinition of what comment lines look like")
512 call append("$", "\t(local to buffer)")
513 call OW_Option("com")
514 call append("$", "formatoptions\tlist of flags that tell how automatic formatting works")
515 call append("$", "\t(local to buffer)")
516 call OW_Option("fo")
517 if has("insert_expand")
518   call append("$", "complete\tspecifies how Insert mode completion works")
519   call append("$", "\t(local to buffer)")
520   call OW_Option("cpt")
521   call append("$", "dictionary\tlist of dictionary files for keyword completion")
522   call OW_OptionL("dict", &dict)
523 endif
524 call append("$", "infercase\tadjust case of a keyword completion match")
525 call append("$", "\t(local to buffer)")
526 call OW_BinOption("inf")
527 if has("digraphs")
528   call append("$", "digraph\tenable entering digraps with c1 <BS> c2")
529   call OW_BinOptionL("dg", &dg)
530 endif
531 call append("$", "tildeop\tthe \"~\" command behaves like an operator")
532 call OW_BinOptionL("top", &top)
533 call append("$", "showmatch\tWhen inserting a bracket, briefly jump to its match")
534 call OW_BinOptionL("sm", &sm)
535 call append("$", "matchtime\ttenth of a second to show a match for 'showmatch'")
536 call append("$", "set mat=" . &mat)
537 call append("$", "matchpairs\tlist of pairs that match for the \"%\" command")
538 call append("$", "\t(local to buffer)")
539 call OW_Option("mps")
540 call append("$", "joinspaces\tuse two spaces after '.' when joining a line")
541 call OW_BinOptionL("js", &js)
542 call append("$", "nrformats\t\"octal\" and/or \"hex\"; number formats recognized for")
543 call append("$", "\tCTRL-A and CTRL-X commands")
544 call append("$", "\t(local to buffer)")
545 call OW_Option("nf")
548 call OW_Header("tabs and indenting")
549 call append("$", "tabstop\tnumber of spaces a <Tab> in the text stands for")
550 call append("$", "\t(local to buffer)")
551 call OW_Option("ts")
552 call append("$", "shiftwidth\tnumber of spaces used for each step of (auto)indent")
553 call append("$", "\t(local to buffer)")
554 call OW_Option("sw")
555 call append("$", "smarttab\ta <Tab> in an indent inserts 'shiftwidth' spaces")
556 call OW_BinOptionL("sta", &sta)
557 call append("$", "softtabstop\tif non-zero, number of spaces to insert for a <Tab>")
558 call append("$", "\t(local to buffer)")
559 call OW_Option("sts")
560 call append("$", "shiftround\tround to 'shiftwidth' for \"<<\" and \">>\"")
561 call OW_BinOptionL("sr", &sr)
562 call append("$", "expandtab\texpand <Tab> to spaces in Insert mode")
563 call append("$", "\t(local to buffer)")
564 call OW_BinOption("et")
565 call append("$", "autoindent\tautomatically set the indent of a new line")
566 call append("$", "\t(local to buffer)")
567 call OW_BinOption("ai")
568 if has("smartindent")
569   call append("$", "smartindent\tdo clever autoindenting")
570   call append("$", "\t(local to buffer)")
571   call OW_BinOption("si")
572 endif
573 if has("cindent")
574   call append("$", "cindent\tenable specific indenting for C code")
575   call append("$", "\t(local to buffer)")
576   call OW_BinOption("cin")
577   call append("$", "cinoptions\toptions for C-indenting")
578   call append("$", "\t(local to buffer)")
579   call OW_Option("cino")
580   call append("$", "cinkeys\tkeys that trigger C-indenting in Insert mode")
581   call append("$", "\t(local to buffer)")
582   call OW_Option("cink")
583   call append("$", "cinwords\tlist of words that cause more C-indent")
584   call append("$", "\t(local to buffer)")
585   call OW_Option("cinw")
586 endif
587 call append("$", "lisp\tenable lisp mode")
588 call append("$", "\t(local to buffer)")
589 call OW_BinOption("lisp")
592 call OW_Header("mapping")
593 call append("$", "maxmapdepth\tmaximum depth of mapping")
594 call append("$", "set mmd=" . &mmd)
595 call append("$", "remap\trecognize mappings in mapped keys")
596 call OW_BinOptionL("remap", &remap)
597 call append("$", "timeout\ttime-out halfway a mapping")
598 call OW_BinOptionL("to", &to)
599 call append("$", "ttimeout\ttime-out halfway a key code")
600 call OW_BinOptionL("ttimeout", &ttimeout)
601 call append("$", "timeoutlen\ttime in msec for 'timeout'")
602 call append("$", "set tm=" . &tm)
603 call append("$", "ttimeoutlen\ttime in msec for 'ttimeout'")
604 call append("$", "set ttm=" . &ttm)
607 call OW_Header("reading and writing files")
608 call append("$", "modeline\tenable using settings from modelines when reading a file")
609 call append("$", "\t(local to buffer)")
610 call OW_BinOption("ml")
611 call append("$", "modelines\tnumber of lines to check for modelines")
612 call append("$", "set mls=" . &mls)
613 call append("$", "binary\tbinary file editing")
614 call append("$", "\t(local to buffer)")
615 call OW_BinOption("bin")
616 call append("$", "endofline\tlast line in the file has an end-of-line")
617 call append("$", "\t(local to buffer)")
618 call OW_BinOption("eol")
619 call append("$", "fileformat\tend-of-line format: \"dos\", \"unix\" or \"mac\"")
620 call append("$", "\t(local to buffer)")
621 call OW_Option("ff")
622 call append("$", "fileformats\tlist of file formats to look for when editing a file")
623 call OW_OptionL("ffs", &ffs)
624 call append("$", "textmode\tobsolete, use 'fileformat'")
625 call append("$", "\t(local to buffer)")
626 call OW_BinOption("tx")
627 call append("$", "textauto\tobsolete, use 'fileformats'")
628 call OW_BinOptionL("ta", &ta)
629 call append("$", "write\twriting files is allowed")
630 call OW_BinOptionL("write", &write)
631 call append("$", "writebackup\twrite a backup file before overwriting")
632 call OW_BinOptionL("wb", &wb)
633 call append("$", "backup\tkeep a backup after overwriting a file")
634 call OW_BinOptionL("bk", &bk)
635 call append("$", "backupdir\tlist of directories to put backup files in")
636 call OW_OptionL("bdir", &bdir)
637 call append("$", "backupext\tfile name extension for the backup file")
638 call OW_OptionL("bex", &bex)
639 call append("$", "autowrite\tautomatically write a file when leaving a modified buffer")
640 call OW_BinOptionL("aw", &aw)
641 call append("$", "writeany\talways write without asking for confirmation")
642 call OW_BinOptionL("wa", &wa)
643 call append("$", "patchmode\tkeep oldest version of a file; specifies file name extension")
644 call OW_OptionL("pm", &pm)
645 if !has("msdos")
646   call append("$", "shortname\tuse 8.3 file names")
647   call append("$", "\t(local to buffer)")
648   call OW_BinOption("sn")
649 endif
652 call OW_Header("the swap file")
653 call append("$", "directory\tlist of directories for the swap file")
654 call OW_OptionL("dir", &dir)
655 call append("$", "swapfile\tuse a swap file for this buffer")
656 call append("$", "\t(local to buffer)")
657 call OW_BinOption("swf")
658 call append("$", "swapsync\t\"sync\", \"fsync\" or empty; how to flush a swap file to disk")
659 call OW_OptionL("sws", &sws)
660 call append("$", "updatecount\tnumber of characters typed to cause a swap file update")
661 call append("$", "set uc=" . &uc)
662 call append("$", "updatetime\ttime in msec after which the swap file will be updated")
663 call append("$", "set ut=" . &ut)
664 call append("$", "maxmem\tmaximum amount of memory in Kbyte used for one buffer")
665 call append("$", "set mm=" . &mm)
666 call append("$", "maxmemtot\tmaximum amount of memory in Kbyte used for all buffers")
667 call append("$", "set mmt=" . &mmt)
670 call OW_Header("command line editing")
671 call append("$", "history\thow many command lines are remembered ")
672 call append("$", "set hi=" . &hi)
673 call append("$", "wildchar\tkey that triggers command-line expansion")
674 call append("$", "set wc=" . &wc)
675 call append("$", "wildcharm\tlike 'wildchar' but can also be used in a mapping")
676 call append("$", "set wcm=" . &wcm)
677 call append("$", "wildmode\tspecifies how command line completion works")
678 call OW_OptionL("wim", &wim)
679 call append("$", "suffixes\tlist of file name extensions that have a lower priority")
680 call OW_OptionL("su", &su)
681 if has("wildignore")
682   call append("$", "wildignore\tlist of patterns to ignore files for file name completion")
683   call OW_OptionL("wig", &wig)
684 endif
685 if has("wildmenu")
686   call append("$", "wildmenu\tcommand-line completion shows a list of matches")
687   call OW_BinOptionL("wmnu", &wmnu)
688 endif
691 call OW_Header("executing external commands")
692 call append("$", "shell\tname of the shell program used for external commands")
693 call OW_OptionL("sh", &sh)
694 if has("amiga")
695   call append("$", "shelltype\twhen to use the shell or directly execute a command")
696   call append("$", "set st=" . &st)
697 endif
698 call append("$", "shellquote\tcharacter(s) to enclose a shell command in")
699 call OW_OptionL("shq", &shq)
700 call append("$", "shellxquote\tlike 'shellquote' but include the redirection")
701 call OW_OptionL("sxq", &sxq)
702 call append("$", "shellcmdflag\targument for 'shell' to execute a command")
703 call OW_OptionL("shcf", &shcf)
704 call append("$", "shellredir\tused to redirect command output to a file")
705 call OW_OptionL("srr", &srr)
706 call append("$", "equalprg\tprogram used for \"=\" command")
707 call OW_OptionL("ep", &ep)
708 call append("$", "formatprg\tprogram used to format lines with \"gq\" command")
709 call OW_OptionL("fp", &fp)
710 call append("$", "keywordprg\tprogram used for the \"K\" command")
711 call OW_OptionL("kp", &kp)
712 call append("$", "warn\twarn when using a shell command and a buffer has changes")
713 call OW_BinOptionL("warn", &warn)
716 if has("quickfix")
717   call OW_Header("running make and jumping to errors")
718   call append("$", "errorfile\tname of the file that contains error messages")
719   call OW_OptionL("ef", &ef)
720   call append("$", "errorformat\tlist of formats for error messages")
721   call OW_OptionL("efm", &efm)
722   call append("$", "makeprg\tprogram used for the \":make\" command")
723   call OW_OptionL("mp", &mp)
724   call append("$", "shellpipe\tstring used to put the output of \":make\" in the error file")
725   call OW_OptionL("sp", &sp)
726   call append("$", "makeef\tname of the errorfile for the 'makeprg' command")
727   call OW_OptionL("mef", &mef)
728   call append("$", "grepprg\tprogram used for the \":grep\" command")
729   call OW_OptionL("gp", &gp)
730   call append("$", "grepformat\tlist of formats for output of 'grepprg'")
731   call OW_OptionL("gfm", &gfm)
732 endif
735 if has("msdos") || has("osfiletype")
736   call OW_Header("system specific")
737   if has("msdos")
738     call append("$", "bioskey\tcall the BIOS to get a keyoard character")
739     call OW_BinOptionL("biosk", &biosk)
740     call append("$", "conskey\tuse direct console I/O to get a keyboard character")
741     call OW_BinOptionL("consk", &consk)
742   endif
743   if has("osfiletype")
744     call append("$", "osfiletype\tOS-specific information about the type of file")
745     call append("$", "\t(local to buffer)")
746     call OW_Option("oft")
747   endif
748 endif
751 call OW_Header("language specific")
752 call append("$", "isfname\tspecifies the characters in a file name")
753 call OW_OptionL("isf", &isf)
754 call append("$", "isident\tspecifies the characters in an identifier")
755 call OW_OptionL("isi", &isi)
756 call append("$", "iskeyword\tspecifies the characters in a keyword")
757 call append("$", "\t(local to buffer)")
758 call OW_Option("isk")
759 call append("$", "isprint\tspecifies printable characters")
760 call OW_OptionL("isp", &isp)
761 if has("rightleft")
762   call append("$", "rightleft\tdisplay the buffer right-to-left")
763   call append("$", "\t(local to window)")
764   call OW_BinOption("rl")
765   call append("$", "revins\tInsert characters backwards")
766   call OW_BinOptionL("ri", &ri)
767   call append("$", "allowrevins\tAllow CTRL-_ in Insert and Command-line mode to toggle 'revins'")
768   call OW_BinOptionL("ari", &ari)
769   call append("$", "aleph\tthe ASCII code for the first letter of the Hebrew alphabet")
770   call append("$", "set al=" . &al)
771   call append("$", "hkmap\tuse Hebrew keyboard mapping")
772   call OW_BinOptionL("hk", &hk)
773   call append("$", "hkmapp\tuse phonetic Hebrew keyboard mapping")
774   call OW_BinOptionL("hkp", &hkp)
775 endif
776 if has("farsi")
777   call append("$", "altkeymap\tuse Farsi as the second language when 'revins' is set")
778   call OW_BinOptionL("akm", &akm)
779   call append("$", "fkmap\tuse Farsi keyboard mapping")
780   call OW_BinOptionL("fk", &fk)
781 endif
782 if has("multi_byte")
783   call append("$", "fileencoding\tcharacter encoding of the file: \"ansi\", \"japan\"")
784   call append("$", "\t\"korea\", \"prc\" or \"taiwan\"")
785   call append("$", "\t(local to buffer)")
786   call OW_Option("fe")
787 endif
788 if has("langmap")
789   call append("$", "langmap\ttranslate characters for Command mode")
790   call OW_OptionL("lmap", &lmap)
791 endif
794 call OW_Header("various")
795 if has("autocmd")
796   call append("$", "eventignore\tlist of autocommand events which are to be ignored")
797   call OW_OptionL("ei", &ei)
798 endif
799 call append("$", "exrc\tenable reading .vimrc/.exrc/.gvimrc in the current directory")
800 call OW_BinOptionL("ex", &ex)
801 call append("$", "secure\tsafer working with script files in the current directory")
802 call OW_BinOptionL("secure", &secure)
803 call append("$", "gdefault\tuse the 'g' flag for \":substitute\"")
804 call OW_BinOptionL("gd", &gd)
805 call append("$", "edcompatible\t'g' and 'c' flags of \":substitute\" toggle")
806 call OW_BinOptionL("ed", &ed)
807   call append("$", "maxfuncdepth\tmaximum depth of function calls")
808   call append("$", "set mfd=" . &mfd)
809 if has("mksession")
810   call append("$", "sessionoptions\tlist of words that specifies what to put in a session file")
811   call OW_OptionL("ssop", &ssop)
812 endif
813 if has("viminfo")
814   call append("$", "viminfo\tlist that specifies what to write in the viminfo file")
815   call OW_OptionL("vi", &vi)
816 endif
818 let &cpo = ""
820 " go to first line
823 " reset 'modified', so that ":q" can be used to close the window
824 set nomodified
826 if has("syntax")
827   " Use Vim highlighting, with some additional stuff
828   set ft=vim
829   syn match optwinHeader "^ \=[0-9].*"
830   syn match optwinName "^[a-z]*\t" nextgroup=optwinComment
831   syn match optwinComment ".*" contained
832   syn match optwinComment "^\t.*"
833   if !exists("did_optwin_syntax_inits")
834     let did_optwin_syntax_inits = 1
835     hi link optwinHeader Title
836     hi link optwinName Identifier
837     hi link optwinComment Comment
838   endif
839 endif
841 " Install autocommands to enable mappings in option-window
842 augroup optwin
843   au!
844   au BufEnter option-window call OW_enter()
845   au BufLeave option-window call OW_leave()
846   au BufUnload,BufHidden option-window nested call OW_unload() |
847         \ delfun OW_unload
848 augroup END
850 fun! OW_enter()
851   let cpo_save = &cpo
852   let &cpo = ""
853   " save existing mappings
854   let g:OW_mappings = ""
855   call OW_mapsave("<CR>", "n")
856   call OW_mapsave("<CR>", "i")
857   call OW_mapsave("<Space>", "n")
858   call OW_mapsave("<Space>", "i")
859   noremap <CR> :call OW_CR()<CR><C-\><C-N>:echo<CR>
860   inoremap <CR> <Esc>:call OW_CR()<CR>:echo<CR>
861   noremap <Space> :call OW_Space()<CR>:echo<CR>
862   inoremap <Space> <Esc>:call OW_Space()<CR>:echo<CR>
863   let &cpo = cpo_save
864 endfun
866 fun! OW_mapsave(map, mode)
867   let m = maparg(a:map, a:mode)
868   if m != ""
869     let m = escape(m, '\|')
870     let g:OW_mappings = g:OW_mappings . ":".a:mode."map ".a:map." ".m."|"
871   endif
872 endfun
874 fun! OW_leave()
875   let cpo_save = &cpo
876   let &cpo = ""
877   if mapcheck("<CR>") != ""
878     unmap <CR>
879     iunmap <CR>
880     unmap <Space>
881     iunmap <Space>
882   endif
883   if exists("g:OW_mappings")
884     exe g:OW_mappings
885     unlet g:OW_mappings
886   endif
887   let &cpo = cpo_save
888 endfun
890 fun! OW_unload()
891   delfun OW_CR
892   delfun OW_Space
893   delfun OW_Find
894   delfun OW_Update
895   delfun OW_Option
896   delfun OW_OptionL
897   delfun OW_BinOption
898   delfun OW_BinOptionL
899   delfun OW_Header
900   au! optwin
901   bdel! option-window
902   delfun OW_enter
903   delfun OW_leave
904   delfun OW_mapsave
905 endfun
907 " Execute the enter autocommands now, to enable the mappings
908 doau optwin BufEnter
910 " Restore the previous value of 'title' and 'icon'.
911 let &title = old_title
912 let &icon = old_icon
913 let &ru = old_ru
914 let &sc = old_sc
915 let &cpo = optwin_cpo_save
916 unlet optwin_cpo_save OW_idx OW_lnum old_title old_icon old_ru old_sc