1308 lines · 52.1 KB · Text
RawDownload
" These commands create the option window."" Maintainer:	Bram Moolenaar <Bram@vim.org>" Last Change:	2006 Oct 10 " If there already is an option window, jump to that one.if bufwinnr("option-window") > 0  let s:thiswin = winnr()  while 1    if @% == "option-window"      finish    endif    exe "norm! \<C-W>w"    if s:thiswin == winnr()      break    endif  endwhileendif " Make sure the '<' flag is not included in 'cpoptions', otherwise <CR> would" not be recognized.  See ":help 'cpoptions'".let s:cpo_save = &cposet cpo&vim " function to be called when <CR> is hit in the option-windowfun! <SID>CR()   " If on a continued comment line, go back to the first comment line  let lnum = line(".")  let line = getline(lnum)  while line[0] == "\t"    let lnum = lnum - 1    let line = getline(lnum)  endwhile   " <CR> on a "set" line executes the option line  if match(line, "^ \tset ") >= 0     " For a local option: go to the previous window    " If this is a help window, go to the window below it    let thiswin = winnr()    let local = <SID>Find(lnum)    if local >= 0      exe line      call <SID>Update(lnum, line, local, thiswin)    endif   " <CR> on a "option" line shows help for that option  elseif match(line, "^[a-z]") >= 0    let name = substitute(line, '\([^\t]*\).*', '\1', "")    exe "help '" . name . "'"   " <CR> on an index line jumps to the group  elseif match(line, '^ \=[0-9]') >= 0    exe "norm! /" . line . "\<CR>zt"  endifendfun " function to be called when <Space> is hit in the option-windowfun! <SID>Space()   let lnum = line(".")  let line = getline(lnum)   " <Space> on a "set" line refreshes the option line  if match(line, "^ \tset ") >= 0     " For a local option: go to the previous window    " If this is a help window, go to the window below it    let thiswin = winnr()    let local = <SID>Find(lnum)    if local >= 0      call <SID>Update(lnum, line, local, thiswin)    endif   endifendfun " find the window in which the option applies" returns 0 for global option, 1 for local option, -1 for errorfun! <SID>Find(lnum)    if getline(a:lnum - 1) =~ "(local to"      let local = 1      let thiswin = winnr()      exe "norm! \<C-W>p"      if exists("b:current_syntax") && b:current_syntax == "help"	exe "norm! \<C-W>j"	if winnr() == thiswin	  exe "norm! \<C-W>j"	endif      endif    else      let local = 0    endif    if local && (winnr() == thiswin || (exists("b:current_syntax")	\ && b:current_syntax == "help"))      echo "Don't know in which window"      let local = -1    endif    return localendfun " Update a "set" line in the option windowfun! <SID>Update(lnum, line, local, thiswin)  " get the new value of the option and update the option window line  if match(a:line, "=") >= 0    let name = substitute(a:line, '^ \tset \([^=]*\)=.*', '\1', "")  else    let name = substitute(a:line, '^ \tset \(no\)\=\([a-z]*\).*', '\2', "")  endif  if name == "pt" && &pt =~ "\x80"    let val = <SID>PTvalue()  else    exe "let val = substitute(&" . name . ', "[ \\t\\\\\"|]", "\\\\\\0", "g")'  endif  if a:local    exe "norm! " . a:thiswin . "\<C-W>w"  endif  if match(a:line, "=") >= 0 || (val != "0" && val != "1")    call setline(a:lnum, " \tset " . name . "=" . val)  else    if val      call setline(a:lnum, " \tset " . name . "\tno" . name)    else      call setline(a:lnum, " \tset no" . name . "\t" . name)    endif  endif  set nomodifiedendfun " Reset 'title' and 'icon' to make it work faster.let s:old_title = &titlelet s:old_icon = &iconlet s:old_sc = &sclet s:old_ru = &ruset notitle noicon nosc noru " If the current window is a help window, try finding a non-help window." Relies on syntax highlighting to be switched on.let s:thiswin = winnr()while exists("b:current_syntax") && b:current_syntax == "help"  exe "norm! \<C-W>w"  if s:thiswin == winnr()    break  endifendwhile " Open the windownew option-windowsetlocal ts=15 tw=0 " Insert help and a "set" command for each option.call append(0, '" Each "set" line shows the current value of an option (on the left).')call append(1, '" Hit <CR> on a "set" line to execute it.')call append(2, '"            A boolean option will be toggled.')call append(3, '"            For other options you can edit the value.')call append(4, '" Hit <CR> on a help line to open a help window on this option.')call append(5, '" Hit <CR> on an index line to jump there.')call append(6, '" Hit <Space> on a "set" line to refresh it.') " These functions are called often below.  Keep them fast! " Init a local binary optionfun! <SID>BinOptionL(name)  exe "norm! \<C-W>p"  exe "let val = &" . a:name  exe "norm! \<C-W>p"  call append("$", substitute(substitute(" \tset " . val . a:name . "\t" .	\!val . a:name, "0", "no", ""), "1", "", ""))endfun " Init a global binary optionfun! <SID>BinOptionG(name, val)  call append("$", substitute(substitute(" \tset " . a:val . a:name . "\t" .	\!a:val . a:name, "0", "no", ""), "1", "", ""))endfun " Init a local string optionfun! <SID>OptionL(name)  exe "norm! \<C-W>p"  exe "let val = substitute(&" . a:name . ', "[ \\t\\\\\"|]", "\\\\\\0", "g")'  exe "norm! \<C-W>p"  call append("$", " \tset " . a:name . "=" . val)endfun " Init a global string optionfun! <SID>OptionG(name, val)  call append("$", " \tset " . a:name . "=" . substitute(a:val, '[ \t\\"|]',	\ '\\\0', "g"))endfun let s:idx = 1let s:lnum = line("$")call append("$", "") fun! <SID>Header(text)  let line = s:idx . " " . a:text  if s:idx < 10    let line = " " . line  endif  call append("$", "")  call append("$", line)  call append("$", "")  call append(s:lnum, line)  let s:idx = s:idx + 1  let s:lnum = s:lnum + 1endfun " Get the value of 'pastetoggle'.  It could be a special key.fun! <SID>PTvalue()  redir @a  silent set pt  redir END  return substitute(@a, '[^=]*=\(.*\)', '\1', "")endfun " Restore the previous value of 'cpoptions' here, it's used below.let &cpo = s:cpo_save " List of all options, organized by function." The text should be sufficient to know what the option is used for. call <SID>Header("important")call append("$", "compatible\tbehave very Vi compatible (not advisable)")call <SID>BinOptionG("cp", &cp)call append("$", "cpoptions\tlist of flags to specify Vi compatibility")call <SID>OptionG("cpo", &cpo)call append("$", "insertmode\tuse Insert mode as the default mode")call <SID>BinOptionG("im", &im)call append("$", "paste\tpaste mode, insert typed text literally")call <SID>BinOptionG("paste", &paste)call append("$", "pastetoggle\tkey sequence to toggle paste mode")if &pt =~ "\x80"  call append("$", " \tset pt=" . <SID>PTvalue())else  call <SID>OptionG("pt", &pt)endifcall append("$", "runtimepath\tlist of directories used for runtime files and plugins")call <SID>OptionG("rtp", &rtp)call append("$", "helpfile\tname of the main help file")call <SID>OptionG("hf", &hf)  call <SID>Header("moving around, searching and patterns")call append("$", "whichwrap\tlist of flags specifying which commands wrap to another line")call append("$", "\t(local to window)")call <SID>OptionL("ww")call append("$", "startofline\tmany jump commands move the cursor to the first non-blank")call append("$", "\tcharacter of a line")call <SID>BinOptionG("sol", &sol)call append("$", "paragraphs\tnroff macro names that separate paragraphs")call <SID>OptionG("para", &para)call append("$", "sections\tnroff macro names that separate sections")call <SID>OptionG("sect", &sect)call append("$", "path\tlist of directory names used for file searching")call append("$", "\t(global or local to buffer)")call <SID>OptionG("pa", &pa)call append("$", "cdpath\tlist of directory names used for :cd")call <SID>OptionG("cd", &cd)if has("netbeans_intg") || has("sun_workshop")  call append("$", "autochdir\tchange to directory of file in buffer")  call <SID>BinOptionG("acd", &acd)endifcall append("$", "wrapscan\tsearch commands wrap around the end of the buffer")call <SID>BinOptionG("ws", &ws)call append("$", "incsearch\tshow match for partly typed search command")call <SID>BinOptionG("is", &is)call append("$", "magic\tchange the way backslashes are used in search patterns")call <SID>BinOptionG("magic", &magic)call append("$", "ignorecase\tignore case when using a search pattern")call <SID>BinOptionG("ic", &ic)call append("$", "smartcase\toverride 'ignorecase' when pattern has upper case characters")call <SID>BinOptionG("scs", &scs)call append("$", "casemap\tWhat method to use for changing case of letters")call <SID>OptionG("cmp", &cmp)call append("$", "maxmempattern\tmaximum amount of memory in Kbyte used for pattern matching")call append("$", " \tset mmp=" . &mmp)call append("$", "define\tpattern for a macro definition line")call append("$", "\t(global or local to buffer)")call <SID>OptionG("def", &def)if has("find_in_path")  call append("$", "include\tpattern for an include-file line")  call append("$", "\t(local to buffer)")  call <SID>OptionL("inc")  call append("$", "includeexpr\texpression used to transform an include line to a file name")  call append("$", "\t(local to buffer)")  call <SID>OptionL("inex")endif  call <SID>Header("tags")call append("$", "tagbsearch\tuse binary searching in tags files")call <SID>BinOptionG("tbs", &tbs)call append("$", "taglength\tnumber of significant characters in a tag name or zero")call append("$", " \tset tl=" . &tl)call append("$", "tags\tlist of file names to search for tags")call append("$", "\t(global or local to buffer)")call <SID>OptionG("tag", &tag)call append("$", "tagrelative\tfile names in a tags file are relative to the tags file")call <SID>BinOptionG("tr", &tr)call append("$", "tagstack\ta :tag command will use the tagstack")call <SID>BinOptionG("tgst", &tgst)call append("$", "showfulltag\twhen completing tags in Insert mode show more info")call <SID>BinOptionG("sft", &sft)if has("cscope")  call append("$", "cscopeprg\tcommand for executing cscope")  call <SID>OptionG("csprg", &csprg)  call append("$", "cscopetag\tuse cscope for tag commands")  call <SID>BinOptionG("cst", &cst)  call append("$", "cscopetagorder\t0 or 1; the order in which \":cstag\" performs a search")  call append("$", " \tset csto=" . &csto)  call append("$", "cscopeverbose\tgive messages when adding a cscope database")  call <SID>BinOptionG("csverb", &csverb)  call append("$", "cscopepathcomp\thow many components of the path to show")  call append("$", " \tset cspc=" . &cspc)  call append("$", "cscopequickfix\tWhen to open a quickfix window for cscope")  call <SID>OptionG("csqf", &csqf)endif  call <SID>Header("displaying text")call append("$", "scroll\tnumber of lines to scroll for CTRL-U and CTRL-D")call append("$", "\t(local to window)")call <SID>OptionL("scr")call append("$", "scrolloff\tnumber of screen lines to show around the cursor")call append("$", " \tset so=" . &so)call append("$", "wrap\tlong lines wrap")call <SID>BinOptionG("wrap", &wrap)call append("$", "linebreak\twrap long lines at a character in 'breakat'")call append("$", "\t(local to window)")call <SID>BinOptionL("lbr")call append("$", "breakat\twhich characters might cause a line break")call <SID>OptionG("brk", &brk)call append("$", "showbreak\tstring to put before wrapped screen lines")call <SID>OptionG("sbr", &sbr)call append("$", "sidescroll\tminimal number of columns to scroll horizontally")call append("$", " \tset ss=" . &ss)call append("$", "sidescrolloff\tminimal number of columns to keep left and right of the cursor")call append("$", " \tset siso=" . &siso)call append("$", "display\tinclude \"lastline\" to show the last line even if it doesn't fit")call append("$", "\tinclude \"uhex\" to show unprintable characters as a hex number")call <SID>OptionG("dy", &dy)call append("$", "fillchars\tcharacters to use for the status line, folds and filler lines")call <SID>OptionG("fcs", &fcs)call append("$", "cmdheight\tnumber of lines used for the command-line")call append("$", " \tset ch=" . &ch)call append("$", "columns\twidth of the display")call append("$", " \tset co=" . &co)call append("$", "lines\tnumber of lines in the display")call append("$", " \tset lines=" . &lines)call append("$", "lazyredraw\tdon't redraw while executing macros")call <SID>BinOptionG("lz", &lz)call append("$", "writedelay\tdelay in msec for each char written to the display")call append("$", "\t(for debugging)")call append("$", " \tset wd=" . &wd)call append("$", "list\tshow <Tab> as ^I and end-of-line as $")call append("$", "\t(local to window)")call <SID>BinOptionL("list")call append("$", "listchars\tlist of strings used for list mode")call <SID>OptionG("lcs", &lcs)call append("$", "number\tshow the line number for each line")call append("$", "\t(local to window)")call <SID>BinOptionL("nu")if has("linebreak")  call append("$", "numberwidth\tnumber of columns to use for the line number")  call append("$", "\t(local to window)")  call <SID>OptionL("nuw")endif  call <SID>Header("syntax, highlighting and spelling")call append("$", "background\t\"dark\" or \"light\"; the background color brightness")call <SID>OptionG("bg", &bg)if has("autocmd")  call append("$", "filetype\ttype of file; triggers the FileType event when set")  call append("$", "\t(local to buffer)")  call <SID>OptionL("ft")endifif has("syntax")  call append("$", "syntax\tname of syntax highlighting used")  call append("$", "\t(local to buffer)")  call <SID>OptionL("syn")  call append("$", "synmaxcol\tmaximum column to look for syntax items")  call append("$", "\t(local to buffer)")  call <SID>OptionL("smc")endifcall append("$", "highlight\twhich highlighting to use for various occasions")call <SID>OptionG("hl", &hl)call append("$", "hlsearch\thighlight all matches for the last used search pattern")call <SID>BinOptionG("hls", &hls)if has("syntax")  call append("$", "cursorcolumn\thighlight the screen column of the cursor")  call append("$", "\t(local to window)")  call <SID>BinOptionL("cuc")  call append("$", "cursorline\thighlight the screen line of the cursor")  call append("$", "\t(local to window)")  call <SID>BinOptionL("cul")  call append("$", "spell\thighlight spelling mistakes")  call append("$", "\t(local to window)")  call <SID>BinOptionL("spell")  call append("$", "spelllang\tlist of accepted languages")  call append("$", "\t(local to buffer)")  call <SID>OptionL("spl")  call append("$", "spellfile\tfile that \"zg\" adds good words to")  call append("$", "\t(local to buffer)")  call <SID>OptionL("spf")  call append("$", "spellcapcheck\tpattern to locate the end of a sentence")  call append("$", "\t(local to buffer)")  call <SID>OptionL("spc")  call append("$", "spellsuggest\tmethods used to suggest corrections")  call <SID>OptionG("sps", &sps)  call append("$", "mkspellmem\tamount of memory used by :mkspell before compressing")  call <SID>OptionG("msm", &msm)endif  call <SID>Header("multiple windows")call append("$", "laststatus\t0, 1 or 2; when to use a status line for the last window")call append("$", " \tset ls=" . &ls)if has("statusline")  call append("$", "statusline\talternate format to be used for a status line")  call <SID>OptionG("stl", &stl)endifcall append("$", "equalalways\tmake all windows the same size when adding/removing windows")call <SID>BinOptionG("ea", &ea)if has("vertsplit")  call append("$", "eadirection\tin which direction 'equalalways' works: \"ver\", \"hor\" or \"both\"")  call <SID>OptionG("ead", &ead)endifcall append("$", "winheight\tminimal number of lines used for the current window")call append("$", " \tset wh=" . &wh)call append("$", "winminheight\tminimal number of lines used for any window")call append("$", " \tset wmh=" . &wmh)call append("$", "winfixheight\tkeep the height of the window")call append("$", "\t(local to window)")call <SID>BinOptionL("wfh")if has("vertsplit")call append("$", "winfixwidth\tkeep the width of the window")call append("$", "\t(local to window)")call <SID>BinOptionL("wfw")  call append("$", "winwidth\tminimal number of columns used for the current window")  call append("$", " \tset wiw=" . &wiw)  call append("$", "winminwidth\tminimal number of columns used for any window")  call append("$", " \tset wmw=" . &wmw)endifcall append("$", "helpheight\tinitial height of the help window")call append("$", " \tset hh=" . &hh)if has("quickfix")  call append("$", "previewheight\tdefault height for the preview window")  call append("$", " \tset pvh=" . &pvh)  call append("$", "previewwindow\tidentifies the preview window")  call append("$", "\t(local to window)")  call <SID>BinOptionL("pvw")endifcall append("$", "hidden\tdon't unload a buffer when no longer shown in a window")call <SID>BinOptionG("hid", &hid)call append("$", "switchbuf\t\"useopen\" and/or \"split\"; which window to use when jumping")call append("$", "\tto a buffer")call <SID>OptionG("swb", &swb)call append("$", "splitbelow\ta new window is put below the current one")call <SID>BinOptionG("sb", &sb)if has("vertsplit")  call append("$", "splitright\ta new window is put right of the current one")  call <SID>BinOptionG("spr", &spr)endifif has("scrollbind")  call append("$", "scrollbind\tthis window scrolls together with other bound windows")  call append("$", "\t(local to window)")  call <SID>BinOptionL("scb")  call append("$", "scrollopt\t\"ver\", \"hor\" and/or \"jump\"; list of options for 'scrollbind'")  call <SID>OptionG("sbo", &sbo)endif  call <SID>Header("multiple tab pages")call append("$", "showtabline\t0, 1 or 2; when to use a tab pages line")call append("$", " \tset stal=" . &stal)call append("$", "tabpagemax\tmaximum number of tab pages to open for -p and \"tab all\"")call append("$", " \tset tpm=" . &tpm)call append("$", "tabline\tcustom tab pages line")call <SID>OptionG("tal", &tal)if has("gui")  call append("$", "guitablabel\tcustom tab page label for the GUI")  call <SID>OptionG("gtl", &gtl)  call append("$", "guitabtooltip\tcustom tab page tooltip for the GUI")  call <SID>OptionG("gtt", &gtt)endif  call <SID>Header("terminal")call append("$", "term\tname of the used terminal")call <SID>OptionG("term", &term)call append("$", "ttytype\talias for 'term'")call <SID>OptionG("tty", &tty)call append("$", "ttybuiltin\tcheck built-in termcaps first")call <SID>BinOptionG("tbi", &tbi)call append("$", "ttyfast\tterminal connection is fast")call <SID>BinOptionG("tf", &tf)call append("$", "weirdinvert\tterminal that requires extra redrawing")call <SID>BinOptionG("wiv", &wiv)

Lines 1–500 of 1308.