Submitted By: Bruce Dubbs Date: 2012-05-20 Initial Package Version: 7.3 Upstream Status: Already in upstream patch repo Origin: Upstream Description: This patch contains upstream patch numbers 1 thru 524. diff -Naur vim73.orig/Filelist vim73.patched/Filelist --- vim73.orig/Filelist 2010-08-07 06:04:57.000000000 -0500 +++ vim73.patched/Filelist 2012-05-20 12:55:42.000000000 -0500 @@ -39,6 +39,7 @@ src/mark.c \ src/mbyte.c \ src/memfile.c \ + src/memfile_test.c \ src/memline.c \ src/menu.c \ src/message.c \ @@ -80,6 +81,7 @@ src/testdir/test[0-9]*.ok \ src/testdir/test49.vim \ src/testdir/test60.vim \ + src/testdir/test83-tags? \ src/proto.h \ src/proto/blowfish.pro \ src/proto/buffer.pro \ @@ -261,6 +263,7 @@ src/bigvim.bat \ src/msvcsetup.bat \ src/msvc2008.bat \ + src/msvc2010.bat \ src/dimm.idl \ src/dlldata.c \ src/dosinst.c \ @@ -311,6 +314,7 @@ src/xxd/Make_bc5.mak \ src/xxd/Make_cyg.mak \ src/xxd/Make_djg.mak \ + src/xxd/Make_ming.mak \ src/xxd/Make_mvc.mak \ nsis/gvim.nsi \ nsis/README.txt \ @@ -426,9 +430,6 @@ $(SRC_VMS) \ README_os390.txt \ src/Make_mint.mak \ - src/Make_ro.mak \ - src/gui_riscos.c \ - src/gui_riscos.h \ src/if_sniff.c \ src/infplist.xml \ src/link.390 \ @@ -436,10 +437,6 @@ src/os_beos.h \ src/os_beos.rsrc \ src/os_mint.h \ - src/os_riscos.c \ - src/os_riscos.h \ - src/proto/gui_riscos.pro \ - src/proto/os_riscos.pro \ src/os_vms_fix.com \ src/toolbar.phi \ @@ -686,6 +683,8 @@ runtime/tutor/tutor.utf-8 \ runtime/tutor/tutor.?? \ runtime/tutor/tutor.??.* \ + runtime/tutor/tutor.bar \ + runtime/tutor/tutor.bar.* \ runtime/spell/README.txt \ runtime/spell/??/*.diff \ runtime/spell/??/main.aap \ diff -Naur vim73.orig/Makefile vim73.patched/Makefile --- vim73.orig/Makefile 2010-08-15 07:23:34.000000000 -0500 +++ vim73.patched/Makefile 2012-05-20 12:55:41.000000000 -0500 @@ -23,6 +23,9 @@ # has run can result in compiling with $(CC) empty. first: + @if test ! -f src/auto/config.mk; then \ + cp src/config.mk.dist src/auto/config.mk; \ + fi @echo "Starting make in the src directory." @echo "If there are problems, cd to the src directory and run make there" cd src && $(MAKE) $@ @@ -30,6 +33,9 @@ # Some make programs use the last target for the $@ default; put the other # targets separately to always let $@ expand to "first" by default. all install uninstall tools config configure reconfig proto depend lint tags types test testclean clean distclean: + @if test ! -f src/auto/config.mk; then \ + cp src/config.mk.dist src/auto/config.mk; \ + fi @echo "Starting make in the src directory." @echo "If there are problems, cd to the src directory and run make there" cd src && $(MAKE) $@ diff -Naur vim73.orig/README_extra.txt vim73.patched/README_extra.txt --- vim73.orig/README_extra.txt 2010-08-15 07:23:19.000000000 -0500 +++ vim73.patched/README_extra.txt 2012-05-20 12:55:41.000000000 -0500 @@ -13,9 +13,6 @@ src/os_amiga.* Files for the Amiga port. -src/gui_riscos.* -src/os_riscos.* Files for the RISC OS port. - src/gui_beos.* src/os_beos.* Files for the BeOS port. diff -Naur vim73.orig/runtime/doc/autocmd.txt vim73.patched/runtime/doc/autocmd.txt --- vim73.orig/runtime/doc/autocmd.txt 2010-08-15 07:23:19.000000000 -0500 +++ vim73.patched/runtime/doc/autocmd.txt 2012-05-20 12:55:43.000000000 -0500 @@ -299,6 +299,8 @@ |InsertEnter| starting Insert mode |InsertChange| when typing while in Insert or Replace mode |InsertLeave| when leaving Insert mode +|InsertCharPre| when a character was typed in Insert mode, before + inserting it |ColorScheme| after loading a color scheme @@ -657,6 +659,17 @@ indicates the new mode. Be careful not to move the cursor or do anything else that the user does not expect. + *InsertCharPre* +InsertCharPre When a character is typed in Insert mode, + before inserting the char. + The |v:char| variable indicates the char typed + and can be changed during the event to insert + a different character. When |v:char| is set + to more than one character this text is + inserted literally. + It is not allowed to change the text |textlock|. + The event is not triggered when 'paste' is + set. *InsertEnter* InsertEnter Just before starting Insert mode. Also for Replace mode and Virtual Replace mode. The @@ -682,7 +695,10 @@ QuickFixCmdPre Before a quickfix command is run (|:make|, |:lmake|, |:grep|, |:lgrep|, |:grepadd|, |:lgrepadd|, |:vimgrep|, |:lvimgrep|, - |:vimgrepadd|, |:lvimgrepadd|, |:cscope|). + |:vimgrepadd|, |:lvimgrepadd|, |:cscope|, + |:cfile|, |:cgetfile|, |:caddfile|, |:lfile|, + |:lgetfile|, |:laddfile|, |:helpgrep|, + |:lhelpgrep|). The pattern is matched against the command being run. When |:grep| is used but 'grepprg' is set to "internal" it still matches "grep". @@ -693,7 +709,10 @@ *QuickFixCmdPost* QuickFixCmdPost Like QuickFixCmdPre, but after a quickfix command is run, before jumping to the first - location. See |QuickFixCmdPost-example|. + location. For |:cfile| and |:lfile| commands + it is run after error file is read and before + moving to the first error. + See |QuickFixCmdPost-example|. *RemoteReply* RemoteReply When a reply from a Vim that functions as server was received |server2client()|. The @@ -1051,14 +1070,17 @@ argument is included, Vim executes only the matching autocommands for that group. Note: if you use an undefined group name, Vim gives you an error message. - + ** After applying the autocommands the modelines are processed, so that their settings overrule the settings from autocommands, like what happens when - editing a file. + editing a file. This is skipped when the + argument is present. You probably want to use + for events that are not used when loading + a buffer, such as |User|. *:doautoa* *:doautoall* -:doautoa[ll] [group] {event} [fname] +:doautoa[ll] [] [group] {event} [fname] Like ":doautocmd", but apply the autocommands to each loaded buffer. Note that [fname] is used to select the autocommands, not the buffers to which they are diff -Naur vim73.orig/runtime/doc/change.txt vim73.patched/runtime/doc/change.txt --- vim73.orig/runtime/doc/change.txt 2010-08-15 07:23:19.000000000 -0500 +++ vim73.patched/runtime/doc/change.txt 2012-05-20 12:55:41.000000000 -0500 @@ -916,8 +916,10 @@ {Visual}["x]Y Yank the highlighted lines [into register x] (for {Visual} see |Visual-mode|). {not in Vi} - *:y* *:yank* -:[range]y[ank] [x] Yank [range] lines [into register x]. + *:y* *:yank* *E850* +:[range]y[ank] [x] Yank [range] lines [into register x]. Yanking to the + "* or "+ registers is possible only in GUI versions or + when the |+xterm_clipboard| feature is included. :[range]y[ank] [x] {count} Yank {count} lines, starting with last line number diff -Naur vim73.orig/runtime/doc/cmdline.txt vim73.patched/runtime/doc/cmdline.txt --- vim73.orig/runtime/doc/cmdline.txt 2010-08-15 07:23:19.000000000 -0500 +++ vim73.patched/runtime/doc/cmdline.txt 2012-05-20 12:55:43.000000000 -0500 @@ -330,12 +330,12 @@ :his[tory] [{name}] [{first}][, [{last}]] List the contents of history {name} which can be: - c[md] or : command-line history - s[earch] or / search string history - e[xpr] or = expression register history - i[nput] or @ input line history - d[ebug] or > debug command history - a[ll] all of the above + c[md] or : command-line history + s[earch] or / or ? search string history + e[xpr] or = expression register history + i[nput] or @ input line history + d[ebug] or > debug command history + a[ll] all of the above {not in Vi} If the numbers {first} and/or {last} are given, the respective diff -Naur vim73.orig/runtime/doc/diff.txt vim73.patched/runtime/doc/diff.txt --- vim73.orig/runtime/doc/diff.txt 2010-08-15 07:23:20.000000000 -0500 +++ vim73.patched/runtime/doc/diff.txt 2012-05-20 12:55:43.000000000 -0500 @@ -178,7 +178,7 @@ nodiff" before hiding it. *:diffu* *:diffupdate* -:diffu[pdate] Update the diff highlighting and folds. +:diffu[pdate][!] Update the diff highlighting and folds. Vim attempts to keep the differences updated when you make changes to the text. This mostly takes care of inserted and deleted lines. Changes within a @@ -187,6 +187,9 @@ :diffupdate +If the ! is included Vim will check if the file was changed externally and +needs to be reloaded. It will prompt for each changed file, like `:checktime` +was used. Vim will show filler lines for lines that are missing in one window but are present in another. These lines were inserted in another file or deleted in diff -Naur vim73.orig/runtime/doc/eval.txt vim73.patched/runtime/doc/eval.txt --- vim73.orig/runtime/doc/eval.txt 2010-08-15 07:23:20.000000000 -0500 +++ vim73.patched/runtime/doc/eval.txt 2012-05-20 12:55:43.000000000 -0500 @@ -798,11 +798,12 @@ For |Lists| only "+" is possible and then both expr6 must be a list. The result is a new list with the two lists Concatenated. -expr7 * expr7 .. number multiplication *expr-star* -expr7 / expr7 .. number division *expr-/* -expr7 % expr7 .. number modulo *expr-%* +expr7 * expr7 .. Number multiplication *expr-star* +expr7 / expr7 .. Number division *expr-/* +expr7 % expr7 .. Number modulo *expr-%* For all, except ".", Strings are converted to Numbers. +For bitwise operators see |and()|, |or()| and |xor()|. Note the difference between "+" and ".": "123" + "456" = 579 @@ -1291,6 +1292,7 @@ *v:char* *char-variable* v:char Argument for evaluating 'formatexpr' and used for the typed character when using in an abbreviation |:map-|. + It is also used by the |InsertPreChar| event. *v:charconvert_from* *charconvert_from-variable* v:charconvert_from @@ -1657,6 +1659,15 @@ *v:warningmsg* *warningmsg-variable* v:warningmsg Last given warning message. It's allowed to set this variable. + *v:windowid* *windowid-variable* +v:windowid When any X11 based GUI is running or when running in a + terminal and Vim connects to the X server (|-X|) this will be + set to the window ID. + When an MS-Windows GUI is running this will be set to the + window handle. + Otherwise the value is zero. + Note: for windows inside Vim use |winnr()|. + ============================================================================== 4. Builtin Functions *functions* @@ -1669,6 +1680,7 @@ abs( {expr}) Float or Number absolute value of {expr} acos( {expr}) Float arc cosine of {expr} add( {list}, {item}) List append {item} to |List| {list} +and( {expr}, {expr}) Number bitwise AND append( {lnum}, {string}) Number append {string} below line {lnum} append( {lnum}, {list}) Number append lines {list} below line {lnum} argc() Number number of files in the argument list @@ -1726,7 +1738,8 @@ extend( {expr1}, {expr2} [, {expr3}]) List/Dict insert items of {expr2} into {expr1} exp( {expr}) Float exponential of {expr} -expand( {expr} [, {flag}]) String expand special keywords in {expr} +expand( {expr} [, {nosuf} [, {list}]]) + any expand special keywords in {expr} feedkeys( {string} [, {mode}]) Number add key sequence to typeahead buffer filereadable( {file}) Number TRUE if {file} is a readable file filewritable( {file}) Number TRUE if {file} is a writable file @@ -1780,7 +1793,8 @@ getwinposx() Number X coord in pixels of GUI Vim window getwinposy() Number Y coord in pixels of GUI Vim window getwinvar( {nr}, {varname}) any variable {varname} in window {nr} -glob( {expr} [, {flag}]) String expand file wildcards in {expr} +glob( {expr} [, {nosuf} [, {list}]]) + any expand file wildcards in {expr} globpath( {path}, {expr} [, {flag}]) String do glob({expr}) for all dirs in {path} has( {feature}) Number TRUE if feature {feature} supported @@ -1807,6 +1821,7 @@ inputsave() Number save and clear typeahead inputsecret( {prompt} [, {text}]) String like input() but hiding the text insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}] +invert( {expr}) Number bitwise invert isdirectory( {directory}) Number TRUE if {directory} is a directory islocked( {expr}) Number TRUE if {expr} is locked items( {dict}) List key-value pairs in {dict} @@ -1822,7 +1837,7 @@ log( {expr}) Float natural logarithm (base e) of {expr} log10( {expr}) Float logarithm of Float {expr} to base 10 map( {expr}, {string}) List/Dict change each item in {expr} to {expr} -maparg( {name}[, {mode} [, {abbr}]]) +maparg( {name}[, {mode} [, {abbr} [, {dict}]]]) String rhs of mapping {name} in mode {mode} mapcheck( {name}[, {mode} [, {abbr}]]) String check for mappings matching {name} @@ -1846,6 +1861,7 @@ mzeval( {expr}) any evaluate |MzScheme| expression nextnonblank( {lnum}) Number line nr of non-blank line >= {lnum} nr2char( {expr}) String single char with ASCII value {expr} +or( {expr}, {expr}) Number bitwise OR pathshorten( {expr}) String shorten directory names in a path pow( {x}, {y}) Float {x} to the power of {y} prevnonblank( {lnum}) Number line nr of non-blank line <= {lnum} @@ -1904,7 +1920,8 @@ simplify( {filename}) String simplify filename as much as possible sin( {expr}) Float sine of {expr} sinh( {expr}) Float hyperbolic sine of {expr} -sort( {list} [, {func}]) List sort {list}, using {func} to compare +sort( {list} [, {func} [, {dict}]]) + List sort {list}, using {func} to compare soundfold( {word}) String sound-fold {word} spellbadword() String badly spelled word at cursor spellsuggest( {word} [, {max} [, {capital}]]) @@ -1967,6 +1984,7 @@ winwidth( {nr}) Number width of window {nr} writefile( {list}, {fname} [, {binary}]) Number write list of lines to file {fname} +xor( {expr}, {expr}) Number bitwise XOR abs({expr}) *abs()* Return the absolute value of {expr}. When {expr} evaluates to @@ -2006,6 +2024,13 @@ Use |insert()| to add an item at another position. +and({expr}, {expr}) *and()* + Bitwise AND on the two arguments. The arguments are converted + to a number. A List, Dict or Float argument causes an error. + Example: > + :let flag = and(bits, 0x80) + + append({lnum}, {expr}) *append()* When {expr} is a |List|: Append each item of the |List| as a text line below line {lnum} in the current buffer. @@ -2708,13 +2733,15 @@ {only available when compiled with the |+float| feature} -expand({expr} [, {flag}]) *expand()* +expand({expr} [, {nosuf} [, {list}]]) *expand()* Expand wildcards and the following special keywords in {expr}. - The result is a String. + 'wildignorecase' applies. - When there are several matches, they are separated by - characters. [Note: in version 5.0 a space was used, which - caused problems when a file name contains a space] + If {list} is given and it is non-zero, a List will be returned. + Otherwise the result is a String and when there are several + matches, they are separated by characters. [Note: in + version 5.0 a space was used, which caused problems when a + file name contains a space] If the expansion fails, the result is an empty string. A name for a non-existing file is not included. @@ -2731,6 +2758,7 @@ autocmd buffer number (as a String!) autocmd matched name sourced script file name + sourced script file line number word under the cursor WORD under the cursor the {clientid} of the last received @@ -2767,10 +2795,10 @@ When {expr} does not start with '%', '#' or '<', it is expanded like a file name is expanded on the command line. 'suffixes' and 'wildignore' are used, unless the optional - {flag} argument is given and it is non-zero. Names for - non-existing files are included. The "**" item can be used to - search in a directory tree. For example, to find all "README" - files in the current directory and below: > + {nosuf} argument is given and it is non-zero. + Names for non-existing files are included. The "**" item can + be used to search in a directory tree. For example, to find + all "README" files in the current directory and below: > :echo expand("**/README") < Expand() can also be used to expand variables and environment @@ -3414,17 +3442,23 @@ :let list_is_on = getwinvar(2, '&list') :echo "myvar = " . getwinvar(1, 'myvar') < -glob({expr} [, {flag}]) *glob()* +glob({expr} [, {nosuf} [, {list}]]) *glob()* Expand the file wildcards in {expr}. See |wildcards| for the use of special characters. - The result is a String. - When there are several matches, they are separated by - characters. - Unless the optional {flag} argument is given and is non-zero, + + Unless the optional {nosuf} argument is given and is non-zero, the 'suffixes' and 'wildignore' options apply: Names matching one of the patterns in 'wildignore' will be skipped and 'suffixes' affect the ordering of matches. - If the expansion fails, the result is an empty string. + 'wildignorecase' always applies. + + When {list} is present and it is non-zero the result is a List + with all matching files. The advantage of using a List is, + you also get filenames containing newlines correctly. + Otherwise the result is a String and when there are several + matches, they are separated by characters. + + If the expansion fails, the result is an empty String or List. A name for a non-existing file is not included. For most systems backticks can be used to get files names from @@ -3759,6 +3793,11 @@ Note that when {item} is a |List| it is inserted as a single item. Use |extend()| to concatenate |Lists|. +invert({expr}) *invert()* + Bitwise invert. The argument is converted to a number. A + List, Dict or Float argument causes an error. Example: > + :let bits = invert(bits) + isdirectory({directory}) *isdirectory()* The result is a Number, which is non-zero when a directory with the name {directory} exists. If {directory} doesn't @@ -3966,23 +4005,51 @@ further items in {expr} are processed. -maparg({name}[, {mode} [, {abbr}]]) *maparg()* - Return the rhs of mapping {name} in mode {mode}. When there - is no mapping for {name}, an empty String is returned. +maparg({name}[, {mode} [, {abbr} [, {dict}]]]) *maparg()* + When {dict} is omitted or zero: Return the rhs of mapping + {name} in mode {mode}. The returned String has special + characters translated like in the output of the ":map" command + listing. + + When there is no mapping for {name}, an empty String is + returned. + + The {name} can have special key names, like in the ":map" + command. + {mode} can be one of these strings: "n" Normal - "v" Visual + "v" Visual (including Select) "o" Operator-pending "i" Insert "c" Cmd-line + "s" Select + "x" Visual "l" langmap |language-mapping| "" Normal, Visual and Operator-pending When {mode} is omitted, the modes for "" are used. + When {abbr} is there and it is non-zero use abbreviations instead of mappings. - The {name} can have special key names, like in the ":map" - command. The returned String has special characters - translated like in the output of the ":map" command listing. + + When {dict} is there and it is non-zero return a dictionary + containing all the information of the mapping with the + following items: + "lhs" The {lhs} of the mapping. + "rhs" The {rhs} of the mapping as typed. + "silent" 1 for a |:map-silent| mapping, else 0. + "noremap" 1 if the {rhs} of the mapping is remappable. + "expr" 1 for an expression mapping (|:map-|). + "buffer" 1 for a buffer local mapping (|:map-local|). + "mode" Modes for which the mapping is defined. In + addition to the modes mentioned above, these + characters will be used: + " " Normal, Visual and Operator-pending + "!" Insert and Commandline mode + (|mapmpde-ic|) + "sid" the Script local ID, used for mappings + (||) + The mappings local to the current buffer are checked first, then the global mappings. This function can be used to map a key even when it's already @@ -4295,6 +4362,13 @@ call setpos('.', save_cursor) < Also see |setpos()|. +or({expr}, {expr}) *or()* + Bitwise OR on the two arguments. The arguments are converted + to a number. A List, Dict or Float argument causes an error. + Example: > + :let bits = or(bits, 0x80) + + pathshorten({expr}) *pathshorten()* Shorten directory names in the path {expr} and return the result. The tail, the file name, is kept as-is. The other @@ -5228,7 +5302,7 @@ {only available when compiled with the |+float| feature} -sort({list} [, {func}]) *sort()* *E702* +sort({list} [, {func} [, {dict}]]) *sort()* *E702* Sort the items in {list} in-place. Returns {list}. If you want a list to remain unmodified make a copy first: > :let sortedlist = sort(copy(mylist)) @@ -5236,6 +5310,8 @@ Numbers sort after Strings, |Lists| after Numbers. For sorting text in the current buffer use |:sort|. When {func} is given and it is one then case is ignored. + {dict} is for functions with the "dict" attribute. It will be + used to set the local variable "self". |Dictionary-function| When {func} is a |Funcref| or a function name, this function is called to compare items. The function is invoked with two items as argument and must return zero if they are equal, 1 or @@ -6056,7 +6132,15 @@ To copy a file byte for byte: > :let fl = readfile("foo", "b") :call writefile(fl, "foocopy", "b") -< + + +xor({expr}, {expr}) *xor()* + Bitwise XOR on the two arguments. The arguments are converted + to a number. A List, Dict or Float argument causes an error. + Example: > + :let bits = xor(bits, 0x80) + + *feature-list* There are three types of features: diff -Naur vim73.orig/runtime/doc/eval.txt.orig vim73.patched/runtime/doc/eval.txt.orig --- vim73.orig/runtime/doc/eval.txt.orig 1969-12-31 18:00:00.000000000 -0600 +++ vim73.patched/runtime/doc/eval.txt.orig 2012-05-20 12:55:41.000000000 -0500 @@ -0,0 +1,8362 @@ +*eval.txt* For Vim version 7.3. Last change: 2010 Aug 15 + + + VIM REFERENCE MANUAL by Bram Moolenaar + + +Expression evaluation *expression* *expr* *E15* *eval* + +Using expressions is introduced in chapter 41 of the user manual |usr_41.txt|. + +Note: Expression evaluation can be disabled at compile time. If this has been +done, the features in this document are not available. See |+eval| and +|no-eval-feature|. + +1. Variables |variables| + 1.1 Variable types + 1.2 Function references |Funcref| + 1.3 Lists |Lists| + 1.4 Dictionaries |Dictionaries| + 1.5 More about variables |more-variables| +2. Expression syntax |expression-syntax| +3. Internal variable |internal-variables| +4. Builtin Functions |functions| +5. Defining functions |user-functions| +6. Curly braces names |curly-braces-names| +7. Commands |expression-commands| +8. Exception handling |exception-handling| +9. Examples |eval-examples| +10. No +eval feature |no-eval-feature| +11. The sandbox |eval-sandbox| +12. Textlock |textlock| + +{Vi does not have any of these commands} + +============================================================================== +1. Variables *variables* + +1.1 Variable types ~ + *E712* +There are six types of variables: + +Number A 32 bit signed number. |expr-number| *Number* + Examples: -123 0x10 0177 + +Float A floating point number. |floating-point-format| *Float* + {only when compiled with the |+float| feature} + Examples: 123.456 1.15e-6 -1.1e3 + +String A NUL terminated string of 8-bit unsigned characters (bytes). + |expr-string| Examples: "ab\txx\"--" 'x-z''a,c' + +Funcref A reference to a function |Funcref|. + Example: function("strlen") + +List An ordered sequence of items |List|. + Example: [1, 2, ['a', 'b']] + +Dictionary An associative, unordered array: Each entry has a key and a + value. |Dictionary| + Example: {'blue': "#0000ff", 'red': "#ff0000"} + +The Number and String types are converted automatically, depending on how they +are used. + +Conversion from a Number to a String is by making the ASCII representation of +the Number. Examples: > + Number 123 --> String "123" + Number 0 --> String "0" + Number -1 --> String "-1" + *octal* +Conversion from a String to a Number is done by converting the first digits +to a number. Hexadecimal "0xf9" and Octal "017" numbers are recognized. If +the String doesn't start with digits, the result is zero. Examples: > + String "456" --> Number 456 + String "6bar" --> Number 6 + String "foo" --> Number 0 + String "0xf1" --> Number 241 + String "0100" --> Number 64 + String "-8" --> Number -8 + String "+8" --> Number 0 + +To force conversion from String to Number, add zero to it: > + :echo "0100" + 0 +< 64 ~ + +To avoid a leading zero to cause octal conversion, or for using a different +base, use |str2nr()|. + +For boolean operators Numbers are used. Zero is FALSE, non-zero is TRUE. + +Note that in the command > + :if "foo" +"foo" is converted to 0, which means FALSE. To test for a non-empty string, +use strlen(): > + :if strlen("foo") +< *E745* *E728* *E703* *E729* *E730* *E731* +List, Dictionary and Funcref types are not automatically converted. + + *E805* *E806* *E808* +When mixing Number and Float the Number is converted to Float. Otherwise +there is no automatic conversion of Float. You can use str2float() for String +to Float, printf() for Float to String and float2nr() for Float to Number. + + *E706* *sticky-type-checking* +You will get an error if you try to change the type of a variable. You need +to |:unlet| it first to avoid this error. String and Number are considered +equivalent though, as well are Float and Number. Consider this sequence of +commands: > + :let l = "string" + :let l = 44 " changes type from String to Number + :let l = [1, 2, 3] " error! l is still a Number + :let l = 4.4 " changes type from Number to Float + :let l = "string" " error! + + +1.2 Function references ~ + *Funcref* *E695* *E718* +A Funcref variable is obtained with the |function()| function. It can be used +in an expression in the place of a function name, before the parenthesis +around the arguments, to invoke the function it refers to. Example: > + + :let Fn = function("MyFunc") + :echo Fn() +< *E704* *E705* *E707* +A Funcref variable must start with a capital, "s:", "w:", "t:" or "b:". You +cannot have both a Funcref variable and a function with the same name. + +A special case is defining a function and directly assigning its Funcref to a +Dictionary entry. Example: > + :function dict.init() dict + : let self.val = 0 + :endfunction + +The key of the Dictionary can start with a lower case letter. The actual +function name is not used here. Also see |numbered-function|. + +A Funcref can also be used with the |:call| command: > + :call Fn() + :call dict.init() + +The name of the referenced function can be obtained with |string()|. > + :let func = string(Fn) + +You can use |call()| to invoke a Funcref and use a list variable for the +arguments: > + :let r = call(Fn, mylist) + + +1.3 Lists ~ + *List* *Lists* *E686* +A List is an ordered sequence of items. An item can be of any type. Items +can be accessed by their index number. Items can be added and removed at any +position in the sequence. + + +List creation ~ + *E696* *E697* +A List is created with a comma separated list of items in square brackets. +Examples: > + :let mylist = [1, two, 3, "four"] + :let emptylist = [] + +An item can be any expression. Using a List for an item creates a +List of Lists: > + :let nestlist = [[11, 12], [21, 22], [31, 32]] + +An extra comma after the last item is ignored. + + +List index ~ + *list-index* *E684* +An item in the List can be accessed by putting the index in square brackets +after the List. Indexes are zero-based, thus the first item has index zero. > + :let item = mylist[0] " get the first item: 1 + :let item = mylist[2] " get the third item: 3 + +When the resulting item is a list this can be repeated: > + :let item = nestlist[0][1] " get the first list, second item: 12 +< +A negative index is counted from the end. Index -1 refers to the last item in +the List, -2 to the last but one item, etc. > + :let last = mylist[-1] " get the last item: "four" + +To avoid an error for an invalid index use the |get()| function. When an item +is not available it returns zero or the default value you specify: > + :echo get(mylist, idx) + :echo get(mylist, idx, "NONE") + + +List concatenation ~ + +Two lists can be concatenated with the "+" operator: > + :let longlist = mylist + [5, 6] + :let mylist += [7, 8] + +To prepend or append an item turn the item into a list by putting [] around +it. To change a list in-place see |list-modification| below. + + +Sublist ~ + +A part of the List can be obtained by specifying the first and last index, +separated by a colon in square brackets: > + :let shortlist = mylist[2:-1] " get List [3, "four"] + +Omitting the first index is similar to zero. Omitting the last index is +similar to -1. > + :let endlist = mylist[2:] " from item 2 to the end: [3, "four"] + :let shortlist = mylist[2:2] " List with one item: [3] + :let otherlist = mylist[:] " make a copy of the List + +If the first index is beyond the last item of the List or the second item is +before the first item, the result is an empty list. There is no error +message. + +If the second index is equal to or greater than the length of the list the +length minus one is used: > + :let mylist = [0, 1, 2, 3] + :echo mylist[2:8] " result: [2, 3] + +NOTE: mylist[s:e] means using the variable "s:e" as index. Watch out for +using a single letter variable before the ":". Insert a space when needed: +mylist[s : e]. + + +List identity ~ + *list-identity* +When variable "aa" is a list and you assign it to another variable "bb", both +variables refer to the same list. Thus changing the list "aa" will also +change "bb": > + :let aa = [1, 2, 3] + :let bb = aa + :call add(aa, 4) + :echo bb +< [1, 2, 3, 4] + +Making a copy of a list is done with the |copy()| function. Using [:] also +works, as explained above. This creates a shallow copy of the list: Changing +a list item in the list will also change the item in the copied list: > + :let aa = [[1, 'a'], 2, 3] + :let bb = copy(aa) + :call add(aa, 4) + :let aa[0][1] = 'aaa' + :echo aa +< [[1, aaa], 2, 3, 4] > + :echo bb +< [[1, aaa], 2, 3] + +To make a completely independent list use |deepcopy()|. This also makes a +copy of the values in the list, recursively. Up to a hundred levels deep. + +The operator "is" can be used to check if two variables refer to the same +List. "isnot" does the opposite. In contrast "==" compares if two lists have +the same value. > + :let alist = [1, 2, 3] + :let blist = [1, 2, 3] + :echo alist is blist +< 0 > + :echo alist == blist +< 1 + +Note about comparing lists: Two lists are considered equal if they have the +same length and all items compare equal, as with using "==". There is one +exception: When comparing a number with a string they are considered +different. There is no automatic type conversion, as with using "==" on +variables. Example: > + echo 4 == "4" +< 1 > + echo [4] == ["4"] +< 0 + +Thus comparing Lists is more strict than comparing numbers and strings. You +can compare simple values this way too by putting them in a list: > + + :let a = 5 + :let b = "5" + :echo a == b +< 1 > + :echo [a] == [b] +< 0 + + +List unpack ~ + +To unpack the items in a list to individual variables, put the variables in +square brackets, like list items: > + :let [var1, var2] = mylist + +When the number of variables does not match the number of items in the list +this produces an error. To handle any extra items from the list append ";" +and a variable name: > + :let [var1, var2; rest] = mylist + +This works like: > + :let var1 = mylist[0] + :let var2 = mylist[1] + :let rest = mylist[2:] + +Except that there is no error if there are only two items. "rest" will be an +empty list then. + + +List modification ~ + *list-modification* +To change a specific item of a list use |:let| this way: > + :let list[4] = "four" + :let listlist[0][3] = item + +To change part of a list you can specify the first and last item to be +modified. The value must at least have the number of items in the range: > + :let list[3:5] = [3, 4, 5] + +Adding and removing items from a list is done with functions. Here are a few +examples: > + :call insert(list, 'a') " prepend item 'a' + :call insert(list, 'a', 3) " insert item 'a' before list[3] + :call add(list, "new") " append String item + :call add(list, [1, 2]) " append a List as one new item + :call extend(list, [1, 2]) " extend the list with two more items + :let i = remove(list, 3) " remove item 3 + :unlet list[3] " idem + :let l = remove(list, 3, -1) " remove items 3 to last item + :unlet list[3 : ] " idem + :call filter(list, 'v:val !~ "x"') " remove items with an 'x' + +Changing the order of items in a list: > + :call sort(list) " sort a list alphabetically + :call reverse(list) " reverse the order of items + + +For loop ~ + +The |:for| loop executes commands for each item in a list. A variable is set +to each item in the list in sequence. Example: > + :for item in mylist + : call Doit(item) + :endfor + +This works like: > + :let index = 0 + :while index < len(mylist) + : let item = mylist[index] + : :call Doit(item) + : let index = index + 1 + :endwhile + +Note that all items in the list should be of the same type, otherwise this +results in error |E706|. To avoid this |:unlet| the variable at the end of +the loop. + +If all you want to do is modify each item in the list then the |map()| +function will be a simpler method than a for loop. + +Just like the |:let| command, |:for| also accepts a list of variables. This +requires the argument to be a list of lists. > + :for [lnum, col] in [[1, 3], [2, 8], [3, 0]] + : call Doit(lnum, col) + :endfor + +This works like a |:let| command is done for each list item. Again, the types +must remain the same to avoid an error. + +It is also possible to put remaining items in a List variable: > + :for [i, j; rest] in listlist + : call Doit(i, j) + : if !empty(rest) + : echo "remainder: " . string(rest) + : endif + :endfor + + +List functions ~ + *E714* +Functions that are useful with a List: > + :let r = call(funcname, list) " call a function with an argument list + :if empty(list) " check if list is empty + :let l = len(list) " number of items in list + :let big = max(list) " maximum value in list + :let small = min(list) " minimum value in list + :let xs = count(list, 'x') " count nr of times 'x' appears in list + :let i = index(list, 'x') " index of first 'x' in list + :let lines = getline(1, 10) " get ten text lines from buffer + :call append('$', lines) " append text lines in buffer + :let list = split("a b c") " create list from items in a string + :let string = join(list, ', ') " create string from list items + :let s = string(list) " String representation of list + :call map(list, '">> " . v:val') " prepend ">> " to each item + +Don't forget that a combination of features can make things simple. For +example, to add up all the numbers in a list: > + :exe 'let sum = ' . join(nrlist, '+') + + +1.4 Dictionaries ~ + *Dictionaries* *Dictionary* +A Dictionary is an associative array: Each entry has a key and a value. The +entry can be located with the key. The entries are stored without a specific +ordering. + + +Dictionary creation ~ + *E720* *E721* *E722* *E723* +A Dictionary is created with a comma separated list of entries in curly +braces. Each entry has a key and a value, separated by a colon. Each key can +only appear once. Examples: > + :let mydict = {1: 'one', 2: 'two', 3: 'three'} + :let emptydict = {} +< *E713* *E716* *E717* +A key is always a String. You can use a Number, it will be converted to a +String automatically. Thus the String '4' and the number 4 will find the same +entry. Note that the String '04' and the Number 04 are different, since the +Number will be converted to the String '4'. + +A value can be any expression. Using a Dictionary for a value creates a +nested Dictionary: > + :let nestdict = {1: {11: 'a', 12: 'b'}, 2: {21: 'c'}} + +An extra comma after the last entry is ignored. + + +Accessing entries ~ + +The normal way to access an entry is by putting the key in square brackets: > + :let val = mydict["one"] + :let mydict["four"] = 4 + +You can add new entries to an existing Dictionary this way, unlike Lists. + +For keys that consist entirely of letters, digits and underscore the following +form can be used |expr-entry|: > + :let val = mydict.one + :let mydict.four = 4 + +Since an entry can be any type, also a List and a Dictionary, the indexing and +key lookup can be repeated: > + :echo dict.key[idx].key + + +Dictionary to List conversion ~ + +You may want to loop over the entries in a dictionary. For this you need to +turn the Dictionary into a List and pass it to |:for|. + +Most often you want to loop over the keys, using the |keys()| function: > + :for key in keys(mydict) + : echo key . ': ' . mydict[key] + :endfor + +The List of keys is unsorted. You may want to sort them first: > + :for key in sort(keys(mydict)) + +To loop over the values use the |values()| function: > + :for v in values(mydict) + : echo "value: " . v + :endfor + +If you want both the key and the value use the |items()| function. It returns +a List in which each item is a List with two items, the key and the value: > + :for [key, value] in items(mydict) + : echo key . ': ' . value + :endfor + + +Dictionary identity ~ + *dict-identity* +Just like Lists you need to use |copy()| and |deepcopy()| to make a copy of a +Dictionary. Otherwise, assignment results in referring to the same +Dictionary: > + :let onedict = {'a': 1, 'b': 2} + :let adict = onedict + :let adict['a'] = 11 + :echo onedict['a'] + 11 + +Two Dictionaries compare equal if all the key-value pairs compare equal. For +more info see |list-identity|. + + +Dictionary modification ~ + *dict-modification* +To change an already existing entry of a Dictionary, or to add a new entry, +use |:let| this way: > + :let dict[4] = "four" + :let dict['one'] = item + +Removing an entry from a Dictionary is done with |remove()| or |:unlet|. +Three ways to remove the entry with key "aaa" from dict: > + :let i = remove(dict, 'aaa') + :unlet dict.aaa + :unlet dict['aaa'] + +Merging a Dictionary with another is done with |extend()|: > + :call extend(adict, bdict) +This extends adict with all entries from bdict. Duplicate keys cause entries +in adict to be overwritten. An optional third argument can change this. +Note that the order of entries in a Dictionary is irrelevant, thus don't +expect ":echo adict" to show the items from bdict after the older entries in +adict. + +Weeding out entries from a Dictionary can be done with |filter()|: > + :call filter(dict, 'v:val =~ "x"') +This removes all entries from "dict" with a value not matching 'x'. + + +Dictionary function ~ + *Dictionary-function* *self* *E725* +When a function is defined with the "dict" attribute it can be used in a +special way with a dictionary. Example: > + :function Mylen() dict + : return len(self.data) + :endfunction + :let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")} + :echo mydict.len() + +This is like a method in object oriented programming. The entry in the +Dictionary is a |Funcref|. The local variable "self" refers to the dictionary +the function was invoked from. + +It is also possible to add a function without the "dict" attribute as a +Funcref to a Dictionary, but the "self" variable is not available then. + + *numbered-function* *anonymous-function* +To avoid the extra name for the function it can be defined and directly +assigned to a Dictionary in this way: > + :let mydict = {'data': [0, 1, 2, 3]} + :function mydict.len() dict + : return len(self.data) + :endfunction + :echo mydict.len() + +The function will then get a number and the value of dict.len is a |Funcref| +that references this function. The function can only be used through a +|Funcref|. It will automatically be deleted when there is no |Funcref| +remaining that refers to it. + +It is not necessary to use the "dict" attribute for a numbered function. + +If you get an error for a numbered function, you can find out what it is with +a trick. Assuming the function is 42, the command is: > + :function {42} + + +Functions for Dictionaries ~ + *E715* +Functions that can be used with a Dictionary: > + :if has_key(dict, 'foo') " TRUE if dict has entry with key "foo" + :if empty(dict) " TRUE if dict is empty + :let l = len(dict) " number of items in dict + :let big = max(dict) " maximum value in dict + :let small = min(dict) " minimum value in dict + :let xs = count(dict, 'x') " count nr of times 'x' appears in dict + :let s = string(dict) " String representation of dict + :call map(dict, '">> " . v:val') " prepend ">> " to each item + + +1.5 More about variables ~ + *more-variables* +If you need to know the type of a variable or expression, use the |type()| +function. + +When the '!' flag is included in the 'viminfo' option, global variables that +start with an uppercase letter, and don't contain a lowercase letter, are +stored in the viminfo file |viminfo-file|. + +When the 'sessionoptions' option contains "global", global variables that +start with an uppercase letter and contain at least one lowercase letter are +stored in the session file |session-file|. + +variable name can be stored where ~ +my_var_6 not +My_Var_6 session file +MY_VAR_6 viminfo file + + +It's possible to form a variable name with curly braces, see +|curly-braces-names|. + +============================================================================== +2. Expression syntax *expression-syntax* + +Expression syntax summary, from least to most significant: + +|expr1| expr2 ? expr1 : expr1 if-then-else + +|expr2| expr3 || expr3 .. logical OR + +|expr3| expr4 && expr4 .. logical AND + +|expr4| expr5 == expr5 equal + expr5 != expr5 not equal + expr5 > expr5 greater than + expr5 >= expr5 greater than or equal + expr5 < expr5 smaller than + expr5 <= expr5 smaller than or equal + expr5 =~ expr5 regexp matches + expr5 !~ expr5 regexp doesn't match + + expr5 ==? expr5 equal, ignoring case + expr5 ==# expr5 equal, match case + etc. As above, append ? for ignoring case, # for + matching case + + expr5 is expr5 same |List| instance + expr5 isnot expr5 different |List| instance + +|expr5| expr6 + expr6 .. number addition or list concatenation + expr6 - expr6 .. number subtraction + expr6 . expr6 .. string concatenation + +|expr6| expr7 * expr7 .. number multiplication + expr7 / expr7 .. number division + expr7 % expr7 .. number modulo + +|expr7| ! expr7 logical NOT + - expr7 unary minus + + expr7 unary plus + + +|expr8| expr8[expr1] byte of a String or item of a |List| + expr8[expr1 : expr1] substring of a String or sublist of a |List| + expr8.name entry in a |Dictionary| + expr8(expr1, ...) function call with |Funcref| variable + +|expr9| number number constant + "string" string constant, backslash is special + 'string' string constant, ' is doubled + [expr1, ...] |List| + {expr1: expr1, ...} |Dictionary| + &option option value + (expr1) nested expression + variable internal variable + va{ria}ble internal variable with curly braces + $VAR environment variable + @r contents of register 'r' + function(expr1, ...) function call + func{ti}on(expr1, ...) function call with curly braces + + +".." indicates that the operations in this level can be concatenated. +Example: > + &nu || &list && &shell == "csh" + +All expressions within one level are parsed from left to right. + + +expr1 *expr1* *E109* +----- + +expr2 ? expr1 : expr1 + +The expression before the '?' is evaluated to a number. If it evaluates to +non-zero, the result is the value of the expression between the '?' and ':', +otherwise the result is the value of the expression after the ':'. +Example: > + :echo lnum == 1 ? "top" : lnum + +Since the first expression is an "expr2", it cannot contain another ?:. The +other two expressions can, thus allow for recursive use of ?:. +Example: > + :echo lnum == 1 ? "top" : lnum == 1000 ? "last" : lnum + +To keep this readable, using |line-continuation| is suggested: > + :echo lnum == 1 + :\ ? "top" + :\ : lnum == 1000 + :\ ? "last" + :\ : lnum + +You should always put a space before the ':', otherwise it can be mistaken for +use in a variable such as "a:1". + + +expr2 and expr3 *expr2* *expr3* +--------------- + + *expr-barbar* *expr-&&* +The "||" and "&&" operators take one argument on each side. The arguments +are (converted to) Numbers. The result is: + + input output ~ +n1 n2 n1 || n2 n1 && n2 ~ +zero zero zero zero +zero non-zero non-zero zero +non-zero zero non-zero zero +non-zero non-zero non-zero non-zero + +The operators can be concatenated, for example: > + + &nu || &list && &shell == "csh" + +Note that "&&" takes precedence over "||", so this has the meaning of: > + + &nu || (&list && &shell == "csh") + +Once the result is known, the expression "short-circuits", that is, further +arguments are not evaluated. This is like what happens in C. For example: > + + let a = 1 + echo a || b + +This is valid even if there is no variable called "b" because "a" is non-zero, +so the result must be non-zero. Similarly below: > + + echo exists("b") && b == "yes" + +This is valid whether "b" has been defined or not. The second clause will +only be evaluated if "b" has been defined. + + +expr4 *expr4* +----- + +expr5 {cmp} expr5 + +Compare two expr5 expressions, resulting in a 0 if it evaluates to false, or 1 +if it evaluates to true. + + *expr-==* *expr-!=* *expr->* *expr->=* + *expr-<* *expr-<=* *expr-=~* *expr-!~* + *expr-==#* *expr-!=#* *expr->#* *expr->=#* + *expr-<#* *expr-<=#* *expr-=~#* *expr-!~#* + *expr-==?* *expr-!=?* *expr->?* *expr->=?* + *expr- ># >? +greater than or equal >= >=# >=? +smaller than < <# + 1 . 90 + 90.0 +As: > + (1 . 90) + 90.0 +That works, since the String "190" is automatically converted to the Number +190, which can be added to the Float 90.0. However: > + 1 . 90 * 90.0 +Should be read as: > + 1 . (90 * 90.0) +Since '.' has lower precedence than '*'. This does NOT work, since this +attempts to concatenate a Float and a String. + +When dividing a Number by zero the result depends on the value: + 0 / 0 = -0x80000000 (like NaN for Float) + >0 / 0 = 0x7fffffff (like positive infinity) + <0 / 0 = -0x7fffffff (like negative infinity) + (before Vim 7.2 it was always 0x7fffffff) + +When the righthand side of '%' is zero, the result is 0. + +None of these work for |Funcref|s. + +. and % do not work for Float. *E804* + + +expr7 *expr7* +----- +! expr7 logical NOT *expr-!* +- expr7 unary minus *expr-unary--* ++ expr7 unary plus *expr-unary-+* + +For '!' non-zero becomes zero, zero becomes one. +For '-' the sign of the number is changed. +For '+' the number is unchanged. + +A String will be converted to a Number first. + +These three can be repeated and mixed. Examples: + !-1 == 0 + !!8 == 1 + --9 == 9 + + +expr8 *expr8* +----- +expr8[expr1] item of String or |List| *expr-[]* *E111* + +If expr8 is a Number or String this results in a String that contains the +expr1'th single byte from expr8. expr8 is used as a String, expr1 as a +Number. This doesn't recognize multi-byte encodings, see |byteidx()| for +an alternative. + +Index zero gives the first character. This is like it works in C. Careful: +text column numbers start with one! Example, to get the character under the +cursor: > + :let c = getline(".")[col(".") - 1] + +If the length of the String is less than the index, the result is an empty +String. A negative index always results in an empty string (reason: backwards +compatibility). Use [-1:] to get the last byte. + +If expr8 is a |List| then it results the item at index expr1. See |list-index| +for possible index values. If the index is out of range this results in an +error. Example: > + :let item = mylist[-1] " get last item + +Generally, if a |List| index is equal to or higher than the length of the +|List|, or more negative than the length of the |List|, this results in an +error. + + +expr8[expr1a : expr1b] substring or sublist *expr-[:]* + +If expr8 is a Number or String this results in the substring with the bytes +from expr1a to and including expr1b. expr8 is used as a String, expr1a and +expr1b are used as a Number. This doesn't recognize multi-byte encodings, see +|byteidx()| for computing the indexes. + +If expr1a is omitted zero is used. If expr1b is omitted the length of the +string minus one is used. + +A negative number can be used to measure from the end of the string. -1 is +the last character, -2 the last but one, etc. + +If an index goes out of range for the string characters are omitted. If +expr1b is smaller than expr1a the result is an empty string. + +Examples: > + :let c = name[-1:] " last byte of a string + :let c = name[-2:-2] " last but one byte of a string + :let s = line(".")[4:] " from the fifth byte to the end + :let s = s[:-3] " remove last two bytes +< + *sublist* *slice* +If expr8 is a |List| this results in a new |List| with the items indicated by +the indexes expr1a and expr1b. This works like with a String, as explained +just above, except that indexes out of range cause an error. Examples: > + :let l = mylist[:3] " first four items + :let l = mylist[4:4] " List with one item + :let l = mylist[:] " shallow copy of a List + +Using expr8[expr1] or expr8[expr1a : expr1b] on a |Funcref| results in an +error. + + +expr8.name entry in a |Dictionary| *expr-entry* + +If expr8 is a |Dictionary| and it is followed by a dot, then the following +name will be used as a key in the |Dictionary|. This is just like: +expr8[name]. + +The name must consist of alphanumeric characters, just like a variable name, +but it may start with a number. Curly braces cannot be used. + +There must not be white space before or after the dot. + +Examples: > + :let dict = {"one": 1, 2: "two"} + :echo dict.one + :echo dict .2 + +Note that the dot is also used for String concatenation. To avoid confusion +always put spaces around the dot for String concatenation. + + +expr8(expr1, ...) |Funcref| function call + +When expr8 is a |Funcref| type variable, invoke the function it refers to. + + + + *expr9* +number +------ +number number constant *expr-number* + +Decimal, Hexadecimal (starting with 0x or 0X), or Octal (starting with 0). + + *floating-point-format* +Floating point numbers can be written in two forms: + + [-+]{N}.{M} + [-+]{N}.{M}e[-+]{exp} + +{N} and {M} are numbers. Both {N} and {M} must be present and can only +contain digits. +[-+] means there is an optional plus or minus sign. +{exp} is the exponent, power of 10. +Only a decimal point is accepted, not a comma. No matter what the current +locale is. +{only when compiled with the |+float| feature} + +Examples: + 123.456 + +0.0001 + 55.0 + -0.123 + 1.234e03 + 1.0E-6 + -3.1416e+88 + +These are INVALID: + 3. empty {M} + 1e40 missing .{M} + + *float-pi* *float-e* +A few useful values to copy&paste: > + :let pi = 3.14159265359 + :let e = 2.71828182846 + +Rationale: +Before floating point was introduced, the text "123.456" was interpreted as +the two numbers "123" and "456", both converted to a string and concatenated, +resulting in the string "123456". Since this was considered pointless, and we +could not find it intentionally being used in Vim scripts, this backwards +incompatibility was accepted in favor of being able to use the normal notation +for floating point numbers. + + *floating-point-precision* +The precision and range of floating points numbers depends on what "double" +means in the library Vim was compiled with. There is no way to change this at +runtime. + +The default for displaying a |Float| is to use 6 decimal places, like using +printf("%g", f). You can select something else when using the |printf()| +function. Example: > + :echo printf('%.15e', atan(1)) +< 7.853981633974483e-01 + + + +string *expr-string* *E114* +------ +"string" string constant *expr-quote* + +Note that double quotes are used. + +A string constant accepts these special characters: +\... three-digit octal number (e.g., "\316") +\.. two-digit octal number (must be followed by non-digit) +\. one-digit octal number (must be followed by non-digit) +\x.. byte specified with two hex numbers (e.g., "\x1f") +\x. byte specified with one hex number (must be followed by non-hex char) +\X.. same as \x.. +\X. same as \x. +\u.... character specified with up to 4 hex numbers, stored according to the + current value of 'encoding' (e.g., "\u02a4") +\U.... same as \u.... +\b backspace +\e escape +\f formfeed +\n newline +\r return +\t tab +\\ backslash +\" double quote +\ Special key named "xxx". e.g. "\" for CTRL-W. This is for use + in mappings, the 0x80 byte is escaped. Don't use to get a + utf-8 character, use \uxxxx as mentioned above. + +Note that "\xff" is stored as the byte 255, which may be invalid in some +encodings. Use "\u00ff" to store character 255 according to the current value +of 'encoding'. + +Note that "\000" and "\x00" force the end of the string. + + +literal-string *literal-string* *E115* +--------------- +'string' string constant *expr-'* + +Note that single quotes are used. + +This string is taken as it is. No backslashes are removed or have a special +meaning. The only exception is that two quotes stand for one quote. + +Single quoted strings are useful for patterns, so that backslashes do not need +to be doubled. These two commands are equivalent: > + if a =~ "\\s*" + if a =~ '\s*' + + +option *expr-option* *E112* *E113* +------ +&option option value, local value if possible +&g:option global option value +&l:option local option value + +Examples: > + echo "tabstop is " . &tabstop + if &insertmode + +Any option name can be used here. See |options|. When using the local value +and there is no buffer-local or window-local value, the global value is used +anyway. + + +register *expr-register* *@r* +-------- +@r contents of register 'r' + +The result is the contents of the named register, as a single string. +Newlines are inserted where required. To get the contents of the unnamed +register use @" or @@. See |registers| for an explanation of the available +registers. + +When using the '=' register you get the expression itself, not what it +evaluates to. Use |eval()| to evaluate it. + + +nesting *expr-nesting* *E110* +------- +(expr1) nested expression + + +environment variable *expr-env* +-------------------- +$VAR environment variable + +The String value of any environment variable. When it is not defined, the +result is an empty string. + *expr-env-expand* +Note that there is a difference between using $VAR directly and using +expand("$VAR"). Using it directly will only expand environment variables that +are known inside the current Vim session. Using expand() will first try using +the environment variables known inside the current Vim session. If that +fails, a shell will be used to expand the variable. This can be slow, but it +does expand all variables that the shell knows about. Example: > + :echo $version + :echo expand("$version") +The first one probably doesn't echo anything, the second echoes the $version +variable (if your shell supports it). + + +internal variable *expr-variable* +----------------- +variable internal variable +See below |internal-variables|. + + +function call *expr-function* *E116* *E118* *E119* *E120* +------------- +function(expr1, ...) function call +See below |functions|. + + +============================================================================== +3. Internal variable *internal-variables* *E121* + *E461* +An internal variable name can be made up of letters, digits and '_'. But it +cannot start with a digit. It's also possible to use curly braces, see +|curly-braces-names|. + +An internal variable is created with the ":let" command |:let|. +An internal variable is explicitly destroyed with the ":unlet" command +|:unlet|. +Using a name that is not an internal variable or refers to a variable that has +been destroyed results in an error. + +There are several name spaces for variables. Which one is to be used is +specified by what is prepended: + + (nothing) In a function: local to a function; otherwise: global +|buffer-variable| b: Local to the current buffer. +|window-variable| w: Local to the current window. +|tabpage-variable| t: Local to the current tab page. +|global-variable| g: Global. +|local-variable| l: Local to a function. +|script-variable| s: Local to a |:source|'ed Vim script. +|function-argument| a: Function argument (only inside a function). +|vim-variable| v: Global, predefined by Vim. + +The scope name by itself can be used as a |Dictionary|. For example, to +delete all script-local variables: > + :for k in keys(s:) + : unlet s:[k] + :endfor +< + *buffer-variable* *b:var* +A variable name that is preceded with "b:" is local to the current buffer. +Thus you can have several "b:foo" variables, one for each buffer. +This kind of variable is deleted when the buffer is wiped out or deleted with +|:bdelete|. + +One local buffer variable is predefined: + *b:changedtick-variable* *changetick* +b:changedtick The total number of changes to the current buffer. It is + incremented for each change. An undo command is also a change + in this case. This can be used to perform an action only when + the buffer has changed. Example: > + :if my_changedtick != b:changedtick + : let my_changedtick = b:changedtick + : call My_Update() + :endif +< + *window-variable* *w:var* +A variable name that is preceded with "w:" is local to the current window. It +is deleted when the window is closed. + + *tabpage-variable* *t:var* +A variable name that is preceded with "t:" is local to the current tab page, +It is deleted when the tab page is closed. {not available when compiled +without the |+windows| feature} + + *global-variable* *g:var* +Inside functions global variables are accessed with "g:". Omitting this will +access a variable local to a function. But "g:" can also be used in any other +place if you like. + + *local-variable* *l:var* +Inside functions local variables are accessed without prepending anything. +But you can also prepend "l:" if you like. However, without prepending "l:" +you may run into reserved variable names. For example "count". By itself it +refers to "v:count". Using "l:count" you can have a local variable with the +same name. + + *script-variable* *s:var* +In a Vim script variables starting with "s:" can be used. They cannot be +accessed from outside of the scripts, thus are local to the script. + +They can be used in: +- commands executed while the script is sourced +- functions defined in the script +- autocommands defined in the script +- functions and autocommands defined in functions and autocommands which were + defined in the script (recursively) +- user defined commands defined in the script +Thus not in: +- other scripts sourced from this one +- mappings +- menus +- etc. + +Script variables can be used to avoid conflicts with global variable names. +Take this example: > + + let s:counter = 0 + function MyCounter() + let s:counter = s:counter + 1 + echo s:counter + endfunction + command Tick call MyCounter() + +You can now invoke "Tick" from any script, and the "s:counter" variable in +that script will not be changed, only the "s:counter" in the script where +"Tick" was defined is used. + +Another example that does the same: > + + let s:counter = 0 + command Tick let s:counter = s:counter + 1 | echo s:counter + +When calling a function and invoking a user-defined command, the context for +script variables is set to the script where the function or command was +defined. + +The script variables are also available when a function is defined inside a +function that is defined in a script. Example: > + + let s:counter = 0 + function StartCounting(incr) + if a:incr + function MyCounter() + let s:counter = s:counter + 1 + endfunction + else + function MyCounter() + let s:counter = s:counter - 1 + endfunction + endif + endfunction + +This defines the MyCounter() function either for counting up or counting down +when calling StartCounting(). It doesn't matter from where StartCounting() is +called, the s:counter variable will be accessible in MyCounter(). + +When the same script is sourced again it will use the same script variables. +They will remain valid as long as Vim is running. This can be used to +maintain a counter: > + + if !exists("s:counter") + let s:counter = 1 + echo "script executed for the first time" + else + let s:counter = s:counter + 1 + echo "script executed " . s:counter . " times now" + endif + +Note that this means that filetype plugins don't get a different set of script +variables for each buffer. Use local buffer variables instead |b:var|. + + +Predefined Vim variables: *vim-variable* *v:var* + + *v:beval_col* *beval_col-variable* +v:beval_col The number of the column, over which the mouse pointer is. + This is the byte index in the |v:beval_lnum| line. + Only valid while evaluating the 'balloonexpr' option. + + *v:beval_bufnr* *beval_bufnr-variable* +v:beval_bufnr The number of the buffer, over which the mouse pointer is. Only + valid while evaluating the 'balloonexpr' option. + + *v:beval_lnum* *beval_lnum-variable* +v:beval_lnum The number of the line, over which the mouse pointer is. Only + valid while evaluating the 'balloonexpr' option. + + *v:beval_text* *beval_text-variable* +v:beval_text The text under or after the mouse pointer. Usually a word as + it is useful for debugging a C program. 'iskeyword' applies, + but a dot and "->" before the position is included. When on a + ']' the text before it is used, including the matching '[' and + word before it. When on a Visual area within one line the + highlighted text is used. + Only valid while evaluating the 'balloonexpr' option. + + *v:beval_winnr* *beval_winnr-variable* +v:beval_winnr The number of the window, over which the mouse pointer is. Only + valid while evaluating the 'balloonexpr' option. + + *v:char* *char-variable* +v:char Argument for evaluating 'formatexpr' and used for the typed + character when using in an abbreviation |:map-|. + It is also used by the |InsertPreChar| event. + + *v:charconvert_from* *charconvert_from-variable* +v:charconvert_from + The name of the character encoding of a file to be converted. + Only valid while evaluating the 'charconvert' option. + + *v:charconvert_to* *charconvert_to-variable* +v:charconvert_to + The name of the character encoding of a file after conversion. + Only valid while evaluating the 'charconvert' option. + + *v:cmdarg* *cmdarg-variable* +v:cmdarg This variable is used for two purposes: + 1. The extra arguments given to a file read/write command. + Currently these are "++enc=" and "++ff=". This variable is + set before an autocommand event for a file read/write + command is triggered. There is a leading space to make it + possible to append this variable directly after the + read/write command. Note: The "+cmd" argument isn't + included here, because it will be executed anyway. + 2. When printing a PostScript file with ":hardcopy" this is + the argument for the ":hardcopy" command. This can be used + in 'printexpr'. + + *v:cmdbang* *cmdbang-variable* +v:cmdbang Set like v:cmdarg for a file read/write command. When a "!" + was used the value is 1, otherwise it is 0. Note that this + can only be used in autocommands. For user commands || + can be used. + + *v:count* *count-variable* +v:count The count given for the last Normal mode command. Can be used + to get the count before a mapping. Read-only. Example: > + :map _x :echo "the count is " . v:count +< Note: The is required to remove the line range that you + get when typing ':' after a count. + When there are two counts, as in "3d2w", they are multiplied, + just like what happens in the command, "d6w" for the example. + Also used for evaluating the 'formatexpr' option. + "count" also works, for backwards compatibility. + + *v:count1* *count1-variable* +v:count1 Just like "v:count", but defaults to one when no count is + used. + + *v:ctype* *ctype-variable* +v:ctype The current locale setting for characters of the runtime + environment. This allows Vim scripts to be aware of the + current locale encoding. Technical: it's the value of + LC_CTYPE. When not using a locale the value is "C". + This variable can not be set directly, use the |:language| + command. + See |multi-lang|. + + *v:dying* *dying-variable* +v:dying Normally zero. When a deadly signal is caught it's set to + one. When multiple signals are caught the number increases. + Can be used in an autocommand to check if Vim didn't + terminate normally. {only works on Unix} + Example: > + :au VimLeave * if v:dying | echo "\nAAAAaaaarrrggghhhh!!!\n" | endif +< Note: if another deadly signal is caught when v:dying is one, + VimLeave autocommands will not be executed. + + *v:errmsg* *errmsg-variable* +v:errmsg Last given error message. It's allowed to set this variable. + Example: > + :let v:errmsg = "" + :silent! next + :if v:errmsg != "" + : ... handle error +< "errmsg" also works, for backwards compatibility. + + *v:exception* *exception-variable* +v:exception The value of the exception most recently caught and not + finished. See also |v:throwpoint| and |throw-variables|. + Example: > + :try + : throw "oops" + :catch /.*/ + : echo "caught" v:exception + :endtry +< Output: "caught oops". + + *v:fcs_reason* *fcs_reason-variable* +v:fcs_reason The reason why the |FileChangedShell| event was triggered. + Can be used in an autocommand to decide what to do and/or what + to set v:fcs_choice to. Possible values: + deleted file no longer exists + conflict file contents, mode or timestamp was + changed and buffer is modified + changed file contents has changed + mode mode of file changed + time only file timestamp changed + + *v:fcs_choice* *fcs_choice-variable* +v:fcs_choice What should happen after a |FileChangedShell| event was + triggered. Can be used in an autocommand to tell Vim what to + do with the affected buffer: + reload Reload the buffer (does not work if + the file was deleted). + ask Ask the user what to do, as if there + was no autocommand. Except that when + only the timestamp changed nothing + will happen. + Nothing, the autocommand should do + everything that needs to be done. + The default is empty. If another (invalid) value is used then + Vim behaves like it is empty, there is no warning message. + + *v:fname_in* *fname_in-variable* +v:fname_in The name of the input file. Valid while evaluating: + option used for ~ + 'charconvert' file to be converted + 'diffexpr' original file + 'patchexpr' original file + 'printexpr' file to be printed + And set to the swap file name for |SwapExists|. + + *v:fname_out* *fname_out-variable* +v:fname_out The name of the output file. Only valid while + evaluating: + option used for ~ + 'charconvert' resulting converted file (*) + 'diffexpr' output of diff + 'patchexpr' resulting patched file + (*) When doing conversion for a write command (e.g., ":w + file") it will be equal to v:fname_in. When doing conversion + for a read command (e.g., ":e file") it will be a temporary + file and different from v:fname_in. + + *v:fname_new* *fname_new-variable* +v:fname_new The name of the new version of the file. Only valid while + evaluating 'diffexpr'. + + *v:fname_diff* *fname_diff-variable* +v:fname_diff The name of the diff (patch) file. Only valid while + evaluating 'patchexpr'. + + *v:folddashes* *folddashes-variable* +v:folddashes Used for 'foldtext': dashes representing foldlevel of a closed + fold. + Read-only in the |sandbox|. |fold-foldtext| + + *v:foldlevel* *foldlevel-variable* +v:foldlevel Used for 'foldtext': foldlevel of closed fold. + Read-only in the |sandbox|. |fold-foldtext| + + *v:foldend* *foldend-variable* +v:foldend Used for 'foldtext': last line of closed fold. + Read-only in the |sandbox|. |fold-foldtext| + + *v:foldstart* *foldstart-variable* +v:foldstart Used for 'foldtext': first line of closed fold. + Read-only in the |sandbox|. |fold-foldtext| + + *v:insertmode* *insertmode-variable* +v:insertmode Used for the |InsertEnter| and |InsertChange| autocommand + events. Values: + i Insert mode + r Replace mode + v Virtual Replace mode + + *v:key* *key-variable* +v:key Key of the current item of a |Dictionary|. Only valid while + evaluating the expression used with |map()| and |filter()|. + Read-only. + + *v:lang* *lang-variable* +v:lang The current locale setting for messages of the runtime + environment. This allows Vim scripts to be aware of the + current language. Technical: it's the value of LC_MESSAGES. + The value is system dependent. + This variable can not be set directly, use the |:language| + command. + It can be different from |v:ctype| when messages are desired + in a different language than what is used for character + encoding. See |multi-lang|. + + *v:lc_time* *lc_time-variable* +v:lc_time The current locale setting for time messages of the runtime + environment. This allows Vim scripts to be aware of the + current language. Technical: it's the value of LC_TIME. + This variable can not be set directly, use the |:language| + command. See |multi-lang|. + + *v:lnum* *lnum-variable* +v:lnum Line number for the 'foldexpr' |fold-expr|, 'formatexpr' and + 'indentexpr' expressions, tab page number for 'guitablabel' + and 'guitabtooltip'. Only valid while one of these + expressions is being evaluated. Read-only when in the + |sandbox|. + + *v:mouse_win* *mouse_win-variable* +v:mouse_win Window number for a mouse click obtained with |getchar()|. + First window has number 1, like with |winnr()|. The value is + zero when there was no mouse button click. + + *v:mouse_lnum* *mouse_lnum-variable* +v:mouse_lnum Line number for a mouse click obtained with |getchar()|. + This is the text line number, not the screen line number. The + value is zero when there was no mouse button click. + + *v:mouse_col* *mouse_col-variable* +v:mouse_col Column number for a mouse click obtained with |getchar()|. + This is the screen column number, like with |virtcol()|. The + value is zero when there was no mouse button click. + + *v:oldfiles* *oldfiles-variable* +v:oldfiles List of file names that is loaded from the |viminfo| file on + startup. These are the files that Vim remembers marks for. + The length of the List is limited by the ' argument of the + 'viminfo' option (default is 100). + Also see |:oldfiles| and |c_#<|. + The List can be modified, but this has no effect on what is + stored in the |viminfo| file later. If you use values other + than String this will cause trouble. + {only when compiled with the |+viminfo| feature} + + *v:operator* *operator-variable* +v:operator The last operator given in Normal mode. This is a single + character except for commands starting with or , + in which case it is two characters. Best used alongside + |v:prevcount| and |v:register|. Useful if you want to cancel + Operator-pending mode and then use the operator, e.g.: > + :omap O :call MyMotion(v:operator) +< The value remains set until another operator is entered, thus + don't expect it to be empty. + v:operator is not set for |:delete|, |:yank| or other Ex + commands. + Read-only. + + *v:prevcount* *prevcount-variable* +v:prevcount The count given for the last but one Normal mode command. + This is the v:count value of the previous command. Useful if + you want to cancel Visual or Operator-pending mode and then + use the count, e.g.: > + :vmap % :call MyFilter(v:prevcount) +< Read-only. + + *v:profiling* *profiling-variable* +v:profiling Normally zero. Set to one after using ":profile start". + See |profiling|. + + *v:progname* *progname-variable* +v:progname Contains the name (with path removed) with which Vim was + invoked. Allows you to do special initialisations for "view", + "evim" etc., or any other name you might symlink to Vim. + Read-only. + + *v:register* *register-variable* +v:register The name of the register supplied to the last normal mode + command. Empty if none were supplied. |getreg()| |setreg()| + + *v:scrollstart* *scrollstart-variable* +v:scrollstart String describing the script or function that caused the + screen to scroll up. It's only set when it is empty, thus the + first reason is remembered. It is set to "Unknown" for a + typed command. + This can be used to find out why your script causes the + hit-enter prompt. + + *v:servername* *servername-variable* +v:servername The resulting registered |x11-clientserver| name if any. + Read-only. + + +v:searchforward *v:searchforward* *searchforward-variable* + Search direction: 1 after a forward search, 0 after a + backward search. It is reset to forward when directly setting + the last search pattern, see |quote/|. + Note that the value is restored when returning from a + function. |function-search-undo|. + Read-write. + + *v:shell_error* *shell_error-variable* +v:shell_error Result of the last shell command. When non-zero, the last + shell command had an error. When zero, there was no problem. + This only works when the shell returns the error code to Vim. + The value -1 is often used when the command could not be + executed. Read-only. + Example: > + :!mv foo bar + :if v:shell_error + : echo 'could not rename "foo" to "bar"!' + :endif +< "shell_error" also works, for backwards compatibility. + + *v:statusmsg* *statusmsg-variable* +v:statusmsg Last given status message. It's allowed to set this variable. + + *v:swapname* *swapname-variable* +v:swapname Only valid when executing |SwapExists| autocommands: Name of + the swap file found. Read-only. + + *v:swapchoice* *swapchoice-variable* +v:swapchoice |SwapExists| autocommands can set this to the selected choice + for handling an existing swap file: + 'o' Open read-only + 'e' Edit anyway + 'r' Recover + 'd' Delete swapfile + 'q' Quit + 'a' Abort + The value should be a single-character string. An empty value + results in the user being asked, as would happen when there is + no SwapExists autocommand. The default is empty. + + *v:swapcommand* *swapcommand-variable* +v:swapcommand Normal mode command to be executed after a file has been + opened. Can be used for a |SwapExists| autocommand to have + another Vim open the file and jump to the right place. For + example, when jumping to a tag the value is ":tag tagname\r". + For ":edit +cmd file" the value is ":cmd\r". + + *v:termresponse* *termresponse-variable* +v:termresponse The escape sequence returned by the terminal for the |t_RV| + termcap entry. It is set when Vim receives an escape sequence + that starts with ESC [ or CSI and ends in a 'c', with only + digits, ';' and '.' in between. + When this option is set, the TermResponse autocommand event is + fired, so that you can react to the response from the + terminal. + The response from a new xterm is: "[ Pp ; Pv ; Pc c". Pp + is the terminal type: 0 for vt100 and 1 for vt220. Pv is the + patch level (since this was introduced in patch 95, it's + always 95 or bigger). Pc is always zero. + {only when compiled with |+termresponse| feature} + + *v:this_session* *this_session-variable* +v:this_session Full filename of the last loaded or saved session file. See + |:mksession|. It is allowed to set this variable. When no + session file has been saved, this variable is empty. + "this_session" also works, for backwards compatibility. + + *v:throwpoint* *throwpoint-variable* +v:throwpoint The point where the exception most recently caught and not + finished was thrown. Not set when commands are typed. See + also |v:exception| and |throw-variables|. + Example: > + :try + : throw "oops" + :catch /.*/ + : echo "Exception from" v:throwpoint + :endtry +< Output: "Exception from test.vim, line 2" + + *v:val* *val-variable* +v:val Value of the current item of a |List| or |Dictionary|. Only + valid while evaluating the expression used with |map()| and + |filter()|. Read-only. + + *v:version* *version-variable* +v:version Version number of Vim: Major version number times 100 plus + minor version number. Version 5.0 is 500. Version 5.1 (5.01) + is 501. Read-only. "version" also works, for backwards + compatibility. + Use |has()| to check if a certain patch was included, e.g.: > + if has("patch123") +< Note that patch numbers are specific to the version, thus both + version 5.0 and 5.1 may have a patch 123, but these are + completely different. + + *v:warningmsg* *warningmsg-variable* +v:warningmsg Last given warning message. It's allowed to set this variable. + + *v:windowid* *windowid-variable* +v:windowid When any X11 based GUI is running or when running in a + terminal and Vim connects to the X server (|-X|) this will be + set to the window ID. + When an MS-Windows GUI is running this will be set to the + window handle. + Otherwise the value is zero. + Note: for windows inside Vim use |winnr()|. + +============================================================================== +4. Builtin Functions *functions* + +See |function-list| for a list grouped by what the function is used for. + +(Use CTRL-] on the function name to jump to the full explanation.) + +USAGE RESULT DESCRIPTION ~ + +abs( {expr}) Float or Number absolute value of {expr} +acos( {expr}) Float arc cosine of {expr} +add( {list}, {item}) List append {item} to |List| {list} +append( {lnum}, {string}) Number append {string} below line {lnum} +append( {lnum}, {list}) Number append lines {list} below line {lnum} +argc() Number number of files in the argument list +argidx() Number current index in the argument list +argv( {nr}) String {nr} entry of the argument list +argv( ) List the argument list +asin( {expr}) Float arc sine of {expr} +atan( {expr}) Float arc tangent of {expr} +atan2( {expr}, {expr}) Float arc tangent of {expr1} / {expr2} +browse( {save}, {title}, {initdir}, {default}) + String put up a file requester +browsedir( {title}, {initdir}) String put up a directory requester +bufexists( {expr}) Number TRUE if buffer {expr} exists +buflisted( {expr}) Number TRUE if buffer {expr} is listed +bufloaded( {expr}) Number TRUE if buffer {expr} is loaded +bufname( {expr}) String Name of the buffer {expr} +bufnr( {expr}) Number Number of the buffer {expr} +bufwinnr( {expr}) Number window number of buffer {expr} +byte2line( {byte}) Number line number at byte count {byte} +byteidx( {expr}, {nr}) Number byte index of {nr}'th char in {expr} +call( {func}, {arglist} [, {dict}]) + any call {func} with arguments {arglist} +ceil( {expr}) Float round {expr} up +changenr() Number current change number +char2nr( {expr}) Number ASCII value of first char in {expr} +cindent( {lnum}) Number C indent for line {lnum} +clearmatches() none clear all matches +col( {expr}) Number column nr of cursor or mark +complete( {startcol}, {matches}) none set Insert mode completion +complete_add( {expr}) Number add completion match +complete_check() Number check for key typed during completion +confirm( {msg} [, {choices} [, {default} [, {type}]]]) + Number number of choice picked by user +copy( {expr}) any make a shallow copy of {expr} +cos( {expr}) Float cosine of {expr} +cosh( {expr}) Float hyperbolic cosine of {expr} +count( {list}, {expr} [, {start} [, {ic}]]) + Number count how many {expr} are in {list} +cscope_connection( [{num} , {dbpath} [, {prepend}]]) + Number checks existence of cscope connection +cursor( {lnum}, {col} [, {coladd}]) + Number move cursor to {lnum}, {col}, {coladd} +cursor( {list}) Number move cursor to position in {list} +deepcopy( {expr}) any make a full copy of {expr} +delete( {fname}) Number delete file {fname} +did_filetype() Number TRUE if FileType autocommand event used +diff_filler( {lnum}) Number diff filler lines about {lnum} +diff_hlID( {lnum}, {col}) Number diff highlighting at {lnum}/{col} +empty( {expr}) Number TRUE if {expr} is empty +escape( {string}, {chars}) String escape {chars} in {string} with '\' +eval( {string}) any evaluate {string} into its value +eventhandler( ) Number TRUE if inside an event handler +executable( {expr}) Number 1 if executable {expr} exists +exists( {expr}) Number TRUE if {expr} exists +extend( {expr1}, {expr2} [, {expr3}]) + List/Dict insert items of {expr2} into {expr1} +exp( {expr}) Float exponential of {expr} +expand( {expr} [, {flag}]) String expand special keywords in {expr} +feedkeys( {string} [, {mode}]) Number add key sequence to typeahead buffer +filereadable( {file}) Number TRUE if {file} is a readable file +filewritable( {file}) Number TRUE if {file} is a writable file +filter( {expr}, {string}) List/Dict remove items from {expr} where + {string} is 0 +finddir( {name}[, {path}[, {count}]]) + String find directory {name} in {path} +findfile( {name}[, {path}[, {count}]]) + String find file {name} in {path} +float2nr( {expr}) Number convert Float {expr} to a Number +floor( {expr}) Float round {expr} down +fmod( {expr1}, {expr2}) Float remainder of {expr1} / {expr2} +fnameescape( {fname}) String escape special characters in {fname} +fnamemodify( {fname}, {mods}) String modify file name +foldclosed( {lnum}) Number first line of fold at {lnum} if closed +foldclosedend( {lnum}) Number last line of fold at {lnum} if closed +foldlevel( {lnum}) Number fold level at {lnum} +foldtext( ) String line displayed for closed fold +foldtextresult( {lnum}) String text for closed fold at {lnum} +foreground( ) Number bring the Vim window to the foreground +function( {name}) Funcref reference to function {name} +garbagecollect( [at_exit]) none free memory, breaking cyclic references +get( {list}, {idx} [, {def}]) any get item {idx} from {list} or {def} +get( {dict}, {key} [, {def}]) any get item {key} from {dict} or {def} +getbufline( {expr}, {lnum} [, {end}]) + List lines {lnum} to {end} of buffer {expr} +getbufvar( {expr}, {varname}) any variable {varname} in buffer {expr} +getchar( [expr]) Number get one character from the user +getcharmod( ) Number modifiers for the last typed character +getcmdline() String return the current command-line +getcmdpos() Number return cursor position in command-line +getcmdtype() String return the current command-line type +getcwd() String the current working directory +getfperm( {fname}) String file permissions of file {fname} +getfsize( {fname}) Number size in bytes of file {fname} +getfontname( [{name}]) String name of font being used +getftime( {fname}) Number last modification time of file +getftype( {fname}) String description of type of file {fname} +getline( {lnum}) String line {lnum} of current buffer +getline( {lnum}, {end}) List lines {lnum} to {end} of current buffer +getloclist( {nr}) List list of location list items +getmatches() List list of current matches +getpid() Number process ID of Vim +getpos( {expr}) List position of cursor, mark, etc. +getqflist() List list of quickfix items +getreg( [{regname} [, 1]]) String contents of register +getregtype( [{regname}]) String type of register +gettabvar( {nr}, {varname}) any variable {varname} in tab {nr} +gettabwinvar( {tabnr}, {winnr}, {name}) + any {name} in {winnr} in tab page {tabnr} +getwinposx() Number X coord in pixels of GUI Vim window +getwinposy() Number Y coord in pixels of GUI Vim window +getwinvar( {nr}, {varname}) any variable {varname} in window {nr} +glob( {expr} [, {flag}]) String expand file wildcards in {expr} +globpath( {path}, {expr} [, {flag}]) + String do glob({expr}) for all dirs in {path} +has( {feature}) Number TRUE if feature {feature} supported +has_key( {dict}, {key}) Number TRUE if {dict} has entry {key} +haslocaldir() Number TRUE if current window executed |:lcd| +hasmapto( {what} [, {mode} [, {abbr}]]) + Number TRUE if mapping to {what} exists +histadd( {history},{item}) String add an item to a history +histdel( {history} [, {item}]) String remove an item from a history +histget( {history} [, {index}]) String get the item {index} from a history +histnr( {history}) Number highest index of a history +hlexists( {name}) Number TRUE if highlight group {name} exists +hlID( {name}) Number syntax ID of highlight group {name} +hostname() String name of the machine Vim is running on +iconv( {expr}, {from}, {to}) String convert encoding of {expr} +indent( {lnum}) Number indent of line {lnum} +index( {list}, {expr} [, {start} [, {ic}]]) + Number index in {list} where {expr} appears +input( {prompt} [, {text} [, {completion}]]) + String get input from the user +inputdialog( {p} [, {t} [, {c}]]) String like input() but in a GUI dialog +inputlist( {textlist}) Number let the user pick from a choice list +inputrestore() Number restore typeahead +inputsave() Number save and clear typeahead +inputsecret( {prompt} [, {text}]) String like input() but hiding the text +insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}] +isdirectory( {directory}) Number TRUE if {directory} is a directory +islocked( {expr}) Number TRUE if {expr} is locked +items( {dict}) List key-value pairs in {dict} +join( {list} [, {sep}]) String join {list} items into one String +keys( {dict}) List keys in {dict} +len( {expr}) Number the length of {expr} +libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg} +libcallnr( {lib}, {func}, {arg}) Number idem, but return a Number +line( {expr}) Number line nr of cursor, last line or mark +line2byte( {lnum}) Number byte count of line {lnum} +lispindent( {lnum}) Number Lisp indent for line {lnum} +localtime() Number current time +log( {expr}) Float natural logarithm (base e) of {expr} +log10( {expr}) Float logarithm of Float {expr} to base 10 +map( {expr}, {string}) List/Dict change each item in {expr} to {expr} +maparg( {name}[, {mode} [, {abbr} [, {dict}]]]) + String rhs of mapping {name} in mode {mode} +mapcheck( {name}[, {mode} [, {abbr}]]) + String check for mappings matching {name} +match( {expr}, {pat}[, {start}[, {count}]]) + Number position where {pat} matches in {expr} +matchadd( {group}, {pattern}[, {priority}[, {id}]]) + Number highlight {pattern} with {group} +matcharg( {nr}) List arguments of |:match| +matchdelete( {id}) Number delete match identified by {id} +matchend( {expr}, {pat}[, {start}[, {count}]]) + Number position where {pat} ends in {expr} +matchlist( {expr}, {pat}[, {start}[, {count}]]) + List match and submatches of {pat} in {expr} +matchstr( {expr}, {pat}[, {start}[, {count}]]) + String {count}'th match of {pat} in {expr} +max( {list}) Number maximum value of items in {list} +min( {list}) Number minimum value of items in {list} +mkdir( {name} [, {path} [, {prot}]]) + Number create directory {name} +mode( [expr]) String current editing mode +mzeval( {expr}) any evaluate |MzScheme| expression +nextnonblank( {lnum}) Number line nr of non-blank line >= {lnum} +nr2char( {expr}) String single char with ASCII value {expr} +pathshorten( {expr}) String shorten directory names in a path +pow( {x}, {y}) Float {x} to the power of {y} +prevnonblank( {lnum}) Number line nr of non-blank line <= {lnum} +printf( {fmt}, {expr1}...) String format text +pumvisible() Number whether popup menu is visible +range( {expr} [, {max} [, {stride}]]) + List items from {expr} to {max} +readfile( {fname} [, {binary} [, {max}]]) + List get list of lines from file {fname} +reltime( [{start} [, {end}]]) List get time value +reltimestr( {time}) String turn time value into a String +remote_expr( {server}, {string} [, {idvar}]) + String send expression +remote_foreground( {server}) Number bring Vim server to the foreground +remote_peek( {serverid} [, {retvar}]) + Number check for reply string +remote_read( {serverid}) String read reply string +remote_send( {server}, {string} [, {idvar}]) + String send key sequence +remove( {list}, {idx} [, {end}]) any remove items {idx}-{end} from {list} +remove( {dict}, {key}) any remove entry {key} from {dict} +rename( {from}, {to}) Number rename (move) file from {from} to {to} +repeat( {expr}, {count}) String repeat {expr} {count} times +resolve( {filename}) String get filename a shortcut points to +reverse( {list}) List reverse {list} in-place +round( {expr}) Float round off {expr} +search( {pattern} [, {flags} [, {stopline} [, {timeout}]]]) + Number search for {pattern} +searchdecl( {name} [, {global} [, {thisblock}]]) + Number search for variable declaration +searchpair( {start}, {middle}, {end} [, {flags} [, {skip} [...]]]) + Number search for other end of start/end pair +searchpairpos( {start}, {middle}, {end} [, {flags} [, {skip} [...]]]) + List search for other end of start/end pair +searchpos( {pattern} [, {flags} [, {stopline} [, {timeout}]]]) + List search for {pattern} +server2client( {clientid}, {string}) + Number send reply string +serverlist() String get a list of available servers +setbufvar( {expr}, {varname}, {val}) set {varname} in buffer {expr} to {val} +setcmdpos( {pos}) Number set cursor position in command-line +setline( {lnum}, {line}) Number set line {lnum} to {line} +setloclist( {nr}, {list}[, {action}]) + Number modify location list using {list} +setmatches( {list}) Number restore a list of matches +setpos( {expr}, {list}) Number set the {expr} position to {list} +setqflist( {list}[, {action}]) Number modify quickfix list using {list} +setreg( {n}, {v}[, {opt}]) Number set register to value and type +settabvar( {nr}, {varname}, {val}) set {varname} in tab page {nr} to {val} +settabwinvar( {tabnr}, {winnr}, {varname}, {val}) set {varname} in window + {winnr} in tab page {tabnr} to {val} +setwinvar( {nr}, {varname}, {val}) set {varname} in window {nr} to {val} +shellescape( {string} [, {special}]) + String escape {string} for use as shell + command argument +simplify( {filename}) String simplify filename as much as possible +sin( {expr}) Float sine of {expr} +sinh( {expr}) Float hyperbolic sine of {expr} +sort( {list} [, {func}]) List sort {list}, using {func} to compare +soundfold( {word}) String sound-fold {word} +spellbadword() String badly spelled word at cursor +spellsuggest( {word} [, {max} [, {capital}]]) + List spelling suggestions +split( {expr} [, {pat} [, {keepempty}]]) + List make |List| from {pat} separated {expr} +sqrt( {expr} Float squar root of {expr} +str2float( {expr}) Float convert String to Float +str2nr( {expr} [, {base}]) Number convert String to Number +strchars( {expr}) Number character length of the String {expr} +strdisplaywidth( {expr} [, {col}]) Number display length of the String {expr} +strftime( {format}[, {time}]) String time in specified format +stridx( {haystack}, {needle}[, {start}]) + Number index of {needle} in {haystack} +string( {expr}) String String representation of {expr} value +strlen( {expr}) Number length of the String {expr} +strpart( {src}, {start}[, {len}]) + String {len} characters of {src} at {start} +strridx( {haystack}, {needle} [, {start}]) + Number last index of {needle} in {haystack} +strtrans( {expr}) String translate string to make it printable +strwidth( {expr}) Number display cell length of the String {expr} +submatch( {nr}) String specific match in ":substitute" +substitute( {expr}, {pat}, {sub}, {flags}) + String all {pat} in {expr} replaced with {sub} +synID( {lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col} +synIDattr( {synID}, {what} [, {mode}]) + String attribute {what} of syntax ID {synID} +synIDtrans( {synID}) Number translated syntax ID of {synID} +synstack( {lnum}, {col}) List stack of syntax IDs at {lnum} and {col} +system( {expr} [, {input}]) String output of shell command/filter {expr} +tabpagebuflist( [{arg}]) List list of buffer numbers in tab page +tabpagenr( [{arg}]) Number number of current or last tab page +tabpagewinnr( {tabarg}[, {arg}]) + Number number of current window in tab page +taglist( {expr}) List list of tags matching {expr} +tagfiles() List tags files used +tempname() String name for a temporary file +tan( {expr}) Float tangent of {expr} +tanh( {expr}) Float hyperbolic tangent of {expr} +tolower( {expr}) String the String {expr} switched to lowercase +toupper( {expr}) String the String {expr} switched to uppercase +tr( {src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr} + to chars in {tostr} +trunc( {expr} Float truncate Float {expr} +type( {name}) Number type of variable {name} +undofile( {name}) String undo file name for {name} +undotree() List undo file tree +values( {dict}) List values in {dict} +virtcol( {expr}) Number screen column of cursor or mark +visualmode( [expr]) String last visual mode used +winbufnr( {nr}) Number buffer number of window {nr} +wincol() Number window column of the cursor +winheight( {nr}) Number height of window {nr} +winline() Number window line of the cursor +winnr( [{expr}]) Number number of current window +winrestcmd() String returns command to restore window sizes +winrestview( {dict}) none restore view of current window +winsaveview() Dict save view of current window +winwidth( {nr}) Number width of window {nr} +writefile( {list}, {fname} [, {binary}]) + Number write list of lines to file {fname} + +abs({expr}) *abs()* + Return the absolute value of {expr}. When {expr} evaluates to + a |Float| abs() returns a |Float|. When {expr} can be + converted to a |Number| abs() returns a |Number|. Otherwise + abs() gives an error message and returns -1. + Examples: > + echo abs(1.456) +< 1.456 > + echo abs(-5.456) +< 5.456 > + echo abs(-4) +< 4 + {only available when compiled with the |+float| feature} + + +acos({expr}) *acos()* + Return the arc cosine of {expr} measured in radians, as a + |Float| in the range of [0, pi]. + {expr} must evaluate to a |Float| or a |Number| in the range + [-1, 1]. + Examples: > + :echo acos(0) +< 1.570796 > + :echo acos(-0.5) +< 2.094395 + {only available when compiled with the |+float| feature} + + +add({list}, {expr}) *add()* + Append the item {expr} to |List| {list}. Returns the + resulting |List|. Examples: > + :let alist = add([1, 2, 3], item) + :call add(mylist, "woodstock") +< Note that when {expr} is a |List| it is appended as a single + item. Use |extend()| to concatenate |Lists|. + Use |insert()| to add an item at another position. + + +append({lnum}, {expr}) *append()* + When {expr} is a |List|: Append each item of the |List| as a + text line below line {lnum} in the current buffer. + Otherwise append {expr} as one text line below line {lnum} in + the current buffer. + {lnum} can be zero to insert a line before the first one. + Returns 1 for failure ({lnum} out of range or out of memory), + 0 for success. Example: > + :let failed = append(line('$'), "# THE END") + :let failed = append(0, ["Chapter 1", "the beginning"]) +< + *argc()* +argc() The result is the number of files in the argument list of the + current window. See |arglist|. + + *argidx()* +argidx() The result is the current index in the argument list. 0 is + the first file. argc() - 1 is the last one. See |arglist|. + + *argv()* +argv([{nr}]) The result is the {nr}th file in the argument list of the + current window. See |arglist|. "argv(0)" is the first one. + Example: > + :let i = 0 + :while i < argc() + : let f = escape(fnameescape(argv(i)), '.') + : exe 'amenu Arg.' . f . ' :e ' . f . '' + : let i = i + 1 + :endwhile +< Without the {nr} argument a |List| with the whole |arglist| is + returned. + +asin({expr}) *asin()* + Return the arc sine of {expr} measured in radians, as a |Float| + in the range of [-pi/2, pi/2]. + {expr} must evaluate to a |Float| or a |Number| in the range + [-1, 1]. + Examples: > + :echo asin(0.8) +< 0.927295 > + :echo asin(-0.5) +< -0.523599 + {only available when compiled with the |+float| feature} + + +atan({expr}) *atan()* + Return the principal value of the arc tangent of {expr}, in + the range [-pi/2, +pi/2] radians, as a |Float|. + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + :echo atan(100) +< 1.560797 > + :echo atan(-4.01) +< -1.326405 + {only available when compiled with the |+float| feature} + + +atan2({expr1}, {expr2}) *atan2()* + Return the arc tangent of {expr1} / {expr2}, measured in + radians, as a |Float| in the range [-pi, pi]. + {expr1} and {expr2} must evaluate to a |Float| or a |Number|. + Examples: > + :echo atan2(-1, 1) +< -0.785398 > + :echo atan2(1, -1) +< 2.356194 + {only available when compiled with the |+float| feature} + + + *browse()* +browse({save}, {title}, {initdir}, {default}) + Put up a file requester. This only works when "has("browse")" + returns non-zero (only in some GUI versions). + The input fields are: + {save} when non-zero, select file to write + {title} title for the requester + {initdir} directory to start browsing in + {default} default file name + When the "Cancel" button is hit, something went wrong, or + browsing is not possible, an empty string is returned. + + *browsedir()* +browsedir({title}, {initdir}) + Put up a directory requester. This only works when + "has("browse")" returns non-zero (only in some GUI versions). + On systems where a directory browser is not supported a file + browser is used. In that case: select a file in the directory + to be used. + The input fields are: + {title} title for the requester + {initdir} directory to start browsing in + When the "Cancel" button is hit, something went wrong, or + browsing is not possible, an empty string is returned. + +bufexists({expr}) *bufexists()* + The result is a Number, which is non-zero if a buffer called + {expr} exists. + If the {expr} argument is a number, buffer numbers are used. + If the {expr} argument is a string it must match a buffer name + exactly. The name can be: + - Relative to the current directory. + - A full path. + - The name of a buffer with 'buftype' set to "nofile". + - A URL name. + Unlisted buffers will be found. + Note that help files are listed by their short name in the + output of |:buffers|, but bufexists() requires using their + long name to be able to find them. + bufexists() may report a buffer exists, but to use the name + with a |:buffer| command you may need to use |expand()|. Esp + for MS-Windows 8.3 names in the form "c:\DOCUME~1" + Use "bufexists(0)" to test for the existence of an alternate + file name. + *buffer_exists()* + Obsolete name: buffer_exists(). + +buflisted({expr}) *buflisted()* + The result is a Number, which is non-zero if a buffer called + {expr} exists and is listed (has the 'buflisted' option set). + The {expr} argument is used like with |bufexists()|. + +bufloaded({expr}) *bufloaded()* + The result is a Number, which is non-zero if a buffer called + {expr} exists and is loaded (shown in a window or hidden). + The {expr} argument is used like with |bufexists()|. + +bufname({expr}) *bufname()* + The result is the name of a buffer, as it is displayed by the + ":ls" command. + If {expr} is a Number, that buffer number's name is given. + Number zero is the alternate buffer for the current window. + If {expr} is a String, it is used as a |file-pattern| to match + with the buffer names. This is always done like 'magic' is + set and 'cpoptions' is empty. When there is more than one + match an empty string is returned. + "" or "%" can be used for the current buffer, "#" for the + alternate buffer. + A full match is preferred, otherwise a match at the start, end + or middle of the buffer name is accepted. If you only want a + full match then put "^" at the start and "$" at the end of the + pattern. + Listed buffers are found first. If there is a single match + with a listed buffer, that one is returned. Next unlisted + buffers are searched for. + If the {expr} is a String, but you want to use it as a buffer + number, force it to be a Number by adding zero to it: > + :echo bufname("3" + 0) +< If the buffer doesn't exist, or doesn't have a name, an empty + string is returned. > + bufname("#") alternate buffer name + bufname(3) name of buffer 3 + bufname("%") name of current buffer + bufname("file2") name of buffer where "file2" matches. +< *buffer_name()* + Obsolete name: buffer_name(). + + *bufnr()* +bufnr({expr} [, {create}]) + The result is the number of a buffer, as it is displayed by + the ":ls" command. For the use of {expr}, see |bufname()| + above. + If the buffer doesn't exist, -1 is returned. Or, if the + {create} argument is present and not zero, a new, unlisted, + buffer is created and its number is returned. + bufnr("$") is the last buffer: > + :let last_buffer = bufnr("$") +< The result is a Number, which is the highest buffer number + of existing buffers. Note that not all buffers with a smaller + number necessarily exist, because ":bwipeout" may have removed + them. Use bufexists() to test for the existence of a buffer. + *buffer_number()* + Obsolete name: buffer_number(). + *last_buffer_nr()* + Obsolete name for bufnr("$"): last_buffer_nr(). + +bufwinnr({expr}) *bufwinnr()* + The result is a Number, which is the number of the first + window associated with buffer {expr}. For the use of {expr}, + see |bufname()| above. If buffer {expr} doesn't exist or + there is no such window, -1 is returned. Example: > + + echo "A window containing buffer 1 is " . (bufwinnr(1)) + +< The number can be used with |CTRL-W_w| and ":wincmd w" + |:wincmd|. + Only deals with the current tab page. + + +byte2line({byte}) *byte2line()* + Return the line number that contains the character at byte + count {byte} in the current buffer. This includes the + end-of-line character, depending on the 'fileformat' option + for the current buffer. The first character has byte count + one. + Also see |line2byte()|, |go| and |:goto|. + {not available when compiled without the |+byte_offset| + feature} + +byteidx({expr}, {nr}) *byteidx()* + Return byte index of the {nr}'th character in the string + {expr}. Use zero for the first character, it returns zero. + This function is only useful when there are multibyte + characters, otherwise the returned value is equal to {nr}. + Composing characters are counted as a separate character. + Example : > + echo matchstr(str, ".", byteidx(str, 3)) +< will display the fourth character. Another way to do the + same: > + let s = strpart(str, byteidx(str, 3)) + echo strpart(s, 0, byteidx(s, 1)) +< If there are less than {nr} characters -1 is returned. + If there are exactly {nr} characters the length of the string + is returned. + +call({func}, {arglist} [, {dict}]) *call()* *E699* + Call function {func} with the items in |List| {arglist} as + arguments. + {func} can either be a |Funcref| or the name of a function. + a:firstline and a:lastline are set to the cursor line. + Returns the return value of the called function. + {dict} is for functions with the "dict" attribute. It will be + used to set the local variable "self". |Dictionary-function| + +ceil({expr}) *ceil()* + Return the smallest integral value greater than or equal to + {expr} as a |Float| (round up). + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + echo ceil(1.456) +< 2.0 > + echo ceil(-5.456) +< -5.0 > + echo ceil(4.0) +< 4.0 + {only available when compiled with the |+float| feature} + +changenr() *changenr()* + Return the number of the most recent change. This is the same + number as what is displayed with |:undolist| and can be used + with the |:undo| command. + When a change was made it is the number of that change. After + redo it is the number of the redone change. After undo it is + one less than the number of the undone change. + +char2nr({expr}) *char2nr()* + Return number value of the first char in {expr}. Examples: > + char2nr(" ") returns 32 + char2nr("ABC") returns 65 +< The current 'encoding' is used. Example for "utf-8": > + char2nr("á") returns 225 + char2nr("á"[0]) returns 195 +< |nr2char()| does the opposite. + +cindent({lnum}) *cindent()* + Get the amount of indent for line {lnum} according the C + indenting rules, as with 'cindent'. + The indent is counted in spaces, the value of 'tabstop' is + relevant. {lnum} is used just like in |getline()|. + When {lnum} is invalid or Vim was not compiled the |+cindent| + feature, -1 is returned. + See |C-indenting|. + +clearmatches() *clearmatches()* + Clears all matches previously defined by |matchadd()| and the + |:match| commands. + + *col()* +col({expr}) The result is a Number, which is the byte index of the column + position given with {expr}. The accepted positions are: + . the cursor position + $ the end of the cursor line (the result is the + number of characters in the cursor line plus one) + 'x position of mark x (if the mark is not set, 0 is + returned) + Additionally {expr} can be [lnum, col]: a |List| with the line + and column number. Most useful when the column is "$", to get + the last column of a specific line. When "lnum" or "col" is + out of range then col() returns zero. + To get the line number use |line()|. To get both use + |getpos()|. + For the screen column position use |virtcol()|. + Note that only marks in the current file can be used. + Examples: > + col(".") column of cursor + col("$") length of cursor line plus one + col("'t") column of mark t + col("'" . markname) column of mark markname +< The first column is 1. 0 is returned for an error. + For an uppercase mark the column may actually be in another + buffer. + For the cursor position, when 'virtualedit' is active, the + column is one higher if the cursor is after the end of the + line. This can be used to obtain the column in Insert mode: > + :imap :let save_ve = &ve + \:set ve=all + \:echo col(".") . "\n" + \let &ve = save_ve +< + +complete({startcol}, {matches}) *complete()* *E785* + Set the matches for Insert mode completion. + Can only be used in Insert mode. You need to use a mapping + with CTRL-R = |i_CTRL-R|. It does not work after CTRL-O or + with an expression mapping. + {startcol} is the byte offset in the line where the completed + text start. The text up to the cursor is the original text + that will be replaced by the matches. Use col('.') for an + empty string. "col('.') - 1" will replace one character by a + match. + {matches} must be a |List|. Each |List| item is one match. + See |complete-items| for the kind of items that are possible. + Note that the after calling this function you need to avoid + inserting anything that would cause completion to stop. + The match can be selected with CTRL-N and CTRL-P as usual with + Insert mode completion. The popup menu will appear if + specified, see |ins-completion-menu|. + Example: > + inoremap =ListMonths() + + func! ListMonths() + call complete(col('.'), ['January', 'February', 'March', + \ 'April', 'May', 'June', 'July', 'August', 'September', + \ 'October', 'November', 'December']) + return '' + endfunc +< This isn't very useful, but it shows how it works. Note that + an empty string is returned to avoid a zero being inserted. + +complete_add({expr}) *complete_add()* + Add {expr} to the list of matches. Only to be used by the + function specified with the 'completefunc' option. + Returns 0 for failure (empty string or out of memory), + 1 when the match was added, 2 when the match was already in + the list. + See |complete-functions| for an explanation of {expr}. It is + the same as one item in the list that 'omnifunc' would return. + +complete_check() *complete_check()* + Check for a key typed while looking for completion matches. + This is to be used when looking for matches takes some time. + Returns non-zero when searching for matches is to be aborted, + zero otherwise. + Only to be used by the function specified with the + 'completefunc' option. + + *confirm()* +confirm({msg} [, {choices} [, {default} [, {type}]]]) + Confirm() offers the user a dialog, from which a choice can be + made. It returns the number of the choice. For the first + choice this is 1. + Note: confirm() is only supported when compiled with dialog + support, see |+dialog_con| and |+dialog_gui|. + + {msg} is displayed in a |dialog| with {choices} as the + alternatives. When {choices} is missing or empty, "&OK" is + used (and translated). + {msg} is a String, use '\n' to include a newline. Only on + some systems the string is wrapped when it doesn't fit. + + {choices} is a String, with the individual choices separated + by '\n', e.g. > + confirm("Save changes?", "&Yes\n&No\n&Cancel") +< The letter after the '&' is the shortcut key for that choice. + Thus you can type 'c' to select "Cancel". The shortcut does + not need to be the first letter: > + confirm("file has been modified", "&Save\nSave &All") +< For the console, the first letter of each choice is used as + the default shortcut key. + + The optional {default} argument is the number of the choice + that is made if the user hits . Use 1 to make the first + choice the default one. Use 0 to not set a default. If + {default} is omitted, 1 is used. + + The optional {type} argument gives the type of dialog. This + is only used for the icon of the GTK, Mac, Motif and Win32 + GUI. It can be one of these values: "Error", "Question", + "Info", "Warning" or "Generic". Only the first character is + relevant. When {type} is omitted, "Generic" is used. + + If the user aborts the dialog by pressing , CTRL-C, + or another valid interrupt key, confirm() returns 0. + + An example: > + :let choice = confirm("What do you want?", "&Apples\n&Oranges\n&Bananas", 2) + :if choice == 0 + : echo "make up your mind!" + :elseif choice == 3 + : echo "tasteful" + :else + : echo "I prefer bananas myself." + :endif +< In a GUI dialog, buttons are used. The layout of the buttons + depends on the 'v' flag in 'guioptions'. If it is included, + the buttons are always put vertically. Otherwise, confirm() + tries to put the buttons in one horizontal line. If they + don't fit, a vertical layout is used anyway. For some systems + the horizontal layout is always used. + + *copy()* +copy({expr}) Make a copy of {expr}. For Numbers and Strings this isn't + different from using {expr} directly. + When {expr} is a |List| a shallow copy is created. This means + that the original |List| can be changed without changing the + copy, and vice versa. But the items are identical, thus + changing an item changes the contents of both |Lists|. Also + see |deepcopy()|. + +cos({expr}) *cos()* + Return the cosine of {expr}, measured in radians, as a |Float|. + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + :echo cos(100) +< 0.862319 > + :echo cos(-4.01) +< -0.646043 + {only available when compiled with the |+float| feature} + + +cosh({expr}) *cosh()* + Return the hyperbolic cosine of {expr} as a |Float| in the range + [1, inf]. + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + :echo cosh(0.5) +< 1.127626 > + :echo cosh(-0.5) +< -1.127626 + {only available when compiled with the |+float| feature} + + +count({comp}, {expr} [, {ic} [, {start}]]) *count()* + Return the number of times an item with value {expr} appears + in |List| or |Dictionary| {comp}. + If {start} is given then start with the item with this index. + {start} can only be used with a |List|. + When {ic} is given and it's non-zero then case is ignored. + + + *cscope_connection()* +cscope_connection([{num} , {dbpath} [, {prepend}]]) + Checks for the existence of a |cscope| connection. If no + parameters are specified, then the function returns: + 0, if cscope was not available (not compiled in), or + if there are no cscope connections; + 1, if there is at least one cscope connection. + + If parameters are specified, then the value of {num} + determines how existence of a cscope connection is checked: + + {num} Description of existence check + ----- ------------------------------ + 0 Same as no parameters (e.g., "cscope_connection()"). + 1 Ignore {prepend}, and use partial string matches for + {dbpath}. + 2 Ignore {prepend}, and use exact string matches for + {dbpath}. + 3 Use {prepend}, use partial string matches for both + {dbpath} and {prepend}. + 4 Use {prepend}, use exact string matches for both + {dbpath} and {prepend}. + + Note: All string comparisons are case sensitive! + + Examples. Suppose we had the following (from ":cs show"): > + + # pid database name prepend path + 0 27664 cscope.out /usr/local +< + Invocation Return Val ~ + ---------- ---------- > + cscope_connection() 1 + cscope_connection(1, "out") 1 + cscope_connection(2, "out") 0 + cscope_connection(3, "out") 0 + cscope_connection(3, "out", "local") 1 + cscope_connection(4, "out") 0 + cscope_connection(4, "out", "local") 0 + cscope_connection(4, "cscope.out", "/usr/local") 1 +< +cursor({lnum}, {col} [, {off}]) *cursor()* +cursor({list}) + Positions the cursor at the column (byte count) {col} in the + line {lnum}. The first column is one. + When there is one argument {list} this is used as a |List| + with two or three items {lnum}, {col} and {off}. This is like + the return value of |getpos()|, but without the first item. + Does not change the jumplist. + If {lnum} is greater than the number of lines in the buffer, + the cursor will be positioned at the last line in the buffer. + If {lnum} is zero, the cursor will stay in the current line. + If {col} is greater than the number of bytes in the line, + the cursor will be positioned at the last character in the + line. + If {col} is zero, the cursor will stay in the current column. + When 'virtualedit' is used {off} specifies the offset in + screen columns from the start of the character. E.g., a + position within a or after the last character. + Returns 0 when the position could be set, -1 otherwise. + + +deepcopy({expr}[, {noref}]) *deepcopy()* *E698* + Make a copy of {expr}. For Numbers and Strings this isn't + different from using {expr} directly. + When {expr} is a |List| a full copy is created. This means + that the original |List| can be changed without changing the + copy, and vice versa. When an item is a |List|, a copy for it + is made, recursively. Thus changing an item in the copy does + not change the contents of the original |List|. + When {noref} is omitted or zero a contained |List| or + |Dictionary| is only copied once. All references point to + this single copy. With {noref} set to 1 every occurrence of a + |List| or |Dictionary| results in a new copy. This also means + that a cyclic reference causes deepcopy() to fail. + *E724* + Nesting is possible up to 100 levels. When there is an item + that refers back to a higher level making a deep copy with + {noref} set to 1 will fail. + Also see |copy()|. + +delete({fname}) *delete()* + Deletes the file by the name {fname}. The result is a Number, + which is 0 if the file was deleted successfully, and non-zero + when the deletion failed. + Use |remove()| to delete an item from a |List|. + + *did_filetype()* +did_filetype() Returns non-zero when autocommands are being executed and the + FileType event has been triggered at least once. Can be used + to avoid triggering the FileType event again in the scripts + that detect the file type. |FileType| + When editing another file, the counter is reset, thus this + really checks if the FileType event has been triggered for the + current buffer. This allows an autocommand that starts + editing another buffer to set 'filetype' and load a syntax + file. + +diff_filler({lnum}) *diff_filler()* + Returns the number of filler lines above line {lnum}. + These are the lines that were inserted at this point in + another diff'ed window. These filler lines are shown in the + display but don't exist in the buffer. + {lnum} is used like with |getline()|. Thus "." is the current + line, "'m" mark m, etc. + Returns 0 if the current window is not in diff mode. + +diff_hlID({lnum}, {col}) *diff_hlID()* + Returns the highlight ID for diff mode at line {lnum} column + {col} (byte index). When the current line does not have a + diff change zero is returned. + {lnum} is used like with |getline()|. Thus "." is the current + line, "'m" mark m, etc. + {col} is 1 for the leftmost column, {lnum} is 1 for the first + line. + The highlight ID can be used with |synIDattr()| to obtain + syntax information about the highlighting. + +empty({expr}) *empty()* + Return the Number 1 if {expr} is empty, zero otherwise. + A |List| or |Dictionary| is empty when it does not have any + items. A Number is empty when its value is zero. + For a long |List| this is much faster than comparing the + length with zero. + +escape({string}, {chars}) *escape()* + Escape the characters in {chars} that occur in {string} with a + backslash. Example: > + :echo escape('c:\program files\vim', ' \') +< results in: > + c:\\program\ files\\vim +< Also see |shellescape()|. + + *eval()* +eval({string}) Evaluate {string} and return the result. Especially useful to + turn the result of |string()| back into the original value. + This works for Numbers, Floats, Strings and composites of + them. Also works for |Funcref|s that refer to existing + functions. + +eventhandler() *eventhandler()* + Returns 1 when inside an event handler. That is that Vim got + interrupted while waiting for the user to type a character, + e.g., when dropping a file on Vim. This means interactive + commands cannot be used. Otherwise zero is returned. + +executable({expr}) *executable()* + This function checks if an executable with the name {expr} + exists. {expr} must be the name of the program without any + arguments. + executable() uses the value of $PATH and/or the normal + searchpath for programs. *PATHEXT* + On MS-DOS and MS-Windows the ".exe", ".bat", etc. can + optionally be included. Then the extensions in $PATHEXT are + tried. Thus if "foo.exe" does not exist, "foo.exe.bat" can be + found. If $PATHEXT is not set then ".exe;.com;.bat;.cmd" is + used. A dot by itself can be used in $PATHEXT to try using + the name without an extension. When 'shell' looks like a + Unix shell, then the name is also tried without adding an + extension. + On MS-DOS and MS-Windows it only checks if the file exists and + is not a directory, not if it's really executable. + On MS-Windows an executable in the same directory as Vim is + always found. Since this directory is added to $PATH it + should also work to execute it |win32-PATH|. + The result is a Number: + 1 exists + 0 does not exist + -1 not implemented on this system + + *exists()* +exists({expr}) The result is a Number, which is non-zero if {expr} is + defined, zero otherwise. The {expr} argument is a string, + which contains one of these: + &option-name Vim option (only checks if it exists, + not if it really works) + +option-name Vim option that works. + $ENVNAME environment variable (could also be + done by comparing with an empty + string) + *funcname built-in function (see |functions|) + or user defined function (see + |user-functions|). + varname internal variable (see + |internal-variables|). Also works + for |curly-braces-names|, |Dictionary| + entries, |List| items, etc. Beware + that evaluating an index may cause an + error message for an invalid + expression. E.g.: > + :let l = [1, 2, 3] + :echo exists("l[5]") +< 0 > + :echo exists("l[xx]") +< E121: Undefined variable: xx + 0 + :cmdname Ex command: built-in command, user + command or command modifier |:command|. + Returns: + 1 for match with start of a command + 2 full match with a command + 3 matches several user commands + To check for a supported command + always check the return value to be 2. + :2match The |:2match| command. + :3match The |:3match| command. + #event autocommand defined for this event + #event#pattern autocommand defined for this event and + pattern (the pattern is taken + literally and compared to the + autocommand patterns character by + character) + #group autocommand group exists + #group#event autocommand defined for this group and + event. + #group#event#pattern + autocommand defined for this group, + event and pattern. + ##event autocommand for this event is + supported. + For checking for a supported feature use |has()|. + + Examples: > + exists("&shortname") + exists("$HOSTNAME") + exists("*strftime") + exists("*s:MyFunc") + exists("bufcount") + exists(":Make") + exists("#CursorHold") + exists("#BufReadPre#*.gz") + exists("#filetypeindent") + exists("#filetypeindent#FileType") + exists("#filetypeindent#FileType#*") + exists("##ColorScheme") +< There must be no space between the symbol (&/$/*/#) and the + name. + There must be no extra characters after the name, although in + a few cases this is ignored. That may become more strict in + the future, thus don't count on it! + Working example: > + exists(":make") +< NOT working example: > + exists(":make install") + +< Note that the argument must be a string, not the name of the + variable itself. For example: > + exists(bufcount) +< This doesn't check for existence of the "bufcount" variable, + but gets the value of "bufcount", and checks if that exists. + +exp({expr}) *exp()* + Return the exponential of {expr} as a |Float| in the range + [0, inf]. + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + :echo exp(2) +< 7.389056 > + :echo exp(-1) +< 0.367879 + {only available when compiled with the |+float| feature} + + +expand({expr} [, {flag}]) *expand()* + Expand wildcards and the following special keywords in {expr}. + The result is a String. + + When there are several matches, they are separated by + characters. [Note: in version 5.0 a space was used, which + caused problems when a file name contains a space] + + If the expansion fails, the result is an empty string. A name + for a non-existing file is not included. + + When {expr} starts with '%', '#' or '<', the expansion is done + like for the |cmdline-special| variables with their associated + modifiers. Here is a short overview: + + % current file name + # alternate file name + #n alternate file name n + file name under the cursor + autocmd file name + autocmd buffer number (as a String!) + autocmd matched name + sourced script file name + word under the cursor + WORD under the cursor + the {clientid} of the last received + message |server2client()| + Modifiers: + :p expand to full path + :h head (last path component removed) + :t tail (last path component only) + :r root (one extension removed) + :e extension only + + Example: > + :let &tags = expand("%:p:h") . "/tags" +< Note that when expanding a string that starts with '%', '#' or + '<', any following text is ignored. This does NOT work: > + :let doesntwork = expand("%:h.bak") +< Use this: > + :let doeswork = expand("%:h") . ".bak" +< Also note that expanding "" and others only returns the + referenced file name without further expansion. If "" + is "~/.cshrc", you need to do another expand() to have the + "~/" expanded into the path of the home directory: > + :echo expand(expand("")) +< + There cannot be white space between the variables and the + following modifier. The |fnamemodify()| function can be used + to modify normal file names. + + When using '%' or '#', and the current or alternate file name + is not defined, an empty string is used. Using "%:p" in a + buffer with no name, results in the current directory, with a + '/' added. + + When {expr} does not start with '%', '#' or '<', it is + expanded like a file name is expanded on the command line. + 'suffixes' and 'wildignore' are used, unless the optional + {flag} argument is given and it is non-zero. Names for + non-existing files are included. The "**" item can be used to + search in a directory tree. For example, to find all "README" + files in the current directory and below: > + :echo expand("**/README") +< + Expand() can also be used to expand variables and environment + variables that are only known in a shell. But this can be + slow, because a shell must be started. See |expr-env-expand|. + The expanded variable is still handled like a list of file + names. When an environment variable cannot be expanded, it is + left unchanged. Thus ":echo expand('$FOOBAR')" results in + "$FOOBAR". + + See |glob()| for finding existing files. See |system()| for + getting the raw output of an external command. + +extend({expr1}, {expr2} [, {expr3}]) *extend()* + {expr1} and {expr2} must be both |Lists| or both + |Dictionaries|. + + If they are |Lists|: Append {expr2} to {expr1}. + If {expr3} is given insert the items of {expr2} before item + {expr3} in {expr1}. When {expr3} is zero insert before the + first item. When {expr3} is equal to len({expr1}) then + {expr2} is appended. + Examples: > + :echo sort(extend(mylist, [7, 5])) + :call extend(mylist, [2, 3], 1) +< When {expr1} is the same List as {expr2} then the number of + items copied is equal to the original length of the List. + E.g., when {expr3} is 1 you get N new copies of the first item + (where N is the original length of the List). + Use |add()| to concatenate one item to a list. To concatenate + two lists into a new list use the + operator: > + :let newlist = [1, 2, 3] + [4, 5] +< + If they are |Dictionaries|: + Add all entries from {expr2} to {expr1}. + If a key exists in both {expr1} and {expr2} then {expr3} is + used to decide what to do: + {expr3} = "keep": keep the value of {expr1} + {expr3} = "force": use the value of {expr2} + {expr3} = "error": give an error message *E737* + When {expr3} is omitted then "force" is assumed. + + {expr1} is changed when {expr2} is not empty. If necessary + make a copy of {expr1} first. + {expr2} remains unchanged. + Returns {expr1}. + + +feedkeys({string} [, {mode}]) *feedkeys()* + Characters in {string} are queued for processing as if they + come from a mapping or were typed by the user. They are added + to the end of the typeahead buffer, thus if a mapping is still + being executed these characters come after them. + The function does not wait for processing of keys contained in + {string}. + To include special keys into {string}, use double-quotes + and "\..." notation |expr-quote|. For example, + feedkeys("\") simulates pressing of the key. But + feedkeys('\') pushes 5 characters. + If {mode} is absent, keys are remapped. + {mode} is a String, which can contain these character flags: + 'm' Remap keys. This is default. + 'n' Do not remap keys. + 't' Handle keys as if typed; otherwise they are handled as + if coming from a mapping. This matters for undo, + opening folds, etc. + Return value is always 0. + +filereadable({file}) *filereadable()* + The result is a Number, which is TRUE when a file with the + name {file} exists, and can be read. If {file} doesn't exist, + or is a directory, the result is FALSE. {file} is any + expression, which is used as a String. + If you don't care about the file being readable you can use + |glob()|. + *file_readable()* + Obsolete name: file_readable(). + + +filewritable({file}) *filewritable()* + The result is a Number, which is 1 when a file with the + name {file} exists, and can be written. If {file} doesn't + exist, or is not writable, the result is 0. If {file} is a + directory, and we can write to it, the result is 2. + + +filter({expr}, {string}) *filter()* + {expr} must be a |List| or a |Dictionary|. + For each item in {expr} evaluate {string} and when the result + is zero remove the item from the |List| or |Dictionary|. + Inside {string} |v:val| has the value of the current item. + For a |Dictionary| |v:key| has the key of the current item. + Examples: > + :call filter(mylist, 'v:val !~ "OLD"') +< Removes the items where "OLD" appears. > + :call filter(mydict, 'v:key >= 8') +< Removes the items with a key below 8. > + :call filter(var, 0) +< Removes all the items, thus clears the |List| or |Dictionary|. + + Note that {string} is the result of expression and is then + used as an expression again. Often it is good to use a + |literal-string| to avoid having to double backslashes. + + The operation is done in-place. If you want a |List| or + |Dictionary| to remain unmodified make a copy first: > + :let l = filter(copy(mylist), 'v:val =~ "KEEP"') + +< Returns {expr}, the |List| or |Dictionary| that was filtered. + When an error is encountered while evaluating {string} no + further items in {expr} are processed. + + +finddir({name}[, {path}[, {count}]]) *finddir()* + Find directory {name} in {path}. Supports both downwards and + upwards recursive directory searches. See |file-searching| + for the syntax of {path}. + Returns the path of the first found match. When the found + directory is below the current directory a relative path is + returned. Otherwise a full path is returned. + If {path} is omitted or empty then 'path' is used. + If the optional {count} is given, find {count}'s occurrence of + {name} in {path} instead of the first one. + When {count} is negative return all the matches in a |List|. + This is quite similar to the ex-command |:find|. + {only available when compiled with the |+file_in_path| + feature} + +findfile({name}[, {path}[, {count}]]) *findfile()* + Just like |finddir()|, but find a file instead of a directory. + Uses 'suffixesadd'. + Example: > + :echo findfile("tags.vim", ".;") +< Searches from the directory of the current file upwards until + it finds the file "tags.vim". + +float2nr({expr}) *float2nr()* + Convert {expr} to a Number by omitting the part after the + decimal point. + {expr} must evaluate to a |Float| or a Number. + When the value of {expr} is out of range for a |Number| the + result is truncated to 0x7fffffff or -0x7fffffff. NaN results + in -0x80000000. + Examples: > + echo float2nr(3.95) +< 3 > + echo float2nr(-23.45) +< -23 > + echo float2nr(1.0e100) +< 2147483647 > + echo float2nr(-1.0e150) +< -2147483647 > + echo float2nr(1.0e-100) +< 0 + {only available when compiled with the |+float| feature} + + +floor({expr}) *floor()* + Return the largest integral value less than or equal to + {expr} as a |Float| (round down). + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + echo floor(1.856) +< 1.0 > + echo floor(-5.456) +< -6.0 > + echo floor(4.0) +< 4.0 + {only available when compiled with the |+float| feature} + + +fmod({expr1}, {expr2}) *fmod()* + Return the remainder of {expr1} / {expr2}, even if the + division is not representable. Returns {expr1} - i * {expr2} + for some integer i such that if {expr2} is non-zero, the + result has the same sign as {expr1} and magnitude less than + the magnitude of {expr2}. If {expr2} is zero, the value + returned is zero. The value returned is a |Float|. + {expr1} and {expr2} must evaluate to a |Float| or a |Number|. + Examples: > + :echo fmod(12.33, 1.22) +< 0.13 > + :echo fmod(-12.33, 1.22) +< -0.13 + {only available when compiled with |+float| feature} + + +fnameescape({string}) *fnameescape()* + Escape {string} for use as file name command argument. All + characters that have a special meaning, such as '%' and '|' + are escaped with a backslash. + For most systems the characters escaped are + " \t\n*?[{`$\\%#'\"|!<". For systems where a backslash + appears in a filename, it depends on the value of 'isfname'. + A leading '+' and '>' is also escaped (special after |:edit| + and |:write|). And a "-" by itself (special after |:cd|). + Example: > + :let fname = '+some str%nge|name' + :exe "edit " . fnameescape(fname) +< results in executing: > + edit \+some\ str\%nge\|name + +fnamemodify({fname}, {mods}) *fnamemodify()* + Modify file name {fname} according to {mods}. {mods} is a + string of characters like it is used for file names on the + command line. See |filename-modifiers|. + Example: > + :echo fnamemodify("main.c", ":p:h") +< results in: > + /home/mool/vim/vim/src +< Note: Environment variables don't work in {fname}, use + |expand()| first then. + +foldclosed({lnum}) *foldclosed()* + The result is a Number. If the line {lnum} is in a closed + fold, the result is the number of the first line in that fold. + If the line {lnum} is not in a closed fold, -1 is returned. + +foldclosedend({lnum}) *foldclosedend()* + The result is a Number. If the line {lnum} is in a closed + fold, the result is the number of the last line in that fold. + If the line {lnum} is not in a closed fold, -1 is returned. + +foldlevel({lnum}) *foldlevel()* + The result is a Number, which is the foldlevel of line {lnum} + in the current buffer. For nested folds the deepest level is + returned. If there is no fold at line {lnum}, zero is + returned. It doesn't matter if the folds are open or closed. + When used while updating folds (from 'foldexpr') -1 is + returned for lines where folds are still to be updated and the + foldlevel is unknown. As a special case the level of the + previous line is usually available. + + *foldtext()* +foldtext() Returns a String, to be displayed for a closed fold. This is + the default function used for the 'foldtext' option and should + only be called from evaluating 'foldtext'. It uses the + |v:foldstart|, |v:foldend| and |v:folddashes| variables. + The returned string looks like this: > + +-- 45 lines: abcdef +< The number of dashes depends on the foldlevel. The "45" is + the number of lines in the fold. "abcdef" is the text in the + first non-blank line of the fold. Leading white space, "//" + or "/*" and the text from the 'foldmarker' and 'commentstring' + options is removed. + {not available when compiled without the |+folding| feature} + +foldtextresult({lnum}) *foldtextresult()* + Returns the text that is displayed for the closed fold at line + {lnum}. Evaluates 'foldtext' in the appropriate context. + When there is no closed fold at {lnum} an empty string is + returned. + {lnum} is used like with |getline()|. Thus "." is the current + line, "'m" mark m, etc. + Useful when exporting folded text, e.g., to HTML. + {not available when compiled without the |+folding| feature} + + *foreground()* +foreground() Move the Vim window to the foreground. Useful when sent from + a client to a Vim server. |remote_send()| + On Win32 systems this might not work, the OS does not always + allow a window to bring itself to the foreground. Use + |remote_foreground()| instead. + {only in the Win32, Athena, Motif and GTK GUI versions and the + Win32 console version} + + +function({name}) *function()* *E700* + Return a |Funcref| variable that refers to function {name}. + {name} can be a user defined function or an internal function. + + +garbagecollect([at_exit]) *garbagecollect()* + Cleanup unused |Lists| and |Dictionaries| that have circular + references. There is hardly ever a need to invoke this + function, as it is automatically done when Vim runs out of + memory or is waiting for the user to press a key after + 'updatetime'. Items without circular references are always + freed when they become unused. + This is useful if you have deleted a very big |List| and/or + |Dictionary| with circular references in a script that runs + for a long time. + When the optional "at_exit" argument is one, garbage + collection will also be done when exiting Vim, if it wasn't + done before. This is useful when checking for memory leaks. + +get({list}, {idx} [, {default}]) *get()* + Get item {idx} from |List| {list}. When this item is not + available return {default}. Return zero when {default} is + omitted. +get({dict}, {key} [, {default}]) + Get item with key {key} from |Dictionary| {dict}. When this + item is not available return {default}. Return zero when + {default} is omitted. + + *getbufline()* +getbufline({expr}, {lnum} [, {end}]) + Return a |List| with the lines starting from {lnum} to {end} + (inclusive) in the buffer {expr}. If {end} is omitted, a + |List| with only the line {lnum} is returned. + + For the use of {expr}, see |bufname()| above. + + For {lnum} and {end} "$" can be used for the last line of the + buffer. Otherwise a number must be used. + + When {lnum} is smaller than 1 or bigger than the number of + lines in the buffer, an empty |List| is returned. + + When {end} is greater than the number of lines in the buffer, + it is treated as {end} is set to the number of lines in the + buffer. When {end} is before {lnum} an empty |List| is + returned. + + This function works only for loaded buffers. For unloaded and + non-existing buffers, an empty |List| is returned. + + Example: > + :let lines = getbufline(bufnr("myfile"), 1, "$") + +getbufvar({expr}, {varname}) *getbufvar()* + The result is the value of option or local buffer variable + {varname} in buffer {expr}. Note that the name without "b:" + must be used. + When {varname} is empty returns a dictionary with all the + buffer-local variables. + This also works for a global or buffer-local option, but it + doesn't work for a global variable, window-local variable or + window-local option. + For the use of {expr}, see |bufname()| above. + When the buffer or variable doesn't exist an empty string is + returned, there is no error message. + Examples: > + :let bufmodified = getbufvar(1, "&mod") + :echo "todo myvar = " . getbufvar("todo", "myvar") +< +getchar([expr]) *getchar()* + Get a single character from the user or input stream. + If [expr] is omitted, wait until a character is available. + If [expr] is 0, only get a character when one is available. + Return zero otherwise. + If [expr] is 1, only check if a character is available, it is + not consumed. Return zero if no character available. + + Without {expr} and when {expr} is 0 a whole character or + special key is returned. If it is an 8-bit character, the + result is a number. Use nr2char() to convert it to a String. + Otherwise a String is returned with the encoded character. + For a special key it's a sequence of bytes starting with 0x80 + (decimal: 128). This is the same value as the string + "\", e.g., "\". The returned value is also a + String when a modifier (shift, control, alt) was used that is + not included in the character. + + When {expr} is 1 only the first byte is returned. For a + one-byte character it is the character itself as a number. + Use nr2char() to convert it to a String. + + When the user clicks a mouse button, the mouse event will be + returned. The position can then be found in |v:mouse_col|, + |v:mouse_lnum| and |v:mouse_win|. This example positions the + mouse as it would normally happen: > + let c = getchar() + if c == "\" && v:mouse_win > 0 + exe v:mouse_win . "wincmd w" + exe v:mouse_lnum + exe "normal " . v:mouse_col . "|" + endif +< + There is no prompt, you will somehow have to make clear to the + user that a character has to be typed. + There is no mapping for the character. + Key codes are replaced, thus when the user presses the + key you get the code for the key, not the raw character + sequence. Examples: > + getchar() == "\" + getchar() == "\" +< This example redefines "f" to ignore case: > + :nmap f :call FindChar() + :function FindChar() + : let c = nr2char(getchar()) + : while col('.') < col('$') - 1 + : normal l + : if getline('.')[col('.') - 1] ==? c + : break + : endif + : endwhile + :endfunction + +getcharmod() *getcharmod()* + The result is a Number which is the state of the modifiers for + the last obtained character with getchar() or in another way. + These values are added together: + 2 shift + 4 control + 8 alt (meta) + 16 mouse double click + 32 mouse triple click + 64 mouse quadruple click + 128 Macintosh only: command + Only the modifiers that have not been included in the + character itself are obtained. Thus Shift-a results in "A" + without a modifier. + +getcmdline() *getcmdline()* + Return the current command-line. Only works when the command + line is being edited, thus requires use of |c_CTRL-\_e| or + |c_CTRL-R_=|. + Example: > + :cmap eescape(getcmdline(), ' \') +< Also see |getcmdtype()|, |getcmdpos()| and |setcmdpos()|. + +getcmdpos() *getcmdpos()* + Return the position of the cursor in the command line as a + byte count. The first column is 1. + Only works when editing the command line, thus requires use of + |c_CTRL-\_e| or |c_CTRL-R_=|. Returns 0 otherwise. + Also see |getcmdtype()|, |setcmdpos()| and |getcmdline()|. + +getcmdtype() *getcmdtype()* + Return the current command-line type. Possible return values + are: + : normal Ex command + > debug mode command |debug-mode| + / forward search command + ? backward search command + @ |input()| command + - |:insert| or |:append| command + Only works when editing the command line, thus requires use of + |c_CTRL-\_e| or |c_CTRL-R_=|. Returns an empty string + otherwise. + Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|. + + *getcwd()* +getcwd() The result is a String, which is the name of the current + working directory. + +getfsize({fname}) *getfsize()* + The result is a Number, which is the size in bytes of the + given file {fname}. + If {fname} is a directory, 0 is returned. + If the file {fname} can't be found, -1 is returned. + If the size of {fname} is too big to fit in a Number then -2 + is returned. + +getfontname([{name}]) *getfontname()* + Without an argument returns the name of the normal font being + used. Like what is used for the Normal highlight group + |hl-Normal|. + With an argument a check is done whether {name} is a valid + font name. If not then an empty string is returned. + Otherwise the actual font name is returned, or {name} if the + GUI does not support obtaining the real name. + Only works when the GUI is running, thus not in your vimrc or + gvimrc file. Use the |GUIEnter| autocommand to use this + function just after the GUI has started. + Note that the GTK 2 GUI accepts any font name, thus checking + for a valid name does not work. + +getfperm({fname}) *getfperm()* + The result is a String, which is the read, write, and execute + permissions of the given file {fname}. + If {fname} does not exist or its directory cannot be read, an + empty string is returned. + The result is of the form "rwxrwxrwx", where each group of + "rwx" flags represent, in turn, the permissions of the owner + of the file, the group the file belongs to, and other users. + If a user does not have a given permission the flag for this + is replaced with the string "-". Example: > + :echo getfperm("/etc/passwd") +< This will hopefully (from a security point of view) display + the string "rw-r--r--" or even "rw-------". + +getftime({fname}) *getftime()* + The result is a Number, which is the last modification time of + the given file {fname}. The value is measured as seconds + since 1st Jan 1970, and may be passed to strftime(). See also + |localtime()| and |strftime()|. + If the file {fname} can't be found -1 is returned. + +getftype({fname}) *getftype()* + The result is a String, which is a description of the kind of + file of the given file {fname}. + If {fname} does not exist an empty string is returned. + Here is a table over different kinds of files and their + results: + Normal file "file" + Directory "dir" + Symbolic link "link" + Block device "bdev" + Character device "cdev" + Socket "socket" + FIFO "fifo" + All other "other" + Example: > + getftype("/home") +< Note that a type such as "link" will only be returned on + systems that support it. On some systems only "dir" and + "file" are returned. + + *getline()* +getline({lnum} [, {end}]) + Without {end} the result is a String, which is line {lnum} + from the current buffer. Example: > + getline(1) +< When {lnum} is a String that doesn't start with a + digit, line() is called to translate the String into a Number. + To get the line under the cursor: > + getline(".") +< When {lnum} is smaller than 1 or bigger than the number of + lines in the buffer, an empty string is returned. + + When {end} is given the result is a |List| where each item is + a line from the current buffer in the range {lnum} to {end}, + including line {end}. + {end} is used in the same way as {lnum}. + Non-existing lines are silently omitted. + When {end} is before {lnum} an empty |List| is returned. + Example: > + :let start = line('.') + :let end = search("^$") - 1 + :let lines = getline(start, end) + +< To get lines from another buffer see |getbufline()| + +getloclist({nr}) *getloclist()* + Returns a list with all the entries in the location list for + window {nr}. When {nr} is zero the current window is used. + For a location list window, the displayed location list is + returned. For an invalid window number {nr}, an empty list is + returned. Otherwise, same as |getqflist()|. + +getmatches() *getmatches()* + Returns a |List| with all matches previously defined by + |matchadd()| and the |:match| commands. |getmatches()| is + useful in combination with |setmatches()|, as |setmatches()| + can restore a list of matches saved by |getmatches()|. + Example: > + :echo getmatches() +< [{'group': 'MyGroup1', 'pattern': 'TODO', + 'priority': 10, 'id': 1}, {'group': 'MyGroup2', + 'pattern': 'FIXME', 'priority': 10, 'id': 2}] > + :let m = getmatches() + :call clearmatches() + :echo getmatches() +< [] > + :call setmatches(m) + :echo getmatches() +< [{'group': 'MyGroup1', 'pattern': 'TODO', + 'priority': 10, 'id': 1}, {'group': 'MyGroup2', + 'pattern': 'FIXME', 'priority': 10, 'id': 2}] > + :unlet m +< + +getqflist() *getqflist()* + Returns a list with all the current quickfix errors. Each + list item is a dictionary with these entries: + bufnr number of buffer that has the file name, use + bufname() to get the name + lnum line number in the buffer (first line is 1) + col column number (first column is 1) + vcol non-zero: "col" is visual column + zero: "col" is byte index + nr error number + pattern search pattern used to locate the error + text description of the error + type type of the error, 'E', '1', etc. + valid non-zero: recognized error message + + When there is no error list or it's empty an empty list is + returned. Quickfix list entries with non-existing buffer + number are returned with "bufnr" set to zero. + + Useful application: Find pattern matches in multiple files and + do something with them: > + :vimgrep /theword/jg *.c + :for d in getqflist() + : echo bufname(d.bufnr) ':' d.lnum '=' d.text + :endfor + + +getreg([{regname} [, 1]]) *getreg()* + The result is a String, which is the contents of register + {regname}. Example: > + :let cliptext = getreg('*') +< getreg('=') returns the last evaluated value of the expression + register. (For use in maps.) + getreg('=', 1) returns the expression itself, so that it can + be restored with |setreg()|. For other registers the extra + argument is ignored, thus you can always give it. + If {regname} is not specified, |v:register| is used. + + +getregtype([{regname}]) *getregtype()* + The result is a String, which is type of register {regname}. + The value will be one of: + "v" for |characterwise| text + "V" for |linewise| text + "{width}" for |blockwise-visual| text + 0 for an empty or unknown register + is one character with value 0x16. + If {regname} is not specified, |v:register| is used. + +gettabvar({tabnr}, {varname}) *gettabvar()* + Get the value of a tab-local variable {varname} in tab page + {tabnr}. |t:var| + Tabs are numbered starting with one. + Note that the name without "t:" must be used. + +gettabwinvar({tabnr}, {winnr}, {varname}) *gettabwinvar()* + Get the value of window-local variable {varname} in window + {winnr} in tab page {tabnr}. + When {varname} starts with "&" get the value of a window-local + option. + Tabs are numbered starting with one. For the current tabpage + use |getwinvar()|. + When {winnr} is zero the current window is used. + This also works for a global option, buffer-local option and + window-local option, but it doesn't work for a global variable + or buffer-local variable. + When {varname} is empty a dictionary with all window-local + variables is returned. + Note that {varname} must be the name without "w:". + Examples: > + :let list_is_on = gettabwinvar(1, 2, '&list') + :echo "myvar = " . gettabwinvar(3, 1, 'myvar') +< + *getwinposx()* +getwinposx() The result is a Number, which is the X coordinate in pixels of + the left hand side of the GUI Vim window. The result will be + -1 if the information is not available. + + *getwinposy()* +getwinposy() The result is a Number, which is the Y coordinate in pixels of + the top of the GUI Vim window. The result will be -1 if the + information is not available. + +getwinvar({winnr}, {varname}) *getwinvar()* + Like |gettabwinvar()| for the current tabpage. + Examples: > + :let list_is_on = getwinvar(2, '&list') + :echo "myvar = " . getwinvar(1, 'myvar') +< +glob({expr} [, {flag}]) *glob()* + Expand the file wildcards in {expr}. See |wildcards| for the + use of special characters. + The result is a String. + When there are several matches, they are separated by + characters. + Unless the optional {flag} argument is given and is non-zero, + the 'suffixes' and 'wildignore' options apply: Names matching + one of the patterns in 'wildignore' will be skipped and + 'suffixes' affect the ordering of matches. + If the expansion fails, the result is an empty string. + A name for a non-existing file is not included. + + For most systems backticks can be used to get files names from + any external command. Example: > + :let tagfiles = glob("`find . -name tags -print`") + :let &tags = substitute(tagfiles, "\n", ",", "g") +< The result of the program inside the backticks should be one + item per line. Spaces inside an item are allowed. + + See |expand()| for expanding special Vim variables. See + |system()| for getting the raw output of an external command. + +globpath({path}, {expr} [, {flag}]) *globpath()* + Perform glob() on all directories in {path} and concatenate + the results. Example: > + :echo globpath(&rtp, "syntax/c.vim") +< {path} is a comma-separated list of directory names. Each + directory name is prepended to {expr} and expanded like with + |glob()|. A path separator is inserted when needed. + To add a comma inside a directory name escape it with a + backslash. Note that on MS-Windows a directory may have a + trailing backslash, remove it if you put a comma after it. + If the expansion fails for one of the directories, there is no + error message. + Unless the optional {flag} argument is given and is non-zero, + the 'suffixes' and 'wildignore' options apply: Names matching + one of the patterns in 'wildignore' will be skipped and + 'suffixes' affect the ordering of matches. + + The "**" item can be used to search in a directory tree. + For example, to find all "README.txt" files in the directories + in 'runtimepath' and below: > + :echo globpath(&rtp, "**/README.txt") +< Upwards search and limiting the depth of "**" is not + supported, thus using 'path' will not always work properly. + + *has()* +has({feature}) The result is a Number, which is 1 if the feature {feature} is + supported, zero otherwise. The {feature} argument is a + string. See |feature-list| below. + Also see |exists()|. + + +has_key({dict}, {key}) *has_key()* + The result is a Number, which is 1 if |Dictionary| {dict} has + an entry with key {key}. Zero otherwise. + +haslocaldir() *haslocaldir()* + The result is a Number, which is 1 when the current + window has set a local path via |:lcd|, and 0 otherwise. + +hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()* + The result is a Number, which is 1 if there is a mapping that + contains {what} in somewhere in the rhs (what it is mapped to) + and this mapping exists in one of the modes indicated by + {mode}. + When {abbr} is there and it is non-zero use abbreviations + instead of mappings. Don't forget to specify Insert and/or + Command-line mode. + Both the global mappings and the mappings local to the current + buffer are checked for a match. + If no matching mapping is found 0 is returned. + The following characters are recognized in {mode}: + n Normal mode + v Visual mode + o Operator-pending mode + i Insert mode + l Language-Argument ("r", "f", "t", etc.) + c Command-line mode + When {mode} is omitted, "nvo" is used. + + This function is useful to check if a mapping already exists + to a function in a Vim script. Example: > + :if !hasmapto('\ABCdoit') + : map d \ABCdoit + :endif +< This installs the mapping to "\ABCdoit" only if there isn't + already a mapping to "\ABCdoit". + +histadd({history}, {item}) *histadd()* + Add the String {item} to the history {history} which can be + one of: *hist-names* + "cmd" or ":" command line history + "search" or "/" search pattern history + "expr" or "=" typed expression history + "input" or "@" input line history + If {item} does already exist in the history, it will be + shifted to become the newest entry. + The result is a Number: 1 if the operation was successful, + otherwise 0 is returned. + + Example: > + :call histadd("input", strftime("%Y %b %d")) + :let date=input("Enter date: ") +< This function is not available in the |sandbox|. + +histdel({history} [, {item}]) *histdel()* + Clear {history}, i.e. delete all its entries. See |hist-names| + for the possible values of {history}. + + If the parameter {item} evaluates to a String, it is used as a + regular expression. All entries matching that expression will + be removed from the history (if there are any). + Upper/lowercase must match, unless "\c" is used |/\c|. + If {item} evaluates to a Number, it will be interpreted as + an index, see |:history-indexing|. The respective entry will + be removed if it exists. + + The result is a Number: 1 for a successful operation, + otherwise 0 is returned. + + Examples: + Clear expression register history: > + :call histdel("expr") +< + Remove all entries starting with "*" from the search history: > + :call histdel("/", '^\*') +< + The following three are equivalent: > + :call histdel("search", histnr("search")) + :call histdel("search", -1) + :call histdel("search", '^'.histget("search", -1).'$') +< + To delete the last search pattern and use the last-but-one for + the "n" command and 'hlsearch': > + :call histdel("search", -1) + :let @/ = histget("search", -1) + +histget({history} [, {index}]) *histget()* + The result is a String, the entry with Number {index} from + {history}. See |hist-names| for the possible values of + {history}, and |:history-indexing| for {index}. If there is + no such entry, an empty String is returned. When {index} is + omitted, the most recent item from the history is used. + + Examples: + Redo the second last search from history. > + :execute '/' . histget("search", -2) + +< Define an Ex command ":H {num}" that supports re-execution of + the {num}th entry from the output of |:history|. > + :command -nargs=1 H execute histget("cmd", 0+) +< +histnr({history}) *histnr()* + The result is the Number of the current entry in {history}. + See |hist-names| for the possible values of {history}. + If an error occurred, -1 is returned. + + Example: > + :let inp_index = histnr("expr") +< +hlexists({name}) *hlexists()* + The result is a Number, which is non-zero if a highlight group + called {name} exists. This is when the group has been + defined in some way. Not necessarily when highlighting has + been defined for it, it may also have been used for a syntax + item. + *highlight_exists()* + Obsolete name: highlight_exists(). + + *hlID()* +hlID({name}) The result is a Number, which is the ID of the highlight group + with name {name}. When the highlight group doesn't exist, + zero is returned. + This can be used to retrieve information about the highlight + group. For example, to get the background color of the + "Comment" group: > + :echo synIDattr(synIDtrans(hlID("Comment")), "bg") +< *highlightID()* + Obsolete name: highlightID(). + +hostname() *hostname()* + The result is a String, which is the name of the machine on + which Vim is currently running. Machine names greater than + 256 characters long are truncated. + +iconv({expr}, {from}, {to}) *iconv()* + The result is a String, which is the text {expr} converted + from encoding {from} to encoding {to}. + When the conversion completely fails an empty string is + returned. When some characters could not be converted they + are replaced with "?". + The encoding names are whatever the iconv() library function + can accept, see ":!man 3 iconv". + Most conversions require Vim to be compiled with the |+iconv| + feature. Otherwise only UTF-8 to latin1 conversion and back + can be done. + This can be used to display messages with special characters, + no matter what 'encoding' is set to. Write the message in + UTF-8 and use: > + echo iconv(utf8_str, "utf-8", &enc) +< Note that Vim uses UTF-8 for all Unicode encodings, conversion + from/to UCS-2 is automatically changed to use UTF-8. You + cannot use UCS-2 in a string anyway, because of the NUL bytes. + {only available when compiled with the |+multi_byte| feature} + + *indent()* +indent({lnum}) The result is a Number, which is indent of line {lnum} in the + current buffer. The indent is counted in spaces, the value + of 'tabstop' is relevant. {lnum} is used just like in + |getline()|. + When {lnum} is invalid -1 is returned. + + +index({list}, {expr} [, {start} [, {ic}]]) *index()* + Return the lowest index in |List| {list} where the item has a + value equal to {expr}. There is no automatic conversion, so + the String "4" is different from the Number 4. And the number + 4 is different from the Float 4.0. The value of 'ignorecase' + is not used here, case always matters. + If {start} is given then start looking at the item with index + {start} (may be negative for an item relative to the end). + When {ic} is given and it is non-zero, ignore case. Otherwise + case must match. + -1 is returned when {expr} is not found in {list}. + Example: > + :let idx = index(words, "the") + :if index(numbers, 123) >= 0 + + +input({prompt} [, {text} [, {completion}]]) *input()* + The result is a String, which is whatever the user typed on + the command-line. The {prompt} argument is either a prompt + string, or a blank string (for no prompt). A '\n' can be used + in the prompt to start a new line. + The highlighting set with |:echohl| is used for the prompt. + The input is entered just like a command-line, with the same + editing commands and mappings. There is a separate history + for lines typed for input(). + Example: > + :if input("Coffee or beer? ") == "beer" + : echo "Cheers!" + :endif +< + If the optional {text} argument is present and not empty, this + is used for the default reply, as if the user typed this. + Example: > + :let color = input("Color? ", "white") + +< The optional {completion} argument specifies the type of + completion supported for the input. Without it completion is + not performed. The supported completion types are the same as + that can be supplied to a user-defined command using the + "-complete=" argument. Refer to |:command-completion| for + more information. Example: > + let fname = input("File: ", "", "file") +< + NOTE: This function must not be used in a startup file, for + the versions that only run in GUI mode (e.g., the Win32 GUI). + Note: When input() is called from within a mapping it will + consume remaining characters from that mapping, because a + mapping is handled like the characters were typed. + Use |inputsave()| before input() and |inputrestore()| + after input() to avoid that. Another solution is to avoid + that further characters follow in the mapping, e.g., by using + |:execute| or |:normal|. + + Example with a mapping: > + :nmap \x :call GetFoo():exe "/" . Foo + :function GetFoo() + : call inputsave() + : let g:Foo = input("enter search pattern: ") + : call inputrestore() + :endfunction + +inputdialog({prompt} [, {text} [, {cancelreturn}]]) *inputdialog()* + Like |input()|, but when the GUI is running and text dialogs + are supported, a dialog window pops up to input the text. + Example: > + :let n = inputdialog("value for shiftwidth", &sw) + :if n != "" + : let &sw = n + :endif +< When the dialog is cancelled {cancelreturn} is returned. When + omitted an empty string is returned. + Hitting works like pressing the OK button. Hitting + works like pressing the Cancel button. + NOTE: Command-line completion is not supported. + +inputlist({textlist}) *inputlist()* + {textlist} must be a |List| of strings. This |List| is + displayed, one string per line. The user will be prompted to + enter a number, which is returned. + The user can also select an item by clicking on it with the + mouse. For the first string 0 is returned. When clicking + above the first item a negative number is returned. When + clicking on the prompt one more than the length of {textlist} + is returned. + Make sure {textlist} has less than 'lines' entries, otherwise + it won't work. It's a good idea to put the entry number at + the start of the string. And put a prompt in the first item. + Example: > + let color = inputlist(['Select color:', '1. red', + \ '2. green', '3. blue']) + +inputrestore() *inputrestore()* + Restore typeahead that was saved with a previous |inputsave()|. + Should be called the same number of times inputsave() is + called. Calling it more often is harmless though. + Returns 1 when there is nothing to restore, 0 otherwise. + +inputsave() *inputsave()* + Preserve typeahead (also from mappings) and clear it, so that + a following prompt gets input from the user. Should be + followed by a matching inputrestore() after the prompt. Can + be used several times, in which case there must be just as + many inputrestore() calls. + Returns 1 when out of memory, 0 otherwise. + +inputsecret({prompt} [, {text}]) *inputsecret()* + This function acts much like the |input()| function with but + two exceptions: + a) the user's response will be displayed as a sequence of + asterisks ("*") thereby keeping the entry secret, and + b) the user's response will not be recorded on the input + |history| stack. + The result is a String, which is whatever the user actually + typed on the command-line in response to the issued prompt. + NOTE: Command-line completion is not supported. + +insert({list}, {item} [, {idx}]) *insert()* + Insert {item} at the start of |List| {list}. + If {idx} is specified insert {item} before the item with index + {idx}. If {idx} is zero it goes before the first item, just + like omitting {idx}. A negative {idx} is also possible, see + |list-index|. -1 inserts just before the last item. + Returns the resulting |List|. Examples: > + :let mylist = insert([2, 3, 5], 1) + :call insert(mylist, 4, -1) + :call insert(mylist, 6, len(mylist)) +< The last example can be done simpler with |add()|. + Note that when {item} is a |List| it is inserted as a single + item. Use |extend()| to concatenate |Lists|. + +isdirectory({directory}) *isdirectory()* + The result is a Number, which is non-zero when a directory + with the name {directory} exists. If {directory} doesn't + exist, or isn't a directory, the result is FALSE. {directory} + is any expression, which is used as a String. + +islocked({expr}) *islocked()* *E786* + The result is a Number, which is non-zero when {expr} is the + name of a locked variable. + {expr} must be the name of a variable, |List| item or + |Dictionary| entry, not the variable itself! Example: > + :let alist = [0, ['a', 'b'], 2, 3] + :lockvar 1 alist + :echo islocked('alist') " 1 + :echo islocked('alist[1]') " 0 + +< When {expr} is a variable that does not exist you get an error + message. Use |exists()| to check for existence. + +items({dict}) *items()* + Return a |List| with all the key-value pairs of {dict}. Each + |List| item is a list with two items: the key of a {dict} + entry and the value of this entry. The |List| is in arbitrary + order. + + +join({list} [, {sep}]) *join()* + Join the items in {list} together into one String. + When {sep} is specified it is put in between the items. If + {sep} is omitted a single space is used. + Note that {sep} is not added at the end. You might want to + add it there too: > + let lines = join(mylist, "\n") . "\n" +< String items are used as-is. |Lists| and |Dictionaries| are + converted into a string like with |string()|. + The opposite function is |split()|. + +keys({dict}) *keys()* + Return a |List| with all the keys of {dict}. The |List| is in + arbitrary order. + + *len()* *E701* +len({expr}) The result is a Number, which is the length of the argument. + When {expr} is a String or a Number the length in bytes is + used, as with |strlen()|. + When {expr} is a |List| the number of items in the |List| is + returned. + When {expr} is a |Dictionary| the number of entries in the + |Dictionary| is returned. + Otherwise an error is given. + + *libcall()* *E364* *E368* +libcall({libname}, {funcname}, {argument}) + Call function {funcname} in the run-time library {libname} + with single argument {argument}. + This is useful to call functions in a library that you + especially made to be used with Vim. Since only one argument + is possible, calling standard library functions is rather + limited. + The result is the String returned by the function. If the + function returns NULL, this will appear as an empty string "" + to Vim. + If the function returns a number, use libcallnr()! + If {argument} is a number, it is passed to the function as an + int; if {argument} is a string, it is passed as a + null-terminated string. + This function will fail in |restricted-mode|. + + libcall() allows you to write your own 'plug-in' extensions to + Vim without having to recompile the program. It is NOT a + means to call system functions! If you try to do so Vim will + very probably crash. + + For Win32, the functions you write must be placed in a DLL + and use the normal C calling convention (NOT Pascal which is + used in Windows System DLLs). The function must take exactly + one parameter, either a character pointer or a long integer, + and must return a character pointer or NULL. The character + pointer returned must point to memory that will remain valid + after the function has returned (e.g. in static data in the + DLL). If it points to allocated memory, that memory will + leak away. Using a static buffer in the function should work, + it's then freed when the DLL is unloaded. + + WARNING: If the function returns a non-valid pointer, Vim may + crash! This also happens if the function returns a number, + because Vim thinks it's a pointer. + For Win32 systems, {libname} should be the filename of the DLL + without the ".DLL" suffix. A full path is only required if + the DLL is not in the usual places. + For Unix: When compiling your own plugins, remember that the + object code must be compiled as position-independent ('PIC'). + {only in Win32 and some Unix versions, when the |+libcall| + feature is present} + Examples: > + :echo libcall("libc.so", "getenv", "HOME") +< + *libcallnr()* +libcallnr({libname}, {funcname}, {argument}) + Just like |libcall()|, but used for a function that returns an + int instead of a string. + {only in Win32 on some Unix versions, when the |+libcall| + feature is present} + Examples: > + :echo libcallnr("/usr/lib/libc.so", "getpid", "") + :call libcallnr("libc.so", "printf", "Hello World!\n") + :call libcallnr("libc.so", "sleep", 10) +< + *line()* +line({expr}) The result is a Number, which is the line number of the file + position given with {expr}. The accepted positions are: + . the cursor position + $ the last line in the current buffer + 'x position of mark x (if the mark is not set, 0 is + returned) + w0 first line visible in current window + w$ last line visible in current window + v In Visual mode: the start of the Visual area (the + cursor is the end). When not in Visual mode + returns the cursor position. Differs from |'<| in + that it's updated right away. + Note that a mark in another file can be used. The line number + then applies to another buffer. + To get the column number use |col()|. To get both use + |getpos()|. + Examples: > + line(".") line number of the cursor + line("'t") line number of mark t + line("'" . marker) line number of mark marker +< *last-position-jump* + This autocommand jumps to the last known position in a file + just after opening it, if the '" mark is set: > + :au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif + +line2byte({lnum}) *line2byte()* + Return the byte count from the start of the buffer for line + {lnum}. This includes the end-of-line character, depending on + the 'fileformat' option for the current buffer. The first + line returns 1. + This can also be used to get the byte count for the line just + below the last line: > + line2byte(line("$") + 1) +< This is the file size plus one. + When {lnum} is invalid, or the |+byte_offset| feature has been + disabled at compile time, -1 is returned. + Also see |byte2line()|, |go| and |:goto|. + +lispindent({lnum}) *lispindent()* + Get the amount of indent for line {lnum} according the lisp + indenting rules, as with 'lisp'. + The indent is counted in spaces, the value of 'tabstop' is + relevant. {lnum} is used just like in |getline()|. + When {lnum} is invalid or Vim was not compiled the + |+lispindent| feature, -1 is returned. + +localtime() *localtime()* + Return the current time, measured as seconds since 1st Jan + 1970. See also |strftime()| and |getftime()|. + + +log({expr}) *log()* + Return the natural logarithm (base e) of {expr} as a |Float|. + {expr} must evaluate to a |Float| or a |Number| in the range + (0, inf]. + Examples: > + :echo log(10) +< 2.302585 > + :echo log(exp(5)) +< 5.0 + {only available when compiled with the |+float| feature} + + +log10({expr}) *log10()* + Return the logarithm of Float {expr} to base 10 as a |Float|. + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + :echo log10(1000) +< 3.0 > + :echo log10(0.01) +< -2.0 + {only available when compiled with the |+float| feature} + +map({expr}, {string}) *map()* + {expr} must be a |List| or a |Dictionary|. + Replace each item in {expr} with the result of evaluating + {string}. + Inside {string} |v:val| has the value of the current item. + For a |Dictionary| |v:key| has the key of the current item + and for a |List| |v:key| has the index of the current item. + Example: > + :call map(mylist, '"> " . v:val . " <"') +< This puts "> " before and " <" after each item in "mylist". + + Note that {string} is the result of an expression and is then + used as an expression again. Often it is good to use a + |literal-string| to avoid having to double backslashes. You + still have to double ' quotes + + The operation is done in-place. If you want a |List| or + |Dictionary| to remain unmodified make a copy first: > + :let tlist = map(copy(mylist), ' & . "\t"') + +< Returns {expr}, the |List| or |Dictionary| that was filtered. + When an error is encountered while evaluating {string} no + further items in {expr} are processed. + + +maparg({name}[, {mode} [, {abbr} [, {dict}]]]) *maparg()* + When {dict} is omitted or zero: Return the rhs of mapping + {name} in mode {mode}. The returned String has special + characters translated like in the output of the ":map" command + listing. + + When there is no mapping for {name}, an empty String is + returned. + + The {name} can have special key names, like in the ":map" + command. + + {mode} can be one of these strings: + "n" Normal + "v" Visual (including Select) + "o" Operator-pending + "i" Insert + "c" Cmd-line + "s" Select + "x" Visual + "l" langmap |language-mapping| + "" Normal, Visual and Operator-pending + When {mode} is omitted, the modes for "" are used. + + When {abbr} is there and it is non-zero use abbreviations + instead of mappings. + + When {dict} is there and it is non-zero return a dictionary + containing all the information of the mapping with the + following items: + "lhs" The {lhs} of the mapping. + "rhs" The {rhs} of the mapping as typed. + "silent" 1 for a |:map-silent| mapping, else 0. + "noremap" 1 if the {rhs} of the mapping is remappable. + "expr" 1 for an expression mapping (|:map-|). + "buffer" 1 for a buffer local mapping (|:map-local|). + "mode" Modes for which the mapping is defined. In + addition to the modes mentioned above, these + characters will be used: + " " Normal, Visual and Operator-pending + "!" Insert and Commandline mode + (|mapmpde-ic|) + "sid" the Script local ID, used for mappings + (||) + + The mappings local to the current buffer are checked first, + then the global mappings. + This function can be used to map a key even when it's already + mapped, and have it do the original mapping too. Sketch: > + exe 'nnoremap ==' . maparg('', 'n') + + +mapcheck({name}[, {mode} [, {abbr}]]) *mapcheck()* + Check if there is a mapping that matches with {name} in mode + {mode}. See |maparg()| for {mode} and special names in + {name}. + When {abbr} is there and it is non-zero use abbreviations + instead of mappings. + A match happens with a mapping that starts with {name} and + with a mapping which is equal to the start of {name}. + + matches mapping "a" "ab" "abc" ~ + mapcheck("a") yes yes yes + mapcheck("abc") yes yes yes + mapcheck("ax") yes no no + mapcheck("b") no no no + + The difference with maparg() is that mapcheck() finds a + mapping that matches with {name}, while maparg() only finds a + mapping for {name} exactly. + When there is no mapping that starts with {name}, an empty + String is returned. If there is one, the rhs of that mapping + is returned. If there are several mappings that start with + {name}, the rhs of one of them is returned. + The mappings local to the current buffer are checked first, + then the global mappings. + This function can be used to check if a mapping can be added + without being ambiguous. Example: > + :if mapcheck("_vv") == "" + : map _vv :set guifont=7x13 + :endif +< This avoids adding the "_vv" mapping when there already is a + mapping for "_v" or for "_vvv". + +match({expr}, {pat}[, {start}[, {count}]]) *match()* + When {expr} is a |List| then this returns the index of the + first item where {pat} matches. Each item is used as a + String, |Lists| and |Dictionaries| are used as echoed. + Otherwise, {expr} is used as a String. The result is a + Number, which gives the index (byte offset) in {expr} where + {pat} matches. + A match at the first character or |List| item returns zero. + If there is no match -1 is returned. + Example: > + :echo match("testing", "ing") " results in 4 + :echo match([1, 'x'], '\a') " results in 1 +< See |string-match| for how {pat} is used. + *strpbrk()* + Vim doesn't have a strpbrk() function. But you can do: > + :let sepidx = match(line, '[.,;: \t]') +< *strcasestr()* + Vim doesn't have a strcasestr() function. But you can add + "\c" to the pattern to ignore case: > + :let idx = match(haystack, '\cneedle') +< + If {start} is given, the search starts from byte index + {start} in a String or item {start} in a |List|. + The result, however, is still the index counted from the + first character/item. Example: > + :echo match("testing", "ing", 2) +< result is again "4". > + :echo match("testing", "ing", 4) +< result is again "4". > + :echo match("testing", "t", 2) +< result is "3". + For a String, if {start} > 0 then it is like the string starts + {start} bytes later, thus "^" will match at {start}. Except + when {count} is given, then it's like matches before the + {start} byte are ignored (this is a bit complicated to keep it + backwards compatible). + For a String, if {start} < 0, it will be set to 0. For a list + the index is counted from the end. + If {start} is out of range ({start} > strlen({expr}) for a + String or {start} > len({expr}) for a |List|) -1 is returned. + + When {count} is given use the {count}'th match. When a match + is found in a String the search for the next one starts one + character further. Thus this example results in 1: > + echo match("testing", "..", 0, 2) +< In a |List| the search continues in the next item. + Note that when {count} is added the way {start} works changes, + see above. + + See |pattern| for the patterns that are accepted. + The 'ignorecase' option is used to set the ignore-caseness of + the pattern. 'smartcase' is NOT used. The matching is always + done like 'magic' is set and 'cpoptions' is empty. + + *matchadd()* *E798* *E799* *E801* +matchadd({group}, {pattern}[, {priority}[, {id}]]) + Defines a pattern to be highlighted in the current window (a + "match"). It will be highlighted with {group}. Returns an + identification number (ID), which can be used to delete the + match using |matchdelete()|. + + The optional {priority} argument assigns a priority to the + match. A match with a high priority will have its + highlighting overrule that of a match with a lower priority. + A priority is specified as an integer (negative numbers are no + exception). If the {priority} argument is not specified, the + default priority is 10. The priority of 'hlsearch' is zero, + hence all matches with a priority greater than zero will + overrule it. Syntax highlighting (see 'syntax') is a separate + mechanism, and regardless of the chosen priority a match will + always overrule syntax highlighting. + + The optional {id} argument allows the request for a specific + match ID. If a specified ID is already taken, an error + message will appear and the match will not be added. An ID + is specified as a positive integer (zero excluded). IDs 1, 2 + and 3 are reserved for |:match|, |:2match| and |:3match|, + respectively. If the {id} argument is not specified, + |matchadd()| automatically chooses a free ID. + + The number of matches is not limited, as it is the case with + the |:match| commands. + + Example: > + :highlight MyGroup ctermbg=green guibg=green + :let m = matchadd("MyGroup", "TODO") +< Deletion of the pattern: > + :call matchdelete(m) + +< A list of matches defined by |matchadd()| and |:match| are + available from |getmatches()|. All matches can be deleted in + one operation by |clearmatches()|. + +matcharg({nr}) *matcharg()* + Selects the {nr} match item, as set with a |:match|, + |:2match| or |:3match| command. + Return a |List| with two elements: + The name of the highlight group used + The pattern used. + When {nr} is not 1, 2 or 3 returns an empty |List|. + When there is no match item set returns ['', '']. + This is useful to save and restore a |:match|. + Highlighting matches using the |:match| commands are limited + to three matches. |matchadd()| does not have this limitation. + +matchdelete({id}) *matchdelete()* *E802* *E803* + Deletes a match with ID {id} previously defined by |matchadd()| + or one of the |:match| commands. Returns 0 if successful, + otherwise -1. See example for |matchadd()|. All matches can + be deleted in one operation by |clearmatches()|. + +matchend({expr}, {pat}[, {start}[, {count}]]) *matchend()* + Same as |match()|, but return the index of first character + after the match. Example: > + :echo matchend("testing", "ing") +< results in "7". + *strspn()* *strcspn()* + Vim doesn't have a strspn() or strcspn() function, but you can + do it with matchend(): > + :let span = matchend(line, '[a-zA-Z]') + :let span = matchend(line, '[^a-zA-Z]') +< Except that -1 is returned when there are no matches. + + The {start}, if given, has the same meaning as for |match()|. > + :echo matchend("testing", "ing", 2) +< results in "7". > + :echo matchend("testing", "ing", 5) +< result is "-1". + When {expr} is a |List| the result is equal to |match()|. + +matchlist({expr}, {pat}[, {start}[, {count}]]) *matchlist()* + Same as |match()|, but return a |List|. The first item in the + list is the matched string, same as what matchstr() would + return. Following items are submatches, like "\1", "\2", etc. + in |:substitute|. When an optional submatch didn't match an + empty string is used. Example: > + echo matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)') +< Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', ''] + When there is no match an empty list is returned. + +matchstr({expr}, {pat}[, {start}[, {count}]]) *matchstr()* + Same as |match()|, but return the matched string. Example: > + :echo matchstr("testing", "ing") +< results in "ing". + When there is no match "" is returned. + The {start}, if given, has the same meaning as for |match()|. > + :echo matchstr("testing", "ing", 2) +< results in "ing". > + :echo matchstr("testing", "ing", 5) +< result is "". + When {expr} is a |List| then the matching item is returned. + The type isn't changed, it's not necessarily a String. + + *max()* +max({list}) Return the maximum value of all items in {list}. + If {list} is not a list or one of the items in {list} cannot + be used as a Number this results in an error. + An empty |List| results in zero. + + *min()* +min({list}) Return the minimum value of all items in {list}. + If {list} is not a list or one of the items in {list} cannot + be used as a Number this results in an error. + An empty |List| results in zero. + + *mkdir()* *E739* +mkdir({name} [, {path} [, {prot}]]) + Create directory {name}. + If {path} is "p" then intermediate directories are created as + necessary. Otherwise it must be "". + If {prot} is given it is used to set the protection bits of + the new directory. The default is 0755 (rwxr-xr-x: r/w for + the user readable for others). Use 0700 to make it unreadable + for others. This is only used for the last part of {name}. + Thus if you create /tmp/foo/bar then /tmp/foo will be created + with 0755. + Example: > + :call mkdir($HOME . "/tmp/foo/bar", "p", 0700) +< This function is not available in the |sandbox|. + Not available on all systems. To check use: > + :if exists("*mkdir") +< + *mode()* +mode([expr]) Return a string that indicates the current mode. + If [expr] is supplied and it evaluates to a non-zero Number or + a non-empty String (|non-zero-arg|), then the full mode is + returned, otherwise only the first letter is returned. Note + that " " and "0" are also non-empty strings. + + n Normal + no Operator-pending + v Visual by character + V Visual by line + CTRL-V Visual blockwise + s Select by character + S Select by line + CTRL-S Select blockwise + i Insert + R Replace |R| + Rv Virtual Replace |gR| + c Command-line + cv Vim Ex mode |gQ| + ce Normal Ex mode |Q| + r Hit-enter prompt + rm The -- more -- prompt + r? A |:confirm| query of some sort + ! Shell or external command is executing + This is useful in the 'statusline' option or when used + with |remote_expr()| In most other places it always returns + "c" or "n". + Also see |visualmode()|. + +mzeval({expr}) *mzeval()* + Evaluate MzScheme expression {expr} and return its result + convert to Vim data structures. + Numbers and strings are returned as they are. + Pairs (including lists and improper lists) and vectors are + returned as Vim |Lists|. + Hash tables are represented as Vim |Dictionary| type with keys + converted to strings. + All other types are converted to string with display function. + Examples: > + :mz (define l (list 1 2 3)) + :mz (define h (make-hash)) (hash-set! h "list" l) + :echo mzeval("l") + :echo mzeval("h") +< + {only available when compiled with the |+mzscheme| feature} + +nextnonblank({lnum}) *nextnonblank()* + Return the line number of the first line at or below {lnum} + that is not blank. Example: > + if getline(nextnonblank(1)) =~ "Java" +< When {lnum} is invalid or there is no non-blank line at or + below it, zero is returned. + See also |prevnonblank()|. + +nr2char({expr}) *nr2char()* + Return a string with a single character, which has the number + value {expr}. Examples: > + nr2char(64) returns "@" + nr2char(32) returns " " +< The current 'encoding' is used. Example for "utf-8": > + nr2char(300) returns I with bow character +< Note that a NUL character in the file is specified with + nr2char(10), because NULs are represented with newline + characters. nr2char(0) is a real NUL and terminates the + string, thus results in an empty string. + + *getpid()* +getpid() Return a Number which is the process ID of the Vim process. + On Unix and MS-Windows this is a unique number, until Vim + exits. On MS-DOS it's always zero. + + *getpos()* +getpos({expr}) Get the position for {expr}. For possible values of {expr} + see |line()|. + The result is a |List| with four numbers: + [bufnum, lnum, col, off] + "bufnum" is zero, unless a mark like '0 or 'A is used, then it + is the buffer number of the mark. + "lnum" and "col" are the position in the buffer. The first + column is 1. + The "off" number is zero, unless 'virtualedit' is used. Then + it is the offset in screen columns from the start of the + character. E.g., a position within a or after the last + character. + This can be used to save and restore the cursor position: > + let save_cursor = getpos(".") + MoveTheCursorAround + call setpos('.', save_cursor) +< Also see |setpos()|. + +pathshorten({expr}) *pathshorten()* + Shorten directory names in the path {expr} and return the + result. The tail, the file name, is kept as-is. The other + components in the path are reduced to single letters. Leading + '~' and '.' characters are kept. Example: > + :echo pathshorten('~/.vim/autoload/myfile.vim') +< ~/.v/a/myfile.vim ~ + It doesn't matter if the path exists or not. + +pow({x}, {y}) *pow()* + Return the power of {x} to the exponent {y} as a |Float|. + {x} and {y} must evaluate to a |Float| or a |Number|. + Examples: > + :echo pow(3, 3) +< 27.0 > + :echo pow(2, 16) +< 65536.0 > + :echo pow(32, 0.20) +< 2.0 + {only available when compiled with the |+float| feature} + +prevnonblank({lnum}) *prevnonblank()* + Return the line number of the first line at or above {lnum} + that is not blank. Example: > + let ind = indent(prevnonblank(v:lnum - 1)) +< When {lnum} is invalid or there is no non-blank line at or + above it, zero is returned. + Also see |nextnonblank()|. + + +printf({fmt}, {expr1} ...) *printf()* + Return a String with {fmt}, where "%" items are replaced by + the formatted form of their respective arguments. Example: > + printf("%4d: E%d %.30s", lnum, errno, msg) +< May result in: + " 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~ + + Often used items are: + %s string + %6s string right-aligned in 6 bytes + %.9s string truncated to 9 bytes + %c single byte + %d decimal number + %5d decimal number padded with spaces to 5 characters + %x hex number + %04x hex number padded with zeros to at least 4 characters + %X hex number using upper case letters + %o octal number + %f floating point number in the form 123.456 + %e floating point number in the form 1.234e3 + %E floating point number in the form 1.234E3 + %g floating point number, as %f or %e depending on value + %G floating point number, as %f or %E depending on value + %% the % character itself + + Conversion specifications start with '%' and end with the + conversion type. All other characters are copied unchanged to + the result. + + The "%" starts a conversion specification. The following + arguments appear in sequence: + + % [flags] [field-width] [.precision] type + + flags + Zero or more of the following flags: + + # The value should be converted to an "alternate + form". For c, d, and s conversions, this option + has no effect. For o conversions, the precision + of the number is increased to force the first + character of the output string to a zero (except + if a zero value is printed with an explicit + precision of zero). + For x and X conversions, a non-zero result has + the string "0x" (or "0X" for X conversions) + prepended to it. + + 0 (zero) Zero padding. For all conversions the converted + value is padded on the left with zeros rather + than blanks. If a precision is given with a + numeric conversion (d, o, x, and X), the 0 flag + is ignored. + + - A negative field width flag; the converted value + is to be left adjusted on the field boundary. + The converted value is padded on the right with + blanks, rather than on the left with blanks or + zeros. A - overrides a 0 if both are given. + + ' ' (space) A blank should be left before a positive + number produced by a signed conversion (d). + + + A sign must always be placed before a number + produced by a signed conversion. A + overrides + a space if both are used. + + field-width + An optional decimal digit string specifying a minimum + field width. If the converted value has fewer bytes + than the field width, it will be padded with spaces on + the left (or right, if the left-adjustment flag has + been given) to fill out the field width. + + .precision + An optional precision, in the form of a period '.' + followed by an optional digit string. If the digit + string is omitted, the precision is taken as zero. + This gives the minimum number of digits to appear for + d, o, x, and X conversions, or the maximum number of + bytes to be printed from a string for s conversions. + For floating point it is the number of digits after + the decimal point. + + type + A character that specifies the type of conversion to + be applied, see below. + + A field width or precision, or both, may be indicated by an + asterisk '*' instead of a digit string. In this case, a + Number argument supplies the field width or precision. A + negative field width is treated as a left adjustment flag + followed by a positive field width; a negative precision is + treated as though it were missing. Example: > + :echo printf("%d: %.*s", nr, width, line) +< This limits the length of the text used from "line" to + "width" bytes. + + The conversion specifiers and their meanings are: + + *printf-d* *printf-o* *printf-x* *printf-X* + doxX The Number argument is converted to signed decimal + (d), unsigned octal (o), or unsigned hexadecimal (x + and X) notation. The letters "abcdef" are used for + x conversions; the letters "ABCDEF" are used for X + conversions. + The precision, if any, gives the minimum number of + digits that must appear; if the converted value + requires fewer digits, it is padded on the left with + zeros. + In no case does a non-existent or small field width + cause truncation of a numeric field; if the result of + a conversion is wider than the field width, the field + is expanded to contain the conversion result. + + *printf-c* + c The Number argument is converted to a byte, and the + resulting character is written. + + *printf-s* + s The text of the String argument is used. If a + precision is specified, no more bytes than the number + specified are used. + + *printf-f* *E807* + f The Float argument is converted into a string of the + form 123.456. The precision specifies the number of + digits after the decimal point. When the precision is + zero the decimal point is omitted. When the precision + is not specified 6 is used. A really big number + (out of range or dividing by zero) results in "inf". + "0.0 / 0.0" results in "nan". + Example: > + echo printf("%.2f", 12.115) +< 12.12 + Note that roundoff depends on the system libraries. + Use |round()| when in doubt. + + *printf-e* *printf-E* + e E The Float argument is converted into a string of the + form 1.234e+03 or 1.234E+03 when using 'E'. The + precision specifies the number of digits after the + decimal point, like with 'f'. + + *printf-g* *printf-G* + g G The Float argument is converted like with 'f' if the + value is between 0.001 (inclusive) and 10000000.0 + (exclusive). Otherwise 'e' is used for 'g' and 'E' + for 'G'. When no precision is specified superfluous + zeroes and '+' signs are removed, except for the zero + immediately after the decimal point. Thus 10000000.0 + results in 1.0e7. + + *printf-%* + % A '%' is written. No argument is converted. The + complete conversion specification is "%%". + + When a Number argument is expected a String argument is also + accepted and automatically converted. + When a Float or String argument is expected a Number argument + is also accepted and automatically converted. + Any other argument type results in an error message. + + *E766* *E767* + The number of {exprN} arguments must exactly match the number + of "%" items. If there are not sufficient or too many + arguments an error is given. Up to 18 arguments can be used. + + +pumvisible() *pumvisible()* + Returns non-zero when the popup menu is visible, zero + otherwise. See |ins-completion-menu|. + This can be used to avoid some things that would remove the + popup menu. + + *E726* *E727* +range({expr} [, {max} [, {stride}]]) *range()* + Returns a |List| with Numbers: + - If only {expr} is specified: [0, 1, ..., {expr} - 1] + - If {max} is specified: [{expr}, {expr} + 1, ..., {max}] + - If {stride} is specified: [{expr}, {expr} + {stride}, ..., + {max}] (increasing {expr} with {stride} each time, not + producing a value past {max}). + When the maximum is one before the start the result is an + empty list. When the maximum is more than one before the + start this is an error. + Examples: > + range(4) " [0, 1, 2, 3] + range(2, 4) " [2, 3, 4] + range(2, 9, 3) " [2, 5, 8] + range(2, -2, -1) " [2, 1, 0, -1, -2] + range(0) " [] + range(2, 0) " error! +< + *readfile()* +readfile({fname} [, {binary} [, {max}]]) + Read file {fname} and return a |List|, each line of the file + as an item. Lines broken at NL characters. Macintosh files + separated with CR will result in a single long line (unless a + NL appears somewhere). + All NUL characters are replaced with a NL character. + When {binary} is equal to "b" binary mode is used: + - When the last line ends in a NL an extra empty list item is + added. + - No CR characters are removed. + Otherwise: + - CR characters that appear before a NL are removed. + - Whether the last line ends in a NL or not does not matter. + - When 'encoding' is Unicode any UTF-8 byte order mark is + removed from the text. + When {max} is given this specifies the maximum number of lines + to be read. Useful if you only want to check the first ten + lines of a file: > + :for line in readfile(fname, '', 10) + : if line =~ 'Date' | echo line | endif + :endfor +< When {max} is negative -{max} lines from the end of the file + are returned, or as many as there are. + When {max} is zero the result is an empty list. + Note that without {max} the whole file is read into memory. + Also note that there is no recognition of encoding. Read a + file into a buffer if you need to. + When the file can't be opened an error message is given and + the result is an empty list. + Also see |writefile()|. + +reltime([{start} [, {end}]]) *reltime()* + Return an item that represents a time value. The format of + the item depends on the system. It can be passed to + |reltimestr()| to convert it to a string. + Without an argument it returns the current time. + With one argument is returns the time passed since the time + specified in the argument. + With two arguments it returns the time passed between {start} + and {end}. + The {start} and {end} arguments must be values returned by + reltime(). + {only available when compiled with the |+reltime| feature} + +reltimestr({time}) *reltimestr()* + Return a String that represents the time value of {time}. + This is the number of seconds, a dot and the number of + microseconds. Example: > + let start = reltime() + call MyFunction() + echo reltimestr(reltime(start)) +< Note that overhead for the commands will be added to the time. + The accuracy depends on the system. + Leading spaces are used to make the string align nicely. You + can use split() to remove it. > + echo split(reltimestr(reltime(start)))[0] +< Also see |profiling|. + {only available when compiled with the |+reltime| feature} + + *remote_expr()* *E449* +remote_expr({server}, {string} [, {idvar}]) + Send the {string} to {server}. The string is sent as an + expression and the result is returned after evaluation. + The result must be a String or a |List|. A |List| is turned + into a String by joining the items with a line break in + between (not at the end), like with join(expr, "\n"). + If {idvar} is present, it is taken as the name of a + variable and a {serverid} for later use with + remote_read() is stored there. + See also |clientserver| |RemoteReply|. + This function is not available in the |sandbox|. + {only available when compiled with the |+clientserver| feature} + Note: Any errors will cause a local error message to be issued + and the result will be the empty string. + Examples: > + :echo remote_expr("gvim", "2+2") + :echo remote_expr("gvim1", "b:current_syntax") +< + +remote_foreground({server}) *remote_foreground()* + Move the Vim server with the name {server} to the foreground. + This works like: > + remote_expr({server}, "foreground()") +< Except that on Win32 systems the client does the work, to work + around the problem that the OS doesn't always allow the server + to bring itself to the foreground. + Note: This does not restore the window if it was minimized, + like foreground() does. + This function is not available in the |sandbox|. + {only in the Win32, Athena, Motif and GTK GUI versions and the + Win32 console version} + + +remote_peek({serverid} [, {retvar}]) *remote_peek()* + Returns a positive number if there are available strings + from {serverid}. Copies any reply string into the variable + {retvar} if specified. {retvar} must be a string with the + name of a variable. + Returns zero if none are available. + Returns -1 if something is wrong. + See also |clientserver|. + This function is not available in the |sandbox|. + {only available when compiled with the |+clientserver| feature} + Examples: > + :let repl = "" + :echo "PEEK: ".remote_peek(id, "repl").": ".repl + +remote_read({serverid}) *remote_read()* + Return the oldest available reply from {serverid} and consume + it. It blocks until a reply is available. + See also |clientserver|. + This function is not available in the |sandbox|. + {only available when compiled with the |+clientserver| feature} + Example: > + :echo remote_read(id) +< + *remote_send()* *E241* +remote_send({server}, {string} [, {idvar}]) + Send the {string} to {server}. The string is sent as input + keys and the function returns immediately. At the Vim server + the keys are not mapped |:map|. + If {idvar} is present, it is taken as the name of a variable + and a {serverid} for later use with remote_read() is stored + there. + See also |clientserver| |RemoteReply|. + This function is not available in the |sandbox|. + {only available when compiled with the |+clientserver| feature} + Note: Any errors will be reported in the server and may mess + up the display. + Examples: > + :echo remote_send("gvim", ":DropAndReply ".file, "serverid"). + \ remote_read(serverid) + + :autocmd NONE RemoteReply * + \ echo remote_read(expand("")) + :echo remote_send("gvim", ":sleep 10 | echo ". + \ 'server2client(expand(""), "HELLO")') +< +remove({list}, {idx} [, {end}]) *remove()* + Without {end}: Remove the item at {idx} from |List| {list} and + return the item. + With {end}: Remove items from {idx} to {end} (inclusive) and + return a List with these items. When {idx} points to the same + item as {end} a list with one item is returned. When {end} + points to an item before {idx} this is an error. + See |list-index| for possible values of {idx} and {end}. + Example: > + :echo "last item: " . remove(mylist, -1) + :call remove(mylist, 0, 9) +remove({dict}, {key}) + Remove the entry from {dict} with key {key}. Example: > + :echo "removed " . remove(dict, "one") +< If there is no {key} in {dict} this is an error. + + Use |delete()| to remove a file. + +rename({from}, {to}) *rename()* + Rename the file by the name {from} to the name {to}. This + should also work to move files across file systems. The + result is a Number, which is 0 if the file was renamed + successfully, and non-zero when the renaming failed. + NOTE: If {to} exists it is overwritten without warning. + This function is not available in the |sandbox|. + +repeat({expr}, {count}) *repeat()* + Repeat {expr} {count} times and return the concatenated + result. Example: > + :let separator = repeat('-', 80) +< When {count} is zero or negative the result is empty. + When {expr} is a |List| the result is {expr} concatenated + {count} times. Example: > + :let longlist = repeat(['a', 'b'], 3) +< Results in ['a', 'b', 'a', 'b', 'a', 'b']. + + +resolve({filename}) *resolve()* *E655* + On MS-Windows, when {filename} is a shortcut (a .lnk file), + returns the path the shortcut points to in a simplified form. + On Unix, repeat resolving symbolic links in all path + components of {filename} and return the simplified result. + To cope with link cycles, resolving of symbolic links is + stopped after 100 iterations. + On other systems, return the simplified {filename}. + The simplification step is done as by |simplify()|. + resolve() keeps a leading path component specifying the + current directory (provided the result is still a relative + path name) and also keeps a trailing path separator. + + *reverse()* +reverse({list}) Reverse the order of items in {list} in-place. Returns + {list}. + If you want a list to remain unmodified make a copy first: > + :let revlist = reverse(copy(mylist)) + +round({expr}) *round()* + Round off {expr} to the nearest integral value and return it + as a |Float|. If {expr} lies halfway between two integral + values, then use the larger one (away from zero). + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + echo round(0.456) +< 0.0 > + echo round(4.5) +< 5.0 > + echo round(-4.5) +< -5.0 + {only available when compiled with the |+float| feature} + + +search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *search()* + Search for regexp pattern {pattern}. The search starts at the + cursor position (you can use |cursor()| to set it). + + {flags} is a String, which can contain these character flags: + 'b' search backward instead of forward + 'c' accept a match at the cursor position + 'e' move to the End of the match + 'n' do Not move the cursor + 'p' return number of matching sub-pattern (see below) + 's' set the ' mark at the previous location of the cursor + 'w' wrap around the end of the file + 'W' don't wrap around the end of the file + If neither 'w' or 'W' is given, the 'wrapscan' option applies. + + If the 's' flag is supplied, the ' mark is set, only if the + cursor is moved. The 's' flag cannot be combined with the 'n' + flag. + + 'ignorecase', 'smartcase' and 'magic' are used. + + When the {stopline} argument is given then the search stops + after searching this line. This is useful to restrict the + search to a range of lines. Examples: > + let match = search('(', 'b', line("w0")) + let end = search('END', '', line("w$")) +< When {stopline} is used and it is not zero this also implies + that the search does not wrap around the end of the file. + A zero value is equal to not giving the argument. + + When the {timeout} argument is given the search stops when + more than this many milli seconds have passed. Thus when + {timeout} is 500 the search stops after half a second. + The value must not be negative. A zero value is like not + giving the argument. + {only available when compiled with the |+reltime| feature} + + If there is no match a 0 is returned and the cursor doesn't + move. No error message is given. + When a match has been found its line number is returned. + *search()-sub-match* + With the 'p' flag the returned value is one more than the + first sub-match in \(\). One if none of them matched but the + whole pattern did match. + To get the column number too use |searchpos()|. + + The cursor will be positioned at the match, unless the 'n' + flag is used. + + Example (goes over all files in the argument list): > + :let n = 1 + :while n <= argc() " loop over all files in arglist + : exe "argument " . n + : " start at the last char in the file and wrap for the + : " first search to find match at start of file + : normal G$ + : let flags = "w" + : while search("foo", flags) > 0 + : s/foo/bar/g + : let flags = "W" + : endwhile + : update " write the file if modified + : let n = n + 1 + :endwhile +< + Example for using some flags: > + :echo search('\ + if searchdecl('myvar') == 0 + echo getline('.') + endif +< + *searchpair()* +searchpair({start}, {middle}, {end} [, {flags} [, {skip} + [, {stopline} [, {timeout}]]]]) + Search for the match of a nested start-end pair. This can be + used to find the "endif" that matches an "if", while other + if/endif pairs in between are ignored. + The search starts at the cursor. The default is to search + forward, include 'b' in {flags} to search backward. + If a match is found, the cursor is positioned at it and the + line number is returned. If no match is found 0 or -1 is + returned and the cursor doesn't move. No error message is + given. + + {start}, {middle} and {end} are patterns, see |pattern|. They + must not contain \( \) pairs. Use of \%( \) is allowed. When + {middle} is not empty, it is found when searching from either + direction, but only when not in a nested start-end pair. A + typical use is: > + searchpair('\', '\', '\') +< By leaving {middle} empty the "else" is skipped. + + {flags} 'b', 'c', 'n', 's', 'w' and 'W' are used like with + |search()|. Additionally: + 'r' Repeat until no more matches found; will find the + outer pair. Implies the 'W' flag. + 'm' Return number of matches instead of line number with + the match; will be > 1 when 'r' is used. + Note: it's nearly always a good idea to use the 'W' flag, to + avoid wrapping around the end of the file. + + When a match for {start}, {middle} or {end} is found, the + {skip} expression is evaluated with the cursor positioned on + the start of the match. It should return non-zero if this + match is to be skipped. E.g., because it is inside a comment + or a string. + When {skip} is omitted or empty, every match is accepted. + When evaluating {skip} causes an error the search is aborted + and -1 returned. + + For {stopline} and {timeout} see |search()|. + + The value of 'ignorecase' is used. 'magic' is ignored, the + patterns are used like it's on. + + The search starts exactly at the cursor. A match with + {start}, {middle} or {end} at the next character, in the + direction of searching, is the first one found. Example: > + if 1 + if 2 + endif 2 + endif 1 +< When starting at the "if 2", with the cursor on the "i", and + searching forwards, the "endif 2" is found. When starting on + the character just before the "if 2", the "endif 1" will be + found. That's because the "if 2" will be found first, and + then this is considered to be a nested if/endif from "if 2" to + "endif 2". + When searching backwards and {end} is more than one character, + it may be useful to put "\zs" at the end of the pattern, so + that when the cursor is inside a match with the end it finds + the matching start. + + Example, to find the "endif" command in a Vim script: > + + :echo searchpair('\', '\', '\', 'W', + \ 'getline(".") =~ "^\\s*\""') + +< The cursor must be at or after the "if" for which a match is + to be found. Note that single-quote strings are used to avoid + having to double the backslashes. The skip expression only + catches comments at the start of a line, not after a command. + Also, a word "en" or "if" halfway a line is considered a + match. + Another example, to search for the matching "{" of a "}": > + + :echo searchpair('{', '', '}', 'bW') + +< This works when the cursor is at or before the "}" for which a + match is to be found. To reject matches that syntax + highlighting recognized as strings: > + + :echo searchpair('{', '', '}', 'bW', + \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"') +< + *searchpairpos()* +searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} + [, {stopline} [, {timeout}]]]]) + Same as |searchpair()|, but returns a |List| with the line and + column position of the match. The first element of the |List| + is the line number and the second element is the byte index of + the column position of the match. If no match is found, + returns [0, 0]. > + + :let [lnum,col] = searchpairpos('{', '', '}', 'n') +< + See |match-parens| for a bigger and more useful example. + +searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *searchpos()* + Same as |search()|, but returns a |List| with the line and + column position of the match. The first element of the |List| + is the line number and the second element is the byte index of + the column position of the match. If no match is found, + returns [0, 0]. + Example: > + :let [lnum, col] = searchpos('mypattern', 'n') + +< When the 'p' flag is given then there is an extra item with + the sub-pattern match number |search()-sub-match|. Example: > + :let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np') +< In this example "submatch" is 2 when a lowercase letter is + found |/\l|, 3 when an uppercase letter is found |/\u|. + +server2client( {clientid}, {string}) *server2client()* + Send a reply string to {clientid}. The most recent {clientid} + that sent a string can be retrieved with expand(""). + {only available when compiled with the |+clientserver| feature} + Note: + This id has to be stored before the next command can be + received. I.e. before returning from the received command and + before calling any commands that waits for input. + See also |clientserver|. + Example: > + :echo server2client(expand(""), "HELLO") +< +serverlist() *serverlist()* + Return a list of available server names, one per line. + When there are no servers or the information is not available + an empty string is returned. See also |clientserver|. + {only available when compiled with the |+clientserver| feature} + Example: > + :echo serverlist() +< +setbufvar({expr}, {varname}, {val}) *setbufvar()* + Set option or local variable {varname} in buffer {expr} to + {val}. + This also works for a global or local window option, but it + doesn't work for a global or local window variable. + For a local window option the global value is unchanged. + For the use of {expr}, see |bufname()| above. + Note that the variable name without "b:" must be used. + Examples: > + :call setbufvar(1, "&mod", 1) + :call setbufvar("todo", "myvar", "foobar") +< This function is not available in the |sandbox|. + +setcmdpos({pos}) *setcmdpos()* + Set the cursor position in the command line to byte position + {pos}. The first position is 1. + Use |getcmdpos()| to obtain the current position. + Only works while editing the command line, thus you must use + |c_CTRL-\_e|, |c_CTRL-R_=| or |c_CTRL-R_CTRL-R| with '='. For + |c_CTRL-\_e| and |c_CTRL-R_CTRL-R| with '=' the position is + set after the command line is set to the expression. For + |c_CTRL-R_=| it is set after evaluating the expression but + before inserting the resulting text. + When the number is too big the cursor is put at the end of the + line. A number smaller than one has undefined results. + Returns 0 when successful, 1 when not editing the command + line. + +setline({lnum}, {text}) *setline()* + Set line {lnum} of the current buffer to {text}. + {lnum} is used like with |getline()|. + When {lnum} is just below the last line the {text} will be + added as a new line. + If this succeeds, 0 is returned. If this fails (most likely + because {lnum} is invalid) 1 is returned. Example: > + :call setline(5, strftime("%c")) +< When {text} is a |List| then line {lnum} and following lines + will be set to the items in the list. Example: > + :call setline(5, ['aaa', 'bbb', 'ccc']) +< This is equivalent to: > + :for [n, l] in [[5, 6, 7], ['aaa', 'bbb', 'ccc']] + : call setline(n, l) + :endfor +< Note: The '[ and '] marks are not set. + +setloclist({nr}, {list} [, {action}]) *setloclist()* + Create or replace or add to the location list for window {nr}. + When {nr} is zero the current window is used. For a location + list window, the displayed location list is modified. For an + invalid window number {nr}, -1 is returned. + Otherwise, same as |setqflist()|. + Also see |location-list|. + +setmatches({list}) *setmatches()* + Restores a list of matches saved by |getmatches()|. Returns 0 + if successful, otherwise -1. All current matches are cleared + before the list is restored. See example for |getmatches()|. + + *setpos()* +setpos({expr}, {list}) + Set the position for {expr}. Possible values: + . the cursor + 'x mark x + + {list} must be a |List| with four numbers: + [bufnum, lnum, col, off] + + "bufnum" is the buffer number. Zero can be used for the + current buffer. Setting the cursor is only possible for + the current buffer. To set a mark in another buffer you can + use the |bufnr()| function to turn a file name into a buffer + number. + Does not change the jumplist. + + "lnum" and "col" are the position in the buffer. The first + column is 1. Use a zero "lnum" to delete a mark. If "col" is + smaller than 1 then 1 is used. + + The "off" number is only used when 'virtualedit' is set. Then + it is the offset in screen columns from the start of the + character. E.g., a position within a or after the last + character. + + Returns 0 when the position could be set, -1 otherwise. + An error message is given if {expr} is invalid. + + Also see |getpos()| + + This does not restore the preferred column for moving + vertically. See |winrestview()| for that. + + +setqflist({list} [, {action}]) *setqflist()* + Create or replace or add to the quickfix list using the items + in {list}. Each item in {list} is a dictionary. + Non-dictionary items in {list} are ignored. Each dictionary + item can contain the following entries: + + bufnr buffer number; must be the number of a valid + buffer + filename name of a file; only used when "bufnr" is not + present or it is invalid. + lnum line number in the file + pattern search pattern used to locate the error + col column number + vcol when non-zero: "col" is visual column + when zero: "col" is byte index + nr error number + text description of the error + type single-character error type, 'E', 'W', etc. + + The "col", "vcol", "nr", "type" and "text" entries are + optional. Either "lnum" or "pattern" entry can be used to + locate a matching error line. + If the "filename" and "bufnr" entries are not present or + neither the "lnum" or "pattern" entries are present, then the + item will not be handled as an error line. + If both "pattern" and "lnum" are present then "pattern" will + be used. + If you supply an empty {list}, the quickfix list will be + cleared. + Note that the list is not exactly the same as what + |getqflist()| returns. + + If {action} is set to 'a', then the items from {list} are + added to the existing quickfix list. If there is no existing + list, then a new list is created. If {action} is set to 'r', + then the items from the current quickfix list are replaced + with the items from {list}. If {action} is not present or is + set to ' ', then a new list is created. + + Returns zero for success, -1 for failure. + + This function can be used to create a quickfix list + independent of the 'errorformat' setting. Use a command like + ":cc 1" to jump to the first position. + + + *setreg()* +setreg({regname}, {value} [,{options}]) + Set the register {regname} to {value}. + If {options} contains "a" or {regname} is upper case, + then the value is appended. + {options} can also contain a register type specification: + "c" or "v" |characterwise| mode + "l" or "V" |linewise| mode + "b" or "" |blockwise-visual| mode + If a number immediately follows "b" or "" then this is + used as the width of the selection - if it is not specified + then the width of the block is set to the number of characters + in the longest line (counting a as 1 character). + + If {options} contains no register settings, then the default + is to use character mode unless {value} ends in a . + Setting the '=' register is not possible. + Returns zero for success, non-zero for failure. + + Examples: > + :call setreg(v:register, @*) + :call setreg('*', @%, 'ac') + :call setreg('a', "1\n2\n3", 'b5') + +< This example shows using the functions to save and restore a + register. > + :let var_a = getreg('a', 1) + :let var_amode = getregtype('a') + .... + :call setreg('a', var_a, var_amode) + +< You can also change the type of a register by appending + nothing: > + :call setreg('a', '', 'al') + +settabvar({tabnr}, {varname}, {val}) *settabvar()* + Set tab-local variable {varname} to {val} in tab page {tabnr}. + |t:var| + Note that the variable name without "t:" must be used. + Tabs are numbered starting with one. + Vim briefly goes to the tab page {tabnr}, this may trigger + TabLeave and TabEnter autocommands. + This function is not available in the |sandbox|. + +settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()* + Set option or local variable {varname} in window {winnr} to + {val}. + Tabs are numbered starting with one. For the current tabpage + use |setwinvar()|. + When {winnr} is zero the current window is used. + This also works for a global or local buffer option, but it + doesn't work for a global or local buffer variable. + For a local buffer option the global value is unchanged. + Note that the variable name without "w:" must be used. + Vim briefly goes to the tab page {tabnr}, this may trigger + TabLeave and TabEnter autocommands. + Examples: > + :call settabwinvar(1, 1, "&list", 0) + :call settabwinvar(3, 2, "myvar", "foobar") +< This function is not available in the |sandbox|. + +setwinvar({nr}, {varname}, {val}) *setwinvar()* + Like |settabwinvar()| for the current tab page. + Examples: > + :call setwinvar(1, "&list", 0) + :call setwinvar(2, "myvar", "foobar") + +shellescape({string} [, {special}]) *shellescape()* + Escape {string} for use as a shell command argument. + On MS-Windows and MS-DOS, when 'shellslash' is not set, it + will enclose {string} in double quotes and double all double + quotes within {string}. + For other systems, it will enclose {string} in single quotes + and replace all "'" with "'\''". + When the {special} argument is present and it's a non-zero + Number or a non-empty String (|non-zero-arg|), then special + items such as "!", "%", "#" and "" will be preceded by + a backslash. This backslash will be removed again by the |:!| + command. + The "!" character will be escaped (again with a |non-zero-arg| + {special}) when 'shell' contains "csh" in the tail. That is + because for csh and tcsh "!" is used for history replacement + even when inside single quotes. + The character is also escaped. With a |non-zero-arg| + {special} and 'shell' containing "csh" in the tail it's + escaped a second time. + Example of use with a |:!| command: > + :exe '!dir ' . shellescape(expand(''), 1) +< This results in a directory listing for the file under the + cursor. Example of use with |system()|: > + :call system("chmod +w -- " . shellescape(expand("%"))) + + +simplify({filename}) *simplify()* + Simplify the file name as much as possible without changing + the meaning. Shortcuts (on MS-Windows) or symbolic links (on + Unix) are not resolved. If the first path component in + {filename} designates the current directory, this will be + valid for the result as well. A trailing path separator is + not removed either. + Example: > + simplify("./dir/.././/file/") == "./file/" +< Note: The combination "dir/.." is only removed if "dir" is + a searchable directory or does not exist. On Unix, it is also + removed when "dir" is a symbolic link within the same + directory. In order to resolve all the involved symbolic + links before simplifying the path name, use |resolve()|. + + +sin({expr}) *sin()* + Return the sine of {expr}, measured in radians, as a |Float|. + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + :echo sin(100) +< -0.506366 > + :echo sin(-4.01) +< 0.763301 + {only available when compiled with the |+float| feature} + + +sinh({expr}) *sinh()* + Return the hyperbolic sine of {expr} as a |Float| in the range + [-inf, inf]. + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + :echo sinh(0.5) +< 0.521095 > + :echo sinh(-0.9) +< -1.026517 + {only available when compiled with the |+float| feature} + + +sort({list} [, {func}]) *sort()* *E702* + Sort the items in {list} in-place. Returns {list}. If you + want a list to remain unmodified make a copy first: > + :let sortedlist = sort(copy(mylist)) +< Uses the string representation of each item to sort on. + Numbers sort after Strings, |Lists| after Numbers. + For sorting text in the current buffer use |:sort|. + When {func} is given and it is one then case is ignored. + When {func} is a |Funcref| or a function name, this function + is called to compare items. The function is invoked with two + items as argument and must return zero if they are equal, 1 or + bigger if the first one sorts after the second one, -1 or + smaller if the first one sorts before the second one. + Example: > + func MyCompare(i1, i2) + return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1 + endfunc + let sortedlist = sort(mylist, "MyCompare") +< A shorter compare version for this specific simple case, which + ignores overflow: > + func MyCompare(i1, i2) + return a:i1 - a:i2 + endfunc +< + *soundfold()* +soundfold({word}) + Return the sound-folded equivalent of {word}. Uses the first + language in 'spelllang' for the current window that supports + soundfolding. 'spell' must be set. When no sound folding is + possible the {word} is returned unmodified. + This can be used for making spelling suggestions. Note that + the method can be quite slow. + + *spellbadword()* +spellbadword([{sentence}]) + Without argument: The result is the badly spelled word under + or after the cursor. The cursor is moved to the start of the + bad word. When no bad word is found in the cursor line the + result is an empty string and the cursor doesn't move. + + With argument: The result is the first word in {sentence} that + is badly spelled. If there are no spelling mistakes the + result is an empty string. + + The return value is a list with two items: + - The badly spelled word or an empty string. + - The type of the spelling error: + "bad" spelling mistake + "rare" rare word + "local" word only valid in another region + "caps" word should start with Capital + Example: > + echo spellbadword("the quik brown fox") +< ['quik', 'bad'] ~ + + The spelling information for the current window is used. The + 'spell' option must be set and the value of 'spelllang' is + used. + + *spellsuggest()* +spellsuggest({word} [, {max} [, {capital}]]) + Return a |List| with spelling suggestions to replace {word}. + When {max} is given up to this number of suggestions are + returned. Otherwise up to 25 suggestions are returned. + + When the {capital} argument is given and it's non-zero only + suggestions with a leading capital will be given. Use this + after a match with 'spellcapcheck'. + + {word} can be a badly spelled word followed by other text. + This allows for joining two words that were split. The + suggestions also include the following text, thus you can + replace a line. + + {word} may also be a good word. Similar words will then be + returned. {word} itself is not included in the suggestions, + although it may appear capitalized. + + The spelling information for the current window is used. The + 'spell' option must be set and the values of 'spelllang' and + 'spellsuggest' are used. + + +split({expr} [, {pattern} [, {keepempty}]]) *split()* + Make a |List| out of {expr}. When {pattern} is omitted or + empty each white-separated sequence of characters becomes an + item. + Otherwise the string is split where {pattern} matches, + removing the matched characters. + When the first or last item is empty it is omitted, unless the + {keepempty} argument is given and it's non-zero. + Other empty items are kept when {pattern} matches at least one + character or when {keepempty} is non-zero. + Example: > + :let words = split(getline('.'), '\W\+') +< To split a string in individual characters: > + :for c in split(mystring, '\zs') +< If you want to keep the separator you can also use '\zs': > + :echo split('abc:def:ghi', ':\zs') +< ['abc:', 'def:', 'ghi'] ~ + Splitting a table where the first element can be empty: > + :let items = split(line, ':', 1) +< The opposite function is |join()|. + + +sqrt({expr}) *sqrt()* + Return the non-negative square root of Float {expr} as a + |Float|. + {expr} must evaluate to a |Float| or a |Number|. When {expr} + is negative the result is NaN (Not a Number). + Examples: > + :echo sqrt(100) +< 10.0 > + :echo sqrt(-4.01) +< nan + "nan" may be different, it depends on system libraries. + {only available when compiled with the |+float| feature} + + +str2float( {expr}) *str2float()* + Convert String {expr} to a Float. This mostly works the same + as when using a floating point number in an expression, see + |floating-point-format|. But it's a bit more permissive. + E.g., "1e40" is accepted, while in an expression you need to + write "1.0e40". + Text after the number is silently ignored. + The decimal point is always '.', no matter what the locale is + set to. A comma ends the number: "12,345.67" is converted to + 12.0. You can strip out thousands separators with + |substitute()|: > + let f = str2float(substitute(text, ',', '', 'g')) +< {only available when compiled with the |+float| feature} + + +str2nr( {expr} [, {base}]) *str2nr()* + Convert string {expr} to a number. + {base} is the conversion base, it can be 8, 10 or 16. + When {base} is omitted base 10 is used. This also means that + a leading zero doesn't cause octal conversion to be used, as + with the default String to Number conversion. + When {base} is 16 a leading "0x" or "0X" is ignored. With a + different base the result will be zero. + Text after the number is silently ignored. + + +strchars({expr}) *strchars()* + The result is a Number, which is the number of characters + String {expr} occupies. Composing characters are counted + separately. + Also see |strlen()|, |strdisplaywidth()| and |strwidth()|. + +strdisplaywidth({expr}[, {col}]) *strdisplaywidth()* + The result is a Number, which is the number of display cells + String {expr} occupies on the screen. + When {col} is omitted zero is used. Otherwise it is the + screen column where to start. This matters for Tab + characters. + The option settings of the current window are used. This + matters for anything that's displayed differently, such as + 'tabstop' and 'display'. + When {expr} contains characters with East Asian Width Class + Ambiguous, this function's return value depends on 'ambiwidth'. + Also see |strlen()|, |strwidth()| and |strchars()|. + +strftime({format} [, {time}]) *strftime()* + The result is a String, which is a formatted date and time, as + specified by the {format} string. The given {time} is used, + or the current time if no time is given. The accepted + {format} depends on your system, thus this is not portable! + See the manual page of the C function strftime() for the + format. The maximum length of the result is 80 characters. + See also |localtime()| and |getftime()|. + The language can be changed with the |:language| command. + Examples: > + :echo strftime("%c") Sun Apr 27 11:49:23 1997 + :echo strftime("%Y %b %d %X") 1997 Apr 27 11:53:25 + :echo strftime("%y%m%d %T") 970427 11:53:55 + :echo strftime("%H:%M") 11:55 + :echo strftime("%c", getftime("file.c")) + Show mod time of file.c. +< Not available on all systems. To check use: > + :if exists("*strftime") + +stridx({haystack}, {needle} [, {start}]) *stridx()* + The result is a Number, which gives the byte index in + {haystack} of the first occurrence of the String {needle}. + If {start} is specified, the search starts at index {start}. + This can be used to find a second match: > + :let comma1 = stridx(line, ",") + :let comma2 = stridx(line, ",", comma1 + 1) +< The search is done case-sensitive. + For pattern searches use |match()|. + -1 is returned if the {needle} does not occur in {haystack}. + See also |strridx()|. + Examples: > + :echo stridx("An Example", "Example") 3 + :echo stridx("Starting point", "Start") 0 + :echo stridx("Starting point", "start") -1 +< *strstr()* *strchr()* + stridx() works similar to the C function strstr(). When used + with a single character it works similar to strchr(). + + *string()* +string({expr}) Return {expr} converted to a String. If {expr} is a Number, + Float, String or a composition of them, then the result can be + parsed back with |eval()|. + {expr} type result ~ + String 'string' + Number 123 + Float 123.123456 or 1.123456e8 + Funcref function('name') + List [item, item] + Dictionary {key: value, key: value} + Note that in String values the ' character is doubled. + Also see |strtrans()|. + + *strlen()* +strlen({expr}) The result is a Number, which is the length of the String + {expr} in bytes. + If you want to count the number of multi-byte characters (not + counting composing characters) use something like this: > + + :let len = strlen(substitute(str, ".", "x", "g")) +< + If the argument is a Number it is first converted to a String. + For other types an error is given. + Also see |len()|, |strchars()|, |strdisplaywidth()| and + |strwidth()|. + +strpart({src}, {start}[, {len}]) *strpart()* + The result is a String, which is part of {src}, starting from + byte {start}, with the byte length {len}. + When non-existing bytes are included, this doesn't result in + an error, the bytes are simply omitted. + If {len} is missing, the copy continues from {start} till the + end of the {src}. > + strpart("abcdefg", 3, 2) == "de" + strpart("abcdefg", -2, 4) == "ab" + strpart("abcdefg", 5, 4) == "fg" + strpart("abcdefg", 3) == "defg" +< Note: To get the first character, {start} must be 0. For + example, to get three bytes under and after the cursor: > + strpart(getline("."), col(".") - 1, 3) +< +strridx({haystack}, {needle} [, {start}]) *strridx()* + The result is a Number, which gives the byte index in + {haystack} of the last occurrence of the String {needle}. + When {start} is specified, matches beyond this index are + ignored. This can be used to find a match before a previous + match: > + :let lastcomma = strridx(line, ",") + :let comma2 = strridx(line, ",", lastcomma - 1) +< The search is done case-sensitive. + For pattern searches use |match()|. + -1 is returned if the {needle} does not occur in {haystack}. + If the {needle} is empty the length of {haystack} is returned. + See also |stridx()|. Examples: > + :echo strridx("an angry armadillo", "an") 3 +< *strrchr()* + When used with a single character it works similar to the C + function strrchr(). + +strtrans({expr}) *strtrans()* + The result is a String, which is {expr} with all unprintable + characters translated into printable characters |'isprint'|. + Like they are shown in a window. Example: > + echo strtrans(@a) +< This displays a newline in register a as "^@" instead of + starting a new line. + +strwidth({expr}) *strwidth()* + The result is a Number, which is the number of display cells + String {expr} occupies. A Tab character is counted as one + cell, alternatively use |strdisplaywidth()|. + When {expr} contains characters with East Asian Width Class + Ambiguous, this function's return value depends on 'ambiwidth'. + Also see |strlen()|, |strdisplaywidth()| and |strchars()|. + +submatch({nr}) *submatch()* + Only for an expression in a |:substitute| command. Returns + the {nr}'th submatch of the matched text. When {nr} is 0 + the whole matched text is returned. + Example: > + :s/\d\+/\=submatch(0) + 1/ +< This finds the first number in the line and adds one to it. + A line break is included as a newline character. + +substitute({expr}, {pat}, {sub}, {flags}) *substitute()* + The result is a String, which is a copy of {expr}, in which + the first match of {pat} is replaced with {sub}. This works + like the ":substitute" command (without any flags). But the + matching with {pat} is always done like the 'magic' option is + set and 'cpoptions' is empty (to make scripts portable). + 'ignorecase' is still relevant. 'smartcase' is not used. + See |string-match| for how {pat} is used. + And a "~" in {sub} is not replaced with the previous {sub}. + Note that some codes in {sub} have a special meaning + |sub-replace-special|. For example, to replace something with + "\n" (two characters), use "\\\\n" or '\\n'. + When {pat} does not match in {expr}, {expr} is returned + unmodified. + When {flags} is "g", all matches of {pat} in {expr} are + replaced. Otherwise {flags} should be "". + Example: > + :let &path = substitute(&path, ",\\=[^,]*$", "", "") +< This removes the last component of the 'path' option. > + :echo substitute("testing", ".*", "\\U\\0", "") +< results in "TESTING". + +synID({lnum}, {col}, {trans}) *synID()* + The result is a Number, which is the syntax ID at the position + {lnum} and {col} in the current window. + The syntax ID can be used with |synIDattr()| and + |synIDtrans()| to obtain syntax information about text. + + {col} is 1 for the leftmost column, {lnum} is 1 for the first + line. 'synmaxcol' applies, in a longer line zero is returned. + + When {trans} is non-zero, transparent items are reduced to the + item that they reveal. This is useful when wanting to know + the effective color. When {trans} is zero, the transparent + item is returned. This is useful when wanting to know which + syntax item is effective (e.g. inside parens). + Warning: This function can be very slow. Best speed is + obtained by going through the file in forward direction. + + Example (echoes the name of the syntax item under the cursor): > + :echo synIDattr(synID(line("."), col("."), 1), "name") +< + +synconcealed({lnum}, {col}) *synconcealed()* + The result is a List. The first item in the list is 0 if the + character at the position {lnum} and {col} is not part of a + concealable region, 1 if it is. The second item in the list is + a string. If the first item is 1, the second item contains the + text which will be displayed in place of the concealed text, + depending on the current setting of 'conceallevel'. The third + and final item in the list is a unique number representing the + specific syntax region matched. This allows detection of the + beginning of a new concealable region if there are two + consecutive regions with the same replacement character. + For an example use see $VIMRUNTIME/syntax/2html.vim . + + +synIDattr({synID}, {what} [, {mode}]) *synIDattr()* + The result is a String, which is the {what} attribute of + syntax ID {synID}. This can be used to obtain information + about a syntax item. + {mode} can be "gui", "cterm" or "term", to get the attributes + for that mode. When {mode} is omitted, or an invalid value is + used, the attributes for the currently active highlighting are + used (GUI, cterm or term). + Use synIDtrans() to follow linked highlight groups. + {what} result + "name" the name of the syntax item + "fg" foreground color (GUI: color name used to set + the color, cterm: color number as a string, + term: empty string) + "bg" background color (as with "fg") + "font" font name (only available in the GUI) + |highlight-font| + "sp" special color (as with "fg") |highlight-guisp| + "fg#" like "fg", but for the GUI and the GUI is + running the name in "#RRGGBB" form + "bg#" like "fg#" for "bg" + "sp#" like "fg#" for "sp" + "bold" "1" if bold + "italic" "1" if italic + "reverse" "1" if reverse + "inverse" "1" if inverse (= reverse) + "standout" "1" if standout + "underline" "1" if underlined + "undercurl" "1" if undercurled + + Example (echoes the color of the syntax item under the + cursor): > + :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg") +< +synIDtrans({synID}) *synIDtrans()* + The result is a Number, which is the translated syntax ID of + {synID}. This is the syntax group ID of what is being used to + highlight the character. Highlight links given with + ":highlight link" are followed. + +synstack({lnum}, {col}) *synstack()* + Return a |List|, which is the stack of syntax items at the + position {lnum} and {col} in the current window. Each item in + the List is an ID like what |synID()| returns. + The first item in the List is the outer region, following are + items contained in that one. The last one is what |synID()| + returns, unless not the whole item is highlighted or it is a + transparent item. + This function is useful for debugging a syntax file. + Example that shows the syntax stack under the cursor: > + for id in synstack(line("."), col(".")) + echo synIDattr(id, "name") + endfor +< When the position specified with {lnum} and {col} is invalid + nothing is returned. The position just after the last + character in a line and the first column in an empty line are + valid positions. + +system({expr} [, {input}]) *system()* *E677* + Get the output of the shell command {expr}. + When {input} is given, this string is written to a file and + passed as stdin to the command. The string is written as-is, + you need to take care of using the correct line separators + yourself. Pipes are not used. + Note: Use |shellescape()| to escape special characters in a + command argument. Newlines in {expr} may cause the command to + fail. The characters in 'shellquote' and 'shellxquote' may + also cause trouble. + This is not to be used for interactive commands. + + The result is a String. Example: > + :let files = system("ls " . shellescape(expand('%:h'))) + +< To make the result more system-independent, the shell output + is filtered to replace with for Macintosh, and + with for DOS-like systems. + The command executed is constructed using several options: + 'shell' 'shellcmdflag' 'shellxquote' {expr} 'shellredir' {tmp} 'shellxquote' + ({tmp} is an automatically generated file name). + For Unix and OS/2 braces are put around {expr} to allow for + concatenated commands. + + The command will be executed in "cooked" mode, so that a + CTRL-C will interrupt the command (on Unix at least). + + The resulting error code can be found in |v:shell_error|. + This function will fail in |restricted-mode|. + + Note that any wrong value in the options mentioned above may + make the function fail. It has also been reported to fail + when using a security agent application. + Unlike ":!cmd" there is no automatic check for changed files. + Use |:checktime| to force a check. + + +tabpagebuflist([{arg}]) *tabpagebuflist()* + The result is a |List|, where each item is the number of the + buffer associated with each window in the current tab page. + {arg} specifies the number of tab page to be used. When + omitted the current tab page is used. + When {arg} is invalid the number zero is returned. + To get a list of all buffers in all tabs use this: > + tablist = [] + for i in range(tabpagenr('$')) + call extend(tablist, tabpagebuflist(i + 1)) + endfor +< Note that a buffer may appear in more than one window. + + +tabpagenr([{arg}]) *tabpagenr()* + The result is a Number, which is the number of the current + tab page. The first tab page has number 1. + When the optional argument is "$", the number of the last tab + page is returned (the tab page count). + The number can be used with the |:tab| command. + + +tabpagewinnr({tabarg}, [{arg}]) *tabpagewinnr()* + Like |winnr()| but for tab page {tabarg}. + {tabarg} specifies the number of tab page to be used. + {arg} is used like with |winnr()|: + - When omitted the current window number is returned. This is + the window which will be used when going to this tab page. + - When "$" the number of windows is returned. + - When "#" the previous window nr is returned. + Useful examples: > + tabpagewinnr(1) " current window of tab page 1 + tabpagewinnr(4, '$') " number of windows in tab page 4 +< When {tabarg} is invalid zero is returned. + + *tagfiles()* +tagfiles() Returns a |List| with the file names used to search for tags + for the current buffer. This is the 'tags' option expanded. + + +taglist({expr}) *taglist()* + Returns a list of tags matching the regular expression {expr}. + Each list item is a dictionary with at least the following + entries: + name Name of the tag. + filename Name of the file where the tag is + defined. It is either relative to the + current directory or a full path. + cmd Ex command used to locate the tag in + the file. + kind Type of the tag. The value for this + entry depends on the language specific + kind values. Only available when + using a tags file generated by + Exuberant ctags or hdrtag. + static A file specific tag. Refer to + |static-tag| for more information. + More entries may be present, depending on the content of the + tags file: access, implementation, inherits and signature. + Refer to the ctags documentation for information about these + fields. For C code the fields "struct", "class" and "enum" + may appear, they give the name of the entity the tag is + contained in. + + The ex-command 'cmd' can be either an ex search pattern, a + line number or a line number followed by a byte number. + + If there are no matching tags, then an empty list is returned. + + To get an exact tag match, the anchors '^' and '$' should be + used in {expr}. Refer to |tag-regexp| for more information + about the tag search regular expression pattern. + + Refer to |'tags'| for information about how the tags file is + located by Vim. Refer to |tags-file-format| for the format of + the tags file generated by the different ctags tools. + +tempname() *tempname()* *temp-file-name* + The result is a String, which is the name of a file that + doesn't exist. It can be used for a temporary file. The name + is different for at least 26 consecutive calls. Example: > + :let tmpfile = tempname() + :exe "redir > " . tmpfile +< For Unix, the file will be in a private directory |tempfile|. + For MS-Windows forward slashes are used when the 'shellslash' + option is set or when 'shellcmdflag' starts with '-'. + + +tan({expr}) *tan()* + Return the tangent of {expr}, measured in radians, as a |Float| + in the range [-inf, inf]. + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + :echo tan(10) +< 0.648361 > + :echo tan(-4.01) +< -1.181502 + {only available when compiled with the |+float| feature} + + +tanh({expr}) *tanh()* + Return the hyperbolic tangent of {expr} as a |Float| in the + range [-1, 1]. + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + :echo tanh(0.5) +< 0.462117 > + :echo tanh(-1) +< -0.761594 + {only available when compiled with the |+float| feature} + + +tolower({expr}) *tolower()* + The result is a copy of the String given, with all uppercase + characters turned into lowercase (just like applying |gu| to + the string). + +toupper({expr}) *toupper()* + The result is a copy of the String given, with all lowercase + characters turned into uppercase (just like applying |gU| to + the string). + +tr({src}, {fromstr}, {tostr}) *tr()* + The result is a copy of the {src} string with all characters + which appear in {fromstr} replaced by the character in that + position in the {tostr} string. Thus the first character in + {fromstr} is translated into the first character in {tostr} + and so on. Exactly like the unix "tr" command. + This code also deals with multibyte characters properly. + + Examples: > + echo tr("hello there", "ht", "HT") +< returns "Hello THere" > + echo tr("", "<>", "{}") +< returns "{blob}" + +trunc({expr}) *trunc()* + Return the largest integral value with magnitude less than or + equal to {expr} as a |Float| (truncate towards zero). + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + echo trunc(1.456) +< 1.0 > + echo trunc(-5.456) +< -5.0 > + echo trunc(4.0) +< 4.0 + {only available when compiled with the |+float| feature} + + *type()* +type({expr}) The result is a Number, depending on the type of {expr}: + Number: 0 + String: 1 + Funcref: 2 + List: 3 + Dictionary: 4 + Float: 5 + To avoid the magic numbers it should be used this way: > + :if type(myvar) == type(0) + :if type(myvar) == type("") + :if type(myvar) == type(function("tr")) + :if type(myvar) == type([]) + :if type(myvar) == type({}) + :if type(myvar) == type(0.0) + +undofile({name}) *undofile()* + Return the name of the undo file that would be used for a file + with name {name} when writing. This uses the 'undodir' + option, finding directories that exist. It does not check if + the undo file exists. + {name} is always expanded to the full path, since that is what + is used internally. + Useful in combination with |:wundo| and |:rundo|. + When compiled without the +persistent_undo option this always + returns an empty string. + +undotree() *undotree()* + Return the current state of the undo tree in a dictionary with + the following items: + "seq_last" The highest undo sequence number used. + "seq_cur" The sequence number of the current position in + the undo tree. This differs from "seq_last" + when some changes were undone. + "time_cur" Time last used for |:earlier| and related + commands. Use |strftime()| to convert to + something readable. + "save_last" Number of the last file write. Zero when no + write yet. + "save_cur" Number of the current position in the undo + tree. + "synced" Non-zero when the last undo block was synced. + This happens when waiting from input from the + user. See |undo-blocks|. + "entries" A list of dictionaries with information about + undo blocks. + + The first item in the "entries" list is the oldest undo item. + Each List item is a Dictionary with these items: + "seq" Undo sequence number. Same as what appears in + |:undolist|. + "time" Timestamp when the change happened. Use + |strftime()| to convert to something readable. + "newhead" Only appears in the item that is the last one + that was added. This marks the last change + and where further changes will be added. + "curhead" Only appears in the item that is the last one + that was undone. This marks the current + position in the undo tree, the block that will + be used by a redo command. When nothing was + undone after the last change this item will + not appear anywhere. + "save" Only appears on the last block before a file + write. The number is the write count. The + first write has number 1, the last one the + "save_last" mentioned above. + "alt" Alternate entry. This is again a List of undo + blocks. Each item may again have an "alt" + item. + +values({dict}) *values()* + Return a |List| with all the values of {dict}. The |List| is + in arbitrary order. + + +virtcol({expr}) *virtcol()* + The result is a Number, which is the screen column of the file + position given with {expr}. That is, the last screen position + occupied by the character at that position, when the screen + would be of unlimited width. When there is a at the + position, the returned Number will be the column at the end of + the . For example, for a in column 1, with 'ts' + set to 8, it returns 8. + For the byte position use |col()|. + For the use of {expr} see |col()|. + When 'virtualedit' is used {expr} can be [lnum, col, off], where + "off" is the offset in screen columns from the start of the + character. E.g., a position within a or after the last + character. + When Virtual editing is active in the current mode, a position + beyond the end of the line can be returned. |'virtualedit'| + The accepted positions are: + . the cursor position + $ the end of the cursor line (the result is the + number of displayed characters in the cursor line + plus one) + 'x position of mark x (if the mark is not set, 0 is + returned) + Note that only marks in the current file can be used. + Examples: > + virtcol(".") with text "foo^Lbar", with cursor on the "^L", returns 5 + virtcol("$") with text "foo^Lbar", returns 9 + virtcol("'t") with text " there", with 't at 'h', returns 6 +< The first column is 1. 0 is returned for an error. + A more advanced example that echoes the maximum length of + all lines: > + echo max(map(range(1, line('$')), "virtcol([v:val, '$'])")) + + +visualmode([expr]) *visualmode()* + The result is a String, which describes the last Visual mode + used in the current buffer. Initially it returns an empty + string, but once Visual mode has been used, it returns "v", + "V", or "" (a single CTRL-V character) for + character-wise, line-wise, or block-wise Visual mode + respectively. + Example: > + :exe "normal " . visualmode() +< This enters the same Visual mode as before. It is also useful + in scripts if you wish to act differently depending on the + Visual mode that was used. + If Visual mode is active, use |mode()| to get the Visual mode + (e.g., in a |:vmap|). + *non-zero-arg* + If [expr] is supplied and it evaluates to a non-zero Number or + a non-empty String, then the Visual mode will be cleared and + the old value is returned. Note that " " and "0" are also + non-empty strings, thus cause the mode to be cleared. A List, + Dictionary or Float is not a Number or String, thus does not + cause the mode to be cleared. + + *winbufnr()* +winbufnr({nr}) The result is a Number, which is the number of the buffer + associated with window {nr}. When {nr} is zero, the number of + the buffer in the current window is returned. When window + {nr} doesn't exist, -1 is returned. + Example: > + :echo "The file in the current window is " . bufname(winbufnr(0)) +< + *wincol()* +wincol() The result is a Number, which is the virtual column of the + cursor in the window. This is counting screen cells from the + left side of the window. The leftmost column is one. + +winheight({nr}) *winheight()* + The result is a Number, which is the height of window {nr}. + When {nr} is zero, the height of the current window is + returned. When window {nr} doesn't exist, -1 is returned. + An existing window always has a height of zero or more. + Examples: > + :echo "The current window has " . winheight(0) . " lines." +< + *winline()* +winline() The result is a Number, which is the screen line of the cursor + in the window. This is counting screen lines from the top of + the window. The first line is one. + If the cursor was moved the view on the file will be updated + first, this may cause a scroll. + + *winnr()* +winnr([{arg}]) The result is a Number, which is the number of the current + window. The top window has number 1. + When the optional argument is "$", the number of the + last window is returned (the window count). + When the optional argument is "#", the number of the last + accessed window is returned (where |CTRL-W_p| goes to). + If there is no previous window or it is in another tab page 0 + is returned. + The number can be used with |CTRL-W_w| and ":wincmd w" + |:wincmd|. + Also see |tabpagewinnr()|. + + *winrestcmd()* +winrestcmd() Returns a sequence of |:resize| commands that should restore + the current window sizes. Only works properly when no windows + are opened or closed and the current window and tab page is + unchanged. + Example: > + :let cmd = winrestcmd() + :call MessWithWindowSizes() + :exe cmd +< + *winrestview()* +winrestview({dict}) + Uses the |Dictionary| returned by |winsaveview()| to restore + the view of the current window. + If you have changed the values the result is unpredictable. + If the window size changed the result won't be the same. + + *winsaveview()* +winsaveview() Returns a |Dictionary| that contains information to restore + the view of the current window. Use |winrestview()| to + restore the view. + This is useful if you have a mapping that jumps around in the + buffer and you want to go back to the original view. + This does not save fold information. Use the 'foldenable' + option to temporarily switch off folding, so that folds are + not opened when moving around. + The return value includes: + lnum cursor line number + col cursor column + coladd cursor column offset for 'virtualedit' + curswant column for vertical movement + topline first line in the window + topfill filler lines, only in diff mode + leftcol first column displayed + skipcol columns skipped + Note that no option values are saved. + + +winwidth({nr}) *winwidth()* + The result is a Number, which is the width of window {nr}. + When {nr} is zero, the width of the current window is + returned. When window {nr} doesn't exist, -1 is returned. + An existing window always has a width of zero or more. + Examples: > + :echo "The current window has " . winwidth(0) . " columns." + :if winwidth(0) <= 50 + : exe "normal 50\|" + :endif +< + *writefile()* +writefile({list}, {fname} [, {binary}]) + Write |List| {list} to file {fname}. Each list item is + separated with a NL. Each list item must be a String or + Number. + When {binary} is equal to "b" binary mode is used: There will + not be a NL after the last list item. An empty item at the + end does cause the last line in the file to end in a NL. + All NL characters are replaced with a NUL character. + Inserting CR characters needs to be done before passing {list} + to writefile(). + An existing file is overwritten, if possible. + When the write fails -1 is returned, otherwise 0. There is an + error message if the file can't be created or when writing + fails. + Also see |readfile()|. + To copy a file byte for byte: > + :let fl = readfile("foo", "b") + :call writefile(fl, "foocopy", "b") +< + + *feature-list* +There are three types of features: +1. Features that are only supported when they have been enabled when Vim + was compiled |+feature-list|. Example: > + :if has("cindent") +2. Features that are only supported when certain conditions have been met. + Example: > + :if has("gui_running") +< *has-patch* +3. Included patches. First check |v:version| for the version of Vim. + Then the "patch123" feature means that patch 123 has been included for + this version. Example (checking version 6.2.148 or later): > + :if v:version > 602 || v:version == 602 && has("patch148") +< Note that it's possible for patch 147 to be omitted even though 148 is + included. + +all_builtin_terms Compiled with all builtin terminals enabled. +amiga Amiga version of Vim. +arabic Compiled with Arabic support |Arabic|. +arp Compiled with ARP support (Amiga). +autocmd Compiled with autocommand support. |autocommand| +balloon_eval Compiled with |balloon-eval| support. +balloon_multiline GUI supports multiline balloons. +beos BeOS version of Vim. +browse Compiled with |:browse| support, and browse() will + work. +builtin_terms Compiled with some builtin terminals. +byte_offset Compiled with support for 'o' in 'statusline' +cindent Compiled with 'cindent' support. +clientserver Compiled with remote invocation support |clientserver|. +clipboard Compiled with 'clipboard' support. +cmdline_compl Compiled with |cmdline-completion| support. +cmdline_hist Compiled with |cmdline-history| support. +cmdline_info Compiled with 'showcmd' and 'ruler' support. +comments Compiled with |'comments'| support. +cryptv Compiled with encryption support |encryption|. +cscope Compiled with |cscope| support. +compatible Compiled to be very Vi compatible. +debug Compiled with "DEBUG" defined. +dialog_con Compiled with console dialog support. +dialog_gui Compiled with GUI dialog support. +diff Compiled with |vimdiff| and 'diff' support. +digraphs Compiled with support for digraphs. +dnd Compiled with support for the "~ register |quote_~|. +dos32 32 bits DOS (DJGPP) version of Vim. +dos16 16 bits DOS version of Vim. +ebcdic Compiled on a machine with ebcdic character set. +emacs_tags Compiled with support for Emacs tags. +eval Compiled with expression evaluation support. Always + true, of course! +ex_extra Compiled with extra Ex commands |+ex_extra|. +extra_search Compiled with support for |'incsearch'| and + |'hlsearch'| +farsi Compiled with Farsi support |farsi|. +file_in_path Compiled with support for |gf| and || +filterpipe When 'shelltemp' is off pipes are used for shell + read/write/filter commands +find_in_path Compiled with support for include file searches + |+find_in_path|. +float Compiled with support for |Float|. +fname_case Case in file names matters (for Amiga, MS-DOS, and + Windows this is not present). +folding Compiled with |folding| support. +footer Compiled with GUI footer support. |gui-footer| +fork Compiled to use fork()/exec() instead of system(). +gettext Compiled with message translation |multi-lang| +gui Compiled with GUI enabled. +gui_athena Compiled with Athena GUI. +gui_gtk Compiled with GTK+ GUI (any version). +gui_gtk2 Compiled with GTK+ 2 GUI (gui_gtk is also defined). +gui_gnome Compiled with Gnome support (gui_gtk is also defined). +gui_mac Compiled with Macintosh GUI. +gui_motif Compiled with Motif GUI. +gui_photon Compiled with Photon GUI. +gui_win32 Compiled with MS Windows Win32 GUI. +gui_win32s idem, and Win32s system being used (Windows 3.1) +gui_running Vim is running in the GUI, or it will start soon. +hangul_input Compiled with Hangul input support. |hangul| +iconv Can use iconv() for conversion. +insert_expand Compiled with support for CTRL-X expansion commands in + Insert mode. +jumplist Compiled with |jumplist| support. +keymap Compiled with 'keymap' support. +langmap Compiled with 'langmap' support. +libcall Compiled with |libcall()| support. +linebreak Compiled with 'linebreak', 'breakat' and 'showbreak' + support. +lispindent Compiled with support for lisp indenting. +listcmds Compiled with commands for the buffer list |:files| + and the argument list |arglist|. +localmap Compiled with local mappings and abbr. |:map-local| +lua Compiled with Lua interface |Lua|. +mac Macintosh version of Vim. +macunix Macintosh version of Vim, using Unix files (OS-X). +menu Compiled with support for |:menu|. +mksession Compiled with support for |:mksession|. +modify_fname Compiled with file name modifiers. |filename-modifiers| +mouse Compiled with support mouse. +mouseshape Compiled with support for 'mouseshape'. +mouse_dec Compiled with support for Dec terminal mouse. +mouse_gpm Compiled with support for gpm (Linux console mouse) +mouse_netterm Compiled with support for netterm mouse. +mouse_pterm Compiled with support for qnx pterm mouse. +mouse_sysmouse Compiled with support for sysmouse (*BSD console mouse) +mouse_xterm Compiled with support for xterm mouse. +multi_byte Compiled with support for 'encoding' +multi_byte_encoding 'encoding' is set to a multi-byte encoding. +multi_byte_ime Compiled with support for IME input method. +multi_lang Compiled with support for multiple languages. +mzscheme Compiled with MzScheme interface |mzscheme|. +netbeans_intg Compiled with support for |netbeans|. +netbeans_enabled Compiled with support for |netbeans| and connected. +ole Compiled with OLE automation support for Win32. +os2 OS/2 version of Vim. +osfiletype Compiled with support for osfiletypes |+osfiletype| +path_extra Compiled with up/downwards search in 'path' and 'tags' +perl Compiled with Perl interface. +persistent_undo Compiled with support for persistent undo history. +postscript Compiled with PostScript file printing. +printer Compiled with |:hardcopy| support. +profile Compiled with |:profile| support. +python Compiled with Python interface. +qnx QNX version of Vim. +quickfix Compiled with |quickfix| support. +reltime Compiled with |reltime()| support. +rightleft Compiled with 'rightleft' support. +ruby Compiled with Ruby interface |ruby|. +scrollbind Compiled with 'scrollbind' support. +showcmd Compiled with 'showcmd' support. +signs Compiled with |:sign| support. +smartindent Compiled with 'smartindent' support. +sniff Compiled with SNiFF interface support. +startuptime Compiled with |--startuptime| support. +statusline Compiled with support for 'statusline', 'rulerformat' + and special formats of 'titlestring' and 'iconstring'. +sun_workshop Compiled with support for Sun |workshop|. +spell Compiled with spell checking support |spell|. +syntax Compiled with syntax highlighting support |syntax|. +syntax_items There are active syntax highlighting items for the + current buffer. +system Compiled to use system() instead of fork()/exec(). +tag_binary Compiled with binary searching in tags files + |tag-binary-search|. +tag_old_static Compiled with support for old static tags + |tag-old-static|. +tag_any_white Compiled with support for any white characters in tags + files |tag-any-white|. +tcl Compiled with Tcl interface. +terminfo Compiled with terminfo instead of termcap. +termresponse Compiled with support for |t_RV| and |v:termresponse|. +textobjects Compiled with support for |text-objects|. +tgetent Compiled with tgetent support, able to use a termcap + or terminfo file. +title Compiled with window title support |'title'|. +toolbar Compiled with support for |gui-toolbar|. +unix Unix version of Vim. +user_commands User-defined commands. +viminfo Compiled with viminfo support. +vim_starting True while initial source'ing takes place. +vertsplit Compiled with vertically split windows |:vsplit|. +virtualedit Compiled with 'virtualedit' option. +visual Compiled with Visual mode. +visualextra Compiled with extra Visual mode commands. + |blockwise-operators|. +vms VMS version of Vim. +vreplace Compiled with |gR| and |gr| commands. +wildignore Compiled with 'wildignore' option. +wildmenu Compiled with 'wildmenu' option. +windows Compiled with support for more than one window. +winaltkeys Compiled with 'winaltkeys' option. +win16 Win16 version of Vim (MS-Windows 3.1). +win32 Win32 version of Vim (MS-Windows 95/98/ME/NT/2000/XP). +win64 Win64 version of Vim (MS-Windows 64 bit). +win32unix Win32 version of Vim, using Unix files (Cygwin) +win95 Win32 version for MS-Windows 95/98/ME. +writebackup Compiled with 'writebackup' default on. +xfontset Compiled with X fontset support |xfontset|. +xim Compiled with X input method support |xim|. +xsmp Compiled with X session management support. +xsmp_interact Compiled with interactive X session management support. +xterm_clipboard Compiled with support for xterm clipboard. +xterm_save Compiled with support for saving and restoring the + xterm screen. +x11 Compiled with X11 support. + + *string-match* +Matching a pattern in a String + +A regexp pattern as explained at |pattern| is normally used to find a match in +the buffer lines. When a pattern is used to find a match in a String, almost +everything works in the same way. The difference is that a String is handled +like it is one line. When it contains a "\n" character, this is not seen as a +line break for the pattern. It can be matched with a "\n" in the pattern, or +with ".". Example: > + :let a = "aaaa\nxxxx" + :echo matchstr(a, "..\n..") + aa + xx + :echo matchstr(a, "a.x") + a + x + +Don't forget that "^" will only match at the first character of the String and +"$" at the last character of the string. They don't match after or before a +"\n". + +============================================================================== +5. Defining functions *user-functions* + +New functions can be defined. These can be called just like builtin +functions. The function executes a sequence of Ex commands. Normal mode +commands can be executed with the |:normal| command. + +The function name must start with an uppercase letter, to avoid confusion with +builtin functions. To prevent from using the same name in different scripts +avoid obvious, short names. A good habit is to start the function name with +the name of the script, e.g., "HTMLcolor()". + +It's also possible to use curly braces, see |curly-braces-names|. And the +|autoload| facility is useful to define a function only when it's called. + + *local-function* +A function local to a script must start with "s:". A local script function +can only be called from within the script and from functions, user commands +and autocommands defined in the script. It is also possible to call the +function from a mapping defined in the script, but then || must be used +instead of "s:" when the mapping is expanded outside of the script. + + *:fu* *:function* *E128* *E129* *E123* +:fu[nction] List all functions and their arguments. + +:fu[nction] {name} List function {name}. + {name} can also be a |Dictionary| entry that is a + |Funcref|: > + :function dict.init + +:fu[nction] /{pattern} List functions with a name matching {pattern}. + Example that lists all functions ending with "File": > + :function /File$ +< + *:function-verbose* +When 'verbose' is non-zero, listing a function will also display where it was +last defined. Example: > + + :verbose function SetFileTypeSH + function SetFileTypeSH(name) + Last set from /usr/share/vim/vim-7.0/filetype.vim +< +See |:verbose-cmd| for more information. + + *E124* *E125* +:fu[nction][!] {name}([arguments]) [range] [abort] [dict] + Define a new function by the name {name}. The name + must be made of alphanumeric characters and '_', and + must start with a capital or "s:" (see above). + + {name} can also be a |Dictionary| entry that is a + |Funcref|: > + :function dict.init(arg) +< "dict" must be an existing dictionary. The entry + "init" is added if it didn't exist yet. Otherwise [!] + is required to overwrite an existing function. The + result is a |Funcref| to a numbered function. The + function can only be used with a |Funcref| and will be + deleted if there are no more references to it. + *E127* *E122* + When a function by this name already exists and [!] is + not used an error message is given. When [!] is used, + an existing function is silently replaced. Unless it + is currently being executed, that is an error. + + For the {arguments} see |function-argument|. + + *a:firstline* *a:lastline* + When the [range] argument is added, the function is + expected to take care of a range itself. The range is + passed as "a:firstline" and "a:lastline". If [range] + is excluded, ":{range}call" will call the function for + each line in the range, with the cursor on the start + of each line. See |function-range-example|. + + When the [abort] argument is added, the function will + abort as soon as an error is detected. + + When the [dict] argument is added, the function must + be invoked through an entry in a |Dictionary|. The + local variable "self" will then be set to the + dictionary. See |Dictionary-function|. + + *function-search-undo* + The last used search pattern and the redo command "." + will not be changed by the function. This also + implies that the effect of |:nohlsearch| is undone + when the function returns. + + *:endf* *:endfunction* *E126* *E193* +:endf[unction] The end of a function definition. Must be on a line + by its own, without other commands. + + *:delf* *:delfunction* *E130* *E131* +:delf[unction] {name} Delete function {name}. + {name} can also be a |Dictionary| entry that is a + |Funcref|: > + :delfunc dict.init +< This will remove the "init" entry from "dict". The + function is deleted if there are no more references to + it. + *:retu* *:return* *E133* +:retu[rn] [expr] Return from a function. When "[expr]" is given, it is + evaluated and returned as the result of the function. + If "[expr]" is not given, the number 0 is returned. + When a function ends without an explicit ":return", + the number 0 is returned. + Note that there is no check for unreachable lines, + thus there is no warning if commands follow ":return". + + If the ":return" is used after a |:try| but before the + matching |:finally| (if present), the commands + following the ":finally" up to the matching |:endtry| + are executed first. This process applies to all + nested ":try"s inside the function. The function + returns at the outermost ":endtry". + + *function-argument* *a:var* +An argument can be defined by giving its name. In the function this can then +be used as "a:name" ("a:" for argument). + *a:0* *a:1* *a:000* *E740* *...* +Up to 20 arguments can be given, separated by commas. After the named +arguments an argument "..." can be specified, which means that more arguments +may optionally be following. In the function the extra arguments can be used +as "a:1", "a:2", etc. "a:0" is set to the number of extra arguments (which +can be 0). "a:000" is set to a |List| that contains these arguments. Note +that "a:1" is the same as "a:000[0]". + *E742* +The a: scope and the variables in it cannot be changed, they are fixed. +However, if a |List| or |Dictionary| is used, you can change their contents. +Thus you can pass a |List| to a function and have the function add an item to +it. If you want to make sure the function cannot change a |List| or +|Dictionary| use |:lockvar|. + +When not using "...", the number of arguments in a function call must be equal +to the number of named arguments. When using "...", the number of arguments +may be larger. + +It is also possible to define a function without any arguments. You must +still supply the () then. The body of the function follows in the next lines, +until the matching |:endfunction|. It is allowed to define another function +inside a function body. + + *local-variables* +Inside a function variables can be used. These are local variables, which +will disappear when the function returns. Global variables need to be +accessed with "g:". + +Example: > + :function Table(title, ...) + : echohl Title + : echo a:title + : echohl None + : echo a:0 . " items:" + : for s in a:000 + : echon ' ' . s + : endfor + :endfunction + +This function can then be called with: > + call Table("Table", "line1", "line2") + call Table("Empty Table") + +To return more than one value, return a |List|: > + :function Compute(n1, n2) + : if a:n2 == 0 + : return ["fail", 0] + : endif + : return ["ok", a:n1 / a:n2] + :endfunction + +This function can then be called with: > + :let [success, div] = Compute(102, 6) + :if success == "ok" + : echo div + :endif +< + *:cal* *:call* *E107* *E117* +:[range]cal[l] {name}([arguments]) + Call a function. The name of the function and its arguments + are as specified with |:function|. Up to 20 arguments can be + used. The returned value is discarded. + Without a range and for functions that accept a range, the + function is called once. When a range is given the cursor is + positioned at the start of the first line before executing the + function. + When a range is given and the function doesn't handle it + itself, the function is executed for each line in the range, + with the cursor in the first column of that line. The cursor + is left at the last line (possibly moved by the last function + call). The arguments are re-evaluated for each line. Thus + this works: + *function-range-example* > + :function Mynumber(arg) + : echo line(".") . " " . a:arg + :endfunction + :1,5call Mynumber(getline(".")) +< + The "a:firstline" and "a:lastline" are defined anyway, they + can be used to do something different at the start or end of + the range. + + Example of a function that handles the range itself: > + + :function Cont() range + : execute (a:firstline + 1) . "," . a:lastline . 's/^/\t\\ ' + :endfunction + :4,8call Cont() +< + This function inserts the continuation character "\" in front + of all the lines in the range, except the first one. + + When the function returns a composite value it can be further + dereferenced, but the range will not be used then. Example: > + :4,8call GetDict().method() +< Here GetDict() gets the range but method() does not. + + *E132* +The recursiveness of user functions is restricted with the |'maxfuncdepth'| +option. + + +AUTOMATICALLY LOADING FUNCTIONS ~ + *autoload-functions* +When using many or large functions, it's possible to automatically define them +only when they are used. There are two methods: with an autocommand and with +the "autoload" directory in 'runtimepath'. + + +Using an autocommand ~ + +This is introduced in the user manual, section |41.14|. + +The autocommand is useful if you have a plugin that is a long Vim script file. +You can define the autocommand and quickly quit the script with |:finish|. +That makes Vim startup faster. The autocommand should then load the same file +again, setting a variable to skip the |:finish| command. + +Use the FuncUndefined autocommand event with a pattern that matches the +function(s) to be defined. Example: > + + :au FuncUndefined BufNet* source ~/vim/bufnetfuncs.vim + +The file "~/vim/bufnetfuncs.vim" should then define functions that start with +"BufNet". Also see |FuncUndefined|. + + +Using an autoload script ~ + *autoload* *E746* +This is introduced in the user manual, section |41.15|. + +Using a script in the "autoload" directory is simpler, but requires using +exactly the right file name. A function that can be autoloaded has a name +like this: > + + :call filename#funcname() + +When such a function is called, and it is not defined yet, Vim will search the +"autoload" directories in 'runtimepath' for a script file called +"filename.vim". For example "~/.vim/autoload/filename.vim". That file should +then define the function like this: > + + function filename#funcname() + echo "Done!" + endfunction + +The file name and the name used before the # in the function must match +exactly, and the defined function must have the name exactly as it will be +called. + +It is possible to use subdirectories. Every # in the function name works like +a path separator. Thus when calling a function: > + + :call foo#bar#func() + +Vim will look for the file "autoload/foo/bar.vim" in 'runtimepath'. + +This also works when reading a variable that has not been set yet: > + + :let l = foo#bar#lvar + +However, when the autoload script was already loaded it won't be loaded again +for an unknown variable. + +When assigning a value to such a variable nothing special happens. This can +be used to pass settings to the autoload script before it's loaded: > + + :let foo#bar#toggle = 1 + :call foo#bar#func() + +Note that when you make a mistake and call a function that is supposed to be +defined in an autoload script, but the script doesn't actually define the +function, the script will be sourced every time you try to call the function. +And you will get an error message every time. + +Also note that if you have two script files, and one calls a function in the +other and vice versa, before the used function is defined, it won't work. +Avoid using the autoload functionality at the toplevel. + +Hint: If you distribute a bunch of scripts you can pack them together with the +|vimball| utility. Also read the user manual |distribute-script|. + +============================================================================== +6. Curly braces names *curly-braces-names* + +Wherever you can use a variable, you can use a "curly braces name" variable. +This is a regular variable name with one or more expressions wrapped in braces +{} like this: > + my_{adjective}_variable + +When Vim encounters this, it evaluates the expression inside the braces, puts +that in place of the expression, and re-interprets the whole as a variable +name. So in the above example, if the variable "adjective" was set to +"noisy", then the reference would be to "my_noisy_variable", whereas if +"adjective" was set to "quiet", then it would be to "my_quiet_variable". + +One application for this is to create a set of variables governed by an option +value. For example, the statement > + echo my_{&background}_message + +would output the contents of "my_dark_message" or "my_light_message" depending +on the current value of 'background'. + +You can use multiple brace pairs: > + echo my_{adverb}_{adjective}_message +..or even nest them: > + echo my_{ad{end_of_word}}_message +where "end_of_word" is either "verb" or "jective". + +However, the expression inside the braces must evaluate to a valid single +variable name, e.g. this is invalid: > + :let foo='a + b' + :echo c{foo}d +.. since the result of expansion is "ca + bd", which is not a variable name. + + *curly-braces-function-names* +You can call and define functions by an evaluated name in a similar way. +Example: > + :let func_end='whizz' + :call my_func_{func_end}(parameter) + +This would call the function "my_func_whizz(parameter)". + +============================================================================== +7. Commands *expression-commands* + +:let {var-name} = {expr1} *:let* *E18* + Set internal variable {var-name} to the result of the + expression {expr1}. The variable will get the type + from the {expr}. If {var-name} didn't exist yet, it + is created. + +:let {var-name}[{idx}] = {expr1} *E689* + Set a list item to the result of the expression + {expr1}. {var-name} must refer to a list and {idx} + must be a valid index in that list. For nested list + the index can be repeated. + This cannot be used to add an item to a |List|. + This cannot be used to set a byte in a String. You + can do that like this: > + :let var = var[0:2] . 'X' . var[4:] +< + *E711* *E719* +:let {var-name}[{idx1}:{idx2}] = {expr1} *E708* *E709* *E710* + Set a sequence of items in a |List| to the result of + the expression {expr1}, which must be a list with the + correct number of items. + {idx1} can be omitted, zero is used instead. + {idx2} can be omitted, meaning the end of the list. + When the selected range of items is partly past the + end of the list, items will be added. + + *:let+=* *:let-=* *:let.=* *E734* +:let {var} += {expr1} Like ":let {var} = {var} + {expr1}". +:let {var} -= {expr1} Like ":let {var} = {var} - {expr1}". +:let {var} .= {expr1} Like ":let {var} = {var} . {expr1}". + These fail if {var} was not set yet and when the type + of {var} and {expr1} don't fit the operator. + + +:let ${env-name} = {expr1} *:let-environment* *:let-$* + Set environment variable {env-name} to the result of + the expression {expr1}. The type is always String. +:let ${env-name} .= {expr1} + Append {expr1} to the environment variable {env-name}. + If the environment variable didn't exist yet this + works like "=". + +:let @{reg-name} = {expr1} *:let-register* *:let-@* + Write the result of the expression {expr1} in register + {reg-name}. {reg-name} must be a single letter, and + must be the name of a writable register (see + |registers|). "@@" can be used for the unnamed + register, "@/" for the search pattern. + If the result of {expr1} ends in a or , the + register will be linewise, otherwise it will be set to + characterwise. + This can be used to clear the last search pattern: > + :let @/ = "" +< This is different from searching for an empty string, + that would match everywhere. + +:let @{reg-name} .= {expr1} + Append {expr1} to register {reg-name}. If the + register was empty it's like setting it to {expr1}. + +:let &{option-name} = {expr1} *:let-option* *:let-&* + Set option {option-name} to the result of the + expression {expr1}. A String or Number value is + always converted to the type of the option. + For an option local to a window or buffer the effect + is just like using the |:set| command: both the local + value and the global value are changed. + Example: > + :let &path = &path . ',/usr/local/include' + +:let &{option-name} .= {expr1} + For a string option: Append {expr1} to the value. + Does not insert a comma like |:set+=|. + +:let &{option-name} += {expr1} +:let &{option-name} -= {expr1} + For a number or boolean option: Add or subtract + {expr1}. + +:let &l:{option-name} = {expr1} +:let &l:{option-name} .= {expr1} +:let &l:{option-name} += {expr1} +:let &l:{option-name} -= {expr1} + Like above, but only set the local value of an option + (if there is one). Works like |:setlocal|. + +:let &g:{option-name} = {expr1} +:let &g:{option-name} .= {expr1} +:let &g:{option-name} += {expr1} +:let &g:{option-name} -= {expr1} + Like above, but only set the global value of an option + (if there is one). Works like |:setglobal|. + +:let [{name1}, {name2}, ...] = {expr1} *:let-unpack* *E687* *E688* + {expr1} must evaluate to a |List|. The first item in + the list is assigned to {name1}, the second item to + {name2}, etc. + The number of names must match the number of items in + the |List|. + Each name can be one of the items of the ":let" + command as mentioned above. + Example: > + :let [s, item] = GetItem(s) +< Detail: {expr1} is evaluated first, then the + assignments are done in sequence. This matters if + {name2} depends on {name1}. Example: > + :let x = [0, 1] + :let i = 0 + :let [i, x[i]] = [1, 2] + :echo x +< The result is [0, 2]. + +:let [{name1}, {name2}, ...] .= {expr1} +:let [{name1}, {name2}, ...] += {expr1} +:let [{name1}, {name2}, ...] -= {expr1} + Like above, but append/add/subtract the value for each + |List| item. + +:let [{name}, ..., ; {lastname}] = {expr1} + Like |:let-unpack| above, but the |List| may have more + items than there are names. A list of the remaining + items is assigned to {lastname}. If there are no + remaining items {lastname} is set to an empty list. + Example: > + :let [a, b; rest] = ["aval", "bval", 3, 4] +< +:let [{name}, ..., ; {lastname}] .= {expr1} +:let [{name}, ..., ; {lastname}] += {expr1} +:let [{name}, ..., ; {lastname}] -= {expr1} + Like above, but append/add/subtract the value for each + |List| item. + *E106* +:let {var-name} .. List the value of variable {var-name}. Multiple + variable names may be given. Special names recognized + here: *E738* + g: global variables + b: local buffer variables + w: local window variables + t: local tab page variables + s: script-local variables + l: local function variables + v: Vim variables. + +:let List the values of all variables. The type of the + variable is indicated before the value: + String + # Number + * Funcref + + +:unl[et][!] {name} ... *:unlet* *:unl* *E108* *E795* + Remove the internal variable {name}. Several variable + names can be given, they are all removed. The name + may also be a |List| or |Dictionary| item. + With [!] no error message is given for non-existing + variables. + One or more items from a |List| can be removed: > + :unlet list[3] " remove fourth item + :unlet list[3:] " remove fourth item to last +< One item from a |Dictionary| can be removed at a time: > + :unlet dict['two'] + :unlet dict.two +< This is especially useful to clean up used global + variables and script-local variables (these are not + deleted when the script ends). Function-local + variables are automatically deleted when the function + ends. + +:lockv[ar][!] [depth] {name} ... *:lockvar* *:lockv* + Lock the internal variable {name}. Locking means that + it can no longer be changed (until it is unlocked). + A locked variable can be deleted: > + :lockvar v + :let v = 'asdf' " fails! + :unlet v +< *E741* + If you try to change a locked variable you get an + error message: "E741: Value of {name} is locked" + + [depth] is relevant when locking a |List| or + |Dictionary|. It specifies how deep the locking goes: + 1 Lock the |List| or |Dictionary| itself, + cannot add or remove items, but can + still change their values. + 2 Also lock the values, cannot change + the items. If an item is a |List| or + |Dictionary|, cannot add or remove + items, but can still change the + values. + 3 Like 2 but for the |List| / + |Dictionary| in the |List| / + |Dictionary|, one level deeper. + The default [depth] is 2, thus when {name} is a |List| + or |Dictionary| the values cannot be changed. + *E743* + For unlimited depth use [!] and omit [depth]. + However, there is a maximum depth of 100 to catch + loops. + + Note that when two variables refer to the same |List| + and you lock one of them, the |List| will also be + locked when used through the other variable. + Example: > + :let l = [0, 1, 2, 3] + :let cl = l + :lockvar l + :let cl[1] = 99 " won't work! +< You may want to make a copy of a list to avoid this. + See |deepcopy()|. + + +:unlo[ckvar][!] [depth] {name} ... *:unlockvar* *:unlo* + Unlock the internal variable {name}. Does the + opposite of |:lockvar|. + + +:if {expr1} *:if* *:endif* *:en* *E171* *E579* *E580* +:en[dif] Execute the commands until the next matching ":else" + or ":endif" if {expr1} evaluates to non-zero. + + From Vim version 4.5 until 5.0, every Ex command in + between the ":if" and ":endif" is ignored. These two + commands were just to allow for future expansions in a + backwards compatible way. Nesting was allowed. Note + that any ":else" or ":elseif" was ignored, the "else" + part was not executed either. + + You can use this to remain compatible with older + versions: > + :if version >= 500 + : version-5-specific-commands + :endif +< The commands still need to be parsed to find the + "endif". Sometimes an older Vim has a problem with a + new command. For example, ":silent" is recognized as + a ":substitute" command. In that case ":execute" can + avoid problems: > + :if version >= 600 + : execute "silent 1,$delete" + :endif +< + NOTE: The ":append" and ":insert" commands don't work + properly in between ":if" and ":endif". + + *:else* *:el* *E581* *E583* +:el[se] Execute the commands until the next matching ":else" + or ":endif" if they previously were not being + executed. + + *:elseif* *:elsei* *E582* *E584* +:elsei[f] {expr1} Short for ":else" ":if", with the addition that there + is no extra ":endif". + +:wh[ile] {expr1} *:while* *:endwhile* *:wh* *:endw* + *E170* *E585* *E588* *E733* +:endw[hile] Repeat the commands between ":while" and ":endwhile", + as long as {expr1} evaluates to non-zero. + When an error is detected from a command inside the + loop, execution continues after the "endwhile". + Example: > + :let lnum = 1 + :while lnum <= line("$") + :call FixLine(lnum) + :let lnum = lnum + 1 + :endwhile +< + NOTE: The ":append" and ":insert" commands don't work + properly inside a ":while" and ":for" loop. + +:for {var} in {list} *:for* *E690* *E732* +:endfo[r] *:endfo* *:endfor* + Repeat the commands between ":for" and ":endfor" for + each item in {list}. Variable {var} is set to the + value of each item. + When an error is detected for a command inside the + loop, execution continues after the "endfor". + Changing {list} inside the loop affects what items are + used. Make a copy if this is unwanted: > + :for item in copy(mylist) +< When not making a copy, Vim stores a reference to the + next item in the list, before executing the commands + with the current item. Thus the current item can be + removed without effect. Removing any later item means + it will not be found. Thus the following example + works (an inefficient way to make a list empty): > + for item in mylist + call remove(mylist, 0) + endfor +< Note that reordering the list (e.g., with sort() or + reverse()) may have unexpected effects. + Note that the type of each list item should be + identical to avoid errors for the type of {var} + changing. Unlet the variable at the end of the loop + to allow multiple item types: > + for item in ["foo", ["bar"]] + echo item + unlet item " E706 without this + endfor + +:for [{var1}, {var2}, ...] in {listlist} +:endfo[r] + Like ":for" above, but each item in {listlist} must be + a list, of which each item is assigned to {var1}, + {var2}, etc. Example: > + :for [lnum, col] in [[1, 3], [2, 5], [3, 8]] + :echo getline(lnum)[col] + :endfor +< + *:continue* *:con* *E586* +:con[tinue] When used inside a ":while" or ":for" loop, jumps back + to the start of the loop. + If it is used after a |:try| inside the loop but + before the matching |:finally| (if present), the + commands following the ":finally" up to the matching + |:endtry| are executed first. This process applies to + all nested ":try"s inside the loop. The outermost + ":endtry" then jumps back to the start of the loop. + + *:break* *:brea* *E587* +:brea[k] When used inside a ":while" or ":for" loop, skips to + the command after the matching ":endwhile" or + ":endfor". + If it is used after a |:try| inside the loop but + before the matching |:finally| (if present), the + commands following the ":finally" up to the matching + |:endtry| are executed first. This process applies to + all nested ":try"s inside the loop. The outermost + ":endtry" then jumps to the command after the loop. + +:try *:try* *:endt* *:endtry* *E600* *E601* *E602* +:endt[ry] Change the error handling for the commands between + ":try" and ":endtry" including everything being + executed across ":source" commands, function calls, + or autocommand invocations. + + When an error or interrupt is detected and there is + a |:finally| command following, execution continues + after the ":finally". Otherwise, or when the + ":endtry" is reached thereafter, the next + (dynamically) surrounding ":try" is checked for + a corresponding ":finally" etc. Then the script + processing is terminated. (Whether a function + definition has an "abort" argument does not matter.) + Example: > + :try | edit too much | finally | echo "cleanup" | endtry + :echo "impossible" " not reached, script terminated above +< + Moreover, an error or interrupt (dynamically) inside + ":try" and ":endtry" is converted to an exception. It + can be caught as if it were thrown by a |:throw| + command (see |:catch|). In this case, the script + processing is not terminated. + + The value "Vim:Interrupt" is used for an interrupt + exception. An error in a Vim command is converted + to a value of the form "Vim({command}):{errmsg}", + other errors are converted to a value of the form + "Vim:{errmsg}". {command} is the full command name, + and {errmsg} is the message that is displayed if the + error exception is not caught, always beginning with + the error number. + Examples: > + :try | sleep 100 | catch /^Vim:Interrupt$/ | endtry + :try | edit | catch /^Vim(edit):E\d\+/ | echo "error" | endtry +< + *:cat* *:catch* *E603* *E604* *E605* +:cat[ch] /{pattern}/ The following commands until the next |:catch|, + |:finally|, or |:endtry| that belongs to the same + |:try| as the ":catch" are executed when an exception + matching {pattern} is being thrown and has not yet + been caught by a previous ":catch". Otherwise, these + commands are skipped. + When {pattern} is omitted all errors are caught. + Examples: > + :catch /^Vim:Interrupt$/ " catch interrupts (CTRL-C) + :catch /^Vim\%((\a\+)\)\=:E/ " catch all Vim errors + :catch /^Vim\%((\a\+)\)\=:/ " catch errors and interrupts + :catch /^Vim(write):/ " catch all errors in :write + :catch /^Vim\%((\a\+)\)\=:E123/ " catch error E123 + :catch /my-exception/ " catch user exception + :catch /.*/ " catch everything + :catch " same as /.*/ +< + Another character can be used instead of / around the + {pattern}, so long as it does not have a special + meaning (e.g., '|' or '"') and doesn't occur inside + {pattern}. + NOTE: It is not reliable to ":catch" the TEXT of + an error message because it may vary in different + locales. + + *:fina* *:finally* *E606* *E607* +:fina[lly] The following commands until the matching |:endtry| + are executed whenever the part between the matching + |:try| and the ":finally" is left: either by falling + through to the ":finally" or by a |:continue|, + |:break|, |:finish|, or |:return|, or by an error or + interrupt or exception (see |:throw|). + + *:th* *:throw* *E608* +:th[row] {expr1} The {expr1} is evaluated and thrown as an exception. + If the ":throw" is used after a |:try| but before the + first corresponding |:catch|, commands are skipped + until the first ":catch" matching {expr1} is reached. + If there is no such ":catch" or if the ":throw" is + used after a ":catch" but before the |:finally|, the + commands following the ":finally" (if present) up to + the matching |:endtry| are executed. If the ":throw" + is after the ":finally", commands up to the ":endtry" + are skipped. At the ":endtry", this process applies + again for the next dynamically surrounding ":try" + (which may be found in a calling function or sourcing + script), until a matching ":catch" has been found. + If the exception is not caught, the command processing + is terminated. + Example: > + :try | throw "oops" | catch /^oo/ | echo "caught" | endtry +< + + *:ec* *:echo* +:ec[ho] {expr1} .. Echoes each {expr1}, with a space in between. The + first {expr1} starts on a new line. + Also see |:comment|. + Use "\n" to start a new line. Use "\r" to move the + cursor to the first column. + Uses the highlighting set by the |:echohl| command. + Cannot be followed by a comment. + Example: > + :echo "the value of 'shell' is" &shell +< *:echo-redraw* + A later redraw may make the message disappear again. + And since Vim mostly postpones redrawing until it's + finished with a sequence of commands this happens + quite often. To avoid that a command from before the + ":echo" causes a redraw afterwards (redraws are often + postponed until you type something), force a redraw + with the |:redraw| command. Example: > + :new | redraw | echo "there is a new window" +< + *:echon* +:echon {expr1} .. Echoes each {expr1}, without anything added. Also see + |:comment|. + Uses the highlighting set by the |:echohl| command. + Cannot be followed by a comment. + Example: > + :echon "the value of 'shell' is " &shell +< + Note the difference between using ":echo", which is a + Vim command, and ":!echo", which is an external shell + command: > + :!echo % --> filename +< The arguments of ":!" are expanded, see |:_%|. > + :!echo "%" --> filename or "filename" +< Like the previous example. Whether you see the double + quotes or not depends on your 'shell'. > + :echo % --> nothing +< The '%' is an illegal character in an expression. > + :echo "%" --> % +< This just echoes the '%' character. > + :echo expand("%") --> filename +< This calls the expand() function to expand the '%'. + + *:echoh* *:echohl* +:echoh[l] {name} Use the highlight group {name} for the following + |:echo|, |:echon| and |:echomsg| commands. Also used + for the |input()| prompt. Example: > + :echohl WarningMsg | echo "Don't panic!" | echohl None +< Don't forget to set the group back to "None", + otherwise all following echo's will be highlighted. + + *:echom* *:echomsg* +:echom[sg] {expr1} .. Echo the expression(s) as a true message, saving the + message in the |message-history|. + Spaces are placed between the arguments as with the + |:echo| command. But unprintable characters are + displayed, not interpreted. + The parsing works slightly different from |:echo|, + more like |:execute|. All the expressions are first + evaluated and concatenated before echoing anything. + The expressions must evaluate to a Number or String, a + Dictionary or List causes an error. + Uses the highlighting set by the |:echohl| command. + Example: > + :echomsg "It's a Zizzer Zazzer Zuzz, as you can plainly see." +< See |:echo-redraw| to avoid the message disappearing + when the screen is redrawn. + *:echoe* *:echoerr* +:echoe[rr] {expr1} .. Echo the expression(s) as an error message, saving the + message in the |message-history|. When used in a + script or function the line number will be added. + Spaces are placed between the arguments as with the + :echo command. When used inside a try conditional, + the message is raised as an error exception instead + (see |try-echoerr|). + Example: > + :echoerr "This script just failed!" +< If you just want a highlighted message use |:echohl|. + And to get a beep: > + :exe "normal \" +< + *:exe* *:execute* +:exe[cute] {expr1} .. Executes the string that results from the evaluation + of {expr1} as an Ex command. + Multiple arguments are concatenated, with a space in + between. To avoid the extra space use the "." + operator to concatenate strings into one argument. + {expr1} is used as the processed command, command line + editing keys are not recognized. + Cannot be followed by a comment. + Examples: > + :execute "buffer" nextbuf + :execute "normal" count . "w" +< + ":execute" can be used to append a command to commands + that don't accept a '|'. Example: > + :execute '!ls' | echo "theend" + +< ":execute" is also a nice way to avoid having to type + control characters in a Vim script for a ":normal" + command: > + :execute "normal ixxx\" +< This has an character, see |expr-string|. + + Be careful to correctly escape special characters in + file names. The |fnameescape()| function can be used + for Vim commands, |shellescape()| for |:!| commands. + Examples: > + :execute "e " . fnameescape(filename) + :execute "!ls " . shellescape(expand('%:h'), 1) +< + Note: The executed string may be any command-line, but + you cannot start or end a "while", "for" or "if" + command. Thus this is illegal: > + :execute 'while i > 5' + :execute 'echo "test" | break' +< + It is allowed to have a "while" or "if" command + completely in the executed string: > + :execute 'while i < 5 | echo i | let i = i + 1 | endwhile' +< + + *:exe-comment* + ":execute", ":echo" and ":echon" cannot be followed by + a comment directly, because they see the '"' as the + start of a string. But, you can use '|' followed by a + comment. Example: > + :echo "foo" | "this is a comment + +============================================================================== +8. Exception handling *exception-handling* + +The Vim script language comprises an exception handling feature. This section +explains how it can be used in a Vim script. + +Exceptions may be raised by Vim on an error or on interrupt, see +|catch-errors| and |catch-interrupt|. You can also explicitly throw an +exception by using the ":throw" command, see |throw-catch|. + + +TRY CONDITIONALS *try-conditionals* + +Exceptions can be caught or can cause cleanup code to be executed. You can +use a try conditional to specify catch clauses (that catch exceptions) and/or +a finally clause (to be executed for cleanup). + A try conditional begins with a |:try| command and ends at the matching +|:endtry| command. In between, you can use a |:catch| command to start +a catch clause, or a |:finally| command to start a finally clause. There may +be none or multiple catch clauses, but there is at most one finally clause, +which must not be followed by any catch clauses. The lines before the catch +clauses and the finally clause is called a try block. > + + :try + : ... + : ... TRY BLOCK + : ... + :catch /{pattern}/ + : ... + : ... CATCH CLAUSE + : ... + :catch /{pattern}/ + : ... + : ... CATCH CLAUSE + : ... + :finally + : ... + : ... FINALLY CLAUSE + : ... + :endtry + +The try conditional allows to watch code for exceptions and to take the +appropriate actions. Exceptions from the try block may be caught. Exceptions +from the try block and also the catch clauses may cause cleanup actions. + When no exception is thrown during execution of the try block, the control +is transferred to the finally clause, if present. After its execution, the +script continues with the line following the ":endtry". + When an exception occurs during execution of the try block, the remaining +lines in the try block are skipped. The exception is matched against the +patterns specified as arguments to the ":catch" commands. The catch clause +after the first matching ":catch" is taken, other catch clauses are not +executed. The catch clause ends when the next ":catch", ":finally", or +":endtry" command is reached - whatever is first. Then, the finally clause +(if present) is executed. When the ":endtry" is reached, the script execution +continues in the following line as usual. + When an exception that does not match any of the patterns specified by the +":catch" commands is thrown in the try block, the exception is not caught by +that try conditional and none of the catch clauses is executed. Only the +finally clause, if present, is taken. The exception pends during execution of +the finally clause. It is resumed at the ":endtry", so that commands after +the ":endtry" are not executed and the exception might be caught elsewhere, +see |try-nesting|. + When during execution of a catch clause another exception is thrown, the +remaining lines in that catch clause are not executed. The new exception is +not matched against the patterns in any of the ":catch" commands of the same +try conditional and none of its catch clauses is taken. If there is, however, +a finally clause, it is executed, and the exception pends during its +execution. The commands following the ":endtry" are not executed. The new +exception might, however, be caught elsewhere, see |try-nesting|. + When during execution of the finally clause (if present) an exception is +thrown, the remaining lines in the finally clause are skipped. If the finally +clause has been taken because of an exception from the try block or one of the +catch clauses, the original (pending) exception is discarded. The commands +following the ":endtry" are not executed, and the exception from the finally +clause is propagated and can be caught elsewhere, see |try-nesting|. + +The finally clause is also executed, when a ":break" or ":continue" for +a ":while" loop enclosing the complete try conditional is executed from the +try block or a catch clause. Or when a ":return" or ":finish" is executed +from the try block or a catch clause of a try conditional in a function or +sourced script, respectively. The ":break", ":continue", ":return", or +":finish" pends during execution of the finally clause and is resumed when the +":endtry" is reached. It is, however, discarded when an exception is thrown +from the finally clause. + When a ":break" or ":continue" for a ":while" loop enclosing the complete +try conditional or when a ":return" or ":finish" is encountered in the finally +clause, the rest of the finally clause is skipped, and the ":break", +":continue", ":return" or ":finish" is executed as usual. If the finally +clause has been taken because of an exception or an earlier ":break", +":continue", ":return", or ":finish" from the try block or a catch clause, +this pending exception or command is discarded. + +For examples see |throw-catch| and |try-finally|. + + +NESTING OF TRY CONDITIONALS *try-nesting* + +Try conditionals can be nested arbitrarily. That is, a complete try +conditional can be put into the try block, a catch clause, or the finally +clause of another try conditional. If the inner try conditional does not +catch an exception thrown in its try block or throws a new exception from one +of its catch clauses or its finally clause, the outer try conditional is +checked according to the rules above. If the inner try conditional is in the +try block of the outer try conditional, its catch clauses are checked, but +otherwise only the finally clause is executed. It does not matter for +nesting, whether the inner try conditional is directly contained in the outer +one, or whether the outer one sources a script or calls a function containing +the inner try conditional. + +When none of the active try conditionals catches an exception, just their +finally clauses are executed. Thereafter, the script processing terminates. +An error message is displayed in case of an uncaught exception explicitly +thrown by a ":throw" command. For uncaught error and interrupt exceptions +implicitly raised by Vim, the error message(s) or interrupt message are shown +as usual. + +For examples see |throw-catch|. + + +EXAMINING EXCEPTION HANDLING CODE *except-examine* + +Exception handling code can get tricky. If you are in doubt what happens, set +'verbose' to 13 or use the ":13verbose" command modifier when sourcing your +script file. Then you see when an exception is thrown, discarded, caught, or +finished. When using a verbosity level of at least 14, things pending in +a finally clause are also shown. This information is also given in debug mode +(see |debug-scripts|). + + +THROWING AND CATCHING EXCEPTIONS *throw-catch* + +You can throw any number or string as an exception. Use the |:throw| command +and pass the value to be thrown as argument: > + :throw 4711 + :throw "string" +< *throw-expression* +You can also specify an expression argument. The expression is then evaluated +first, and the result is thrown: > + :throw 4705 + strlen("string") + :throw strpart("strings", 0, 6) + +An exception might be thrown during evaluation of the argument of the ":throw" +command. Unless it is caught there, the expression evaluation is abandoned. +The ":throw" command then does not throw a new exception. + Example: > + + :function! Foo(arg) + : try + : throw a:arg + : catch /foo/ + : endtry + : return 1 + :endfunction + : + :function! Bar() + : echo "in Bar" + : return 4710 + :endfunction + : + :throw Foo("arrgh") + Bar() + +This throws "arrgh", and "in Bar" is not displayed since Bar() is not +executed. > + :throw Foo("foo") + Bar() +however displays "in Bar" and throws 4711. + +Any other command that takes an expression as argument might also be +abandoned by an (uncaught) exception during the expression evaluation. The +exception is then propagated to the caller of the command. + Example: > + + :if Foo("arrgh") + : echo "then" + :else + : echo "else" + :endif + +Here neither of "then" or "else" is displayed. + + *catch-order* +Exceptions can be caught by a try conditional with one or more |:catch| +commands, see |try-conditionals|. The values to be caught by each ":catch" +command can be specified as a pattern argument. The subsequent catch clause +gets executed when a matching exception is caught. + Example: > + + :function! Foo(value) + : try + : throw a:value + : catch /^\d\+$/ + : echo "Number thrown" + : catch /.*/ + : echo "String thrown" + : endtry + :endfunction + : + :call Foo(0x1267) + :call Foo('string') + +The first call to Foo() displays "Number thrown", the second "String thrown". +An exception is matched against the ":catch" commands in the order they are +specified. Only the first match counts. So you should place the more +specific ":catch" first. The following order does not make sense: > + + : catch /.*/ + : echo "String thrown" + : catch /^\d\+$/ + : echo "Number thrown" + +The first ":catch" here matches always, so that the second catch clause is +never taken. + + *throw-variables* +If you catch an exception by a general pattern, you may access the exact value +in the variable |v:exception|: > + + : catch /^\d\+$/ + : echo "Number thrown. Value is" v:exception + +You may also be interested where an exception was thrown. This is stored in +|v:throwpoint|. Note that "v:exception" and "v:throwpoint" are valid for the +exception most recently caught as long it is not finished. + Example: > + + :function! Caught() + : if v:exception != "" + : echo 'Caught "' . v:exception . '" in ' . v:throwpoint + : else + : echo 'Nothing caught' + : endif + :endfunction + : + :function! Foo() + : try + : try + : try + : throw 4711 + : finally + : call Caught() + : endtry + : catch /.*/ + : call Caught() + : throw "oops" + : endtry + : catch /.*/ + : call Caught() + : finally + : call Caught() + : endtry + :endfunction + : + :call Foo() + +This displays > + + Nothing caught + Caught "4711" in function Foo, line 4 + Caught "oops" in function Foo, line 10 + Nothing caught + +A practical example: The following command ":LineNumber" displays the line +number in the script or function where it has been used: > + + :function! LineNumber() + : return substitute(v:throwpoint, '.*\D\(\d\+\).*', '\1', "") + :endfunction + :command! LineNumber try | throw "" | catch | echo LineNumber() | endtry +< + *try-nested* +An exception that is not caught by a try conditional can be caught by +a surrounding try conditional: > + + :try + : try + : throw "foo" + : catch /foobar/ + : echo "foobar" + : finally + : echo "inner finally" + : endtry + :catch /foo/ + : echo "foo" + :endtry + +The inner try conditional does not catch the exception, just its finally +clause is executed. The exception is then caught by the outer try +conditional. The example displays "inner finally" and then "foo". + + *throw-from-catch* +You can catch an exception and throw a new one to be caught elsewhere from the +catch clause: > + + :function! Foo() + : throw "foo" + :endfunction + : + :function! Bar() + : try + : call Foo() + : catch /foo/ + : echo "Caught foo, throw bar" + : throw "bar" + : endtry + :endfunction + : + :try + : call Bar() + :catch /.*/ + : echo "Caught" v:exception + :endtry + +This displays "Caught foo, throw bar" and then "Caught bar". + + *rethrow* +There is no real rethrow in the Vim script language, but you may throw +"v:exception" instead: > + + :function! Bar() + : try + : call Foo() + : catch /.*/ + : echo "Rethrow" v:exception + : throw v:exception + : endtry + :endfunction +< *try-echoerr* +Note that this method cannot be used to "rethrow" Vim error or interrupt +exceptions, because it is not possible to fake Vim internal exceptions. +Trying so causes an error exception. You should throw your own exception +denoting the situation. If you want to cause a Vim error exception containing +the original error exception value, you can use the |:echoerr| command: > + + :try + : try + : asdf + : catch /.*/ + : echoerr v:exception + : endtry + :catch /.*/ + : echo v:exception + :endtry + +This code displays + + Vim(echoerr):Vim:E492: Not an editor command: asdf ~ + + +CLEANUP CODE *try-finally* + +Scripts often change global settings and restore them at their end. If the +user however interrupts the script by pressing CTRL-C, the settings remain in +an inconsistent state. The same may happen to you in the development phase of +a script when an error occurs or you explicitly throw an exception without +catching it. You can solve these problems by using a try conditional with +a finally clause for restoring the settings. Its execution is guaranteed on +normal control flow, on error, on an explicit ":throw", and on interrupt. +(Note that errors and interrupts from inside the try conditional are converted +to exceptions. When not caught, they terminate the script after the finally +clause has been executed.) +Example: > + + :try + : let s:saved_ts = &ts + : set ts=17 + : + : " Do the hard work here. + : + :finally + : let &ts = s:saved_ts + : unlet s:saved_ts + :endtry + +This method should be used locally whenever a function or part of a script +changes global settings which need to be restored on failure or normal exit of +that function or script part. + + *break-finally* +Cleanup code works also when the try block or a catch clause is left by +a ":continue", ":break", ":return", or ":finish". + Example: > + + :let first = 1 + :while 1 + : try + : if first + : echo "first" + : let first = 0 + : continue + : else + : throw "second" + : endif + : catch /.*/ + : echo v:exception + : break + : finally + : echo "cleanup" + : endtry + : echo "still in while" + :endwhile + :echo "end" + +This displays "first", "cleanup", "second", "cleanup", and "end". > + + :function! Foo() + : try + : return 4711 + : finally + : echo "cleanup\n" + : endtry + : echo "Foo still active" + :endfunction + : + :echo Foo() "returned by Foo" + +This displays "cleanup" and "4711 returned by Foo". You don't need to add an +extra ":return" in the finally clause. (Above all, this would override the +return value.) + + *except-from-finally* +Using either of ":continue", ":break", ":return", ":finish", or ":throw" in +a finally clause is possible, but not recommended since it abandons the +cleanup actions for the try conditional. But, of course, interrupt and error +exceptions might get raised from a finally clause. + Example where an error in the finally clause stops an interrupt from +working correctly: > + + :try + : try + : echo "Press CTRL-C for interrupt" + : while 1 + : endwhile + : finally + : unlet novar + : endtry + :catch /novar/ + :endtry + :echo "Script still running" + :sleep 1 + +If you need to put commands that could fail into a finally clause, you should +think about catching or ignoring the errors in these commands, see +|catch-errors| and |ignore-errors|. + + +CATCHING ERRORS *catch-errors* + +If you want to catch specific errors, you just have to put the code to be +watched in a try block and add a catch clause for the error message. The +presence of the try conditional causes all errors to be converted to an +exception. No message is displayed and |v:errmsg| is not set then. To find +the right pattern for the ":catch" command, you have to know how the format of +the error exception is. + Error exceptions have the following format: > + + Vim({cmdname}):{errmsg} +or > + Vim:{errmsg} + +{cmdname} is the name of the command that failed; the second form is used when +the command name is not known. {errmsg} is the error message usually produced +when the error occurs outside try conditionals. It always begins with +a capital "E", followed by a two or three-digit error number, a colon, and +a space. + +Examples: + +The command > + :unlet novar +normally produces the error message > + E108: No such variable: "novar" +which is converted inside try conditionals to an exception > + Vim(unlet):E108: No such variable: "novar" + +The command > + :dwim +normally produces the error message > + E492: Not an editor command: dwim +which is converted inside try conditionals to an exception > + Vim:E492: Not an editor command: dwim + +You can catch all ":unlet" errors by a > + :catch /^Vim(unlet):/ +or all errors for misspelled command names by a > + :catch /^Vim:E492:/ + +Some error messages may be produced by different commands: > + :function nofunc +and > + :delfunction nofunc +both produce the error message > + E128: Function name must start with a capital: nofunc +which is converted inside try conditionals to an exception > + Vim(function):E128: Function name must start with a capital: nofunc +or > + Vim(delfunction):E128: Function name must start with a capital: nofunc +respectively. You can catch the error by its number independently on the +command that caused it if you use the following pattern: > + :catch /^Vim(\a\+):E128:/ + +Some commands like > + :let x = novar +produce multiple error messages, here: > + E121: Undefined variable: novar + E15: Invalid expression: novar +Only the first is used for the exception value, since it is the most specific +one (see |except-several-errors|). So you can catch it by > + :catch /^Vim(\a\+):E121:/ + +You can catch all errors related to the name "nofunc" by > + :catch /\/ + +You can catch all Vim errors in the ":write" and ":read" commands by > + :catch /^Vim(\(write\|read\)):E\d\+:/ + +You can catch all Vim errors by the pattern > + :catch /^Vim\((\a\+)\)\=:E\d\+:/ +< + *catch-text* +NOTE: You should never catch the error message text itself: > + :catch /No such variable/ +only works in the english locale, but not when the user has selected +a different language by the |:language| command. It is however helpful to +cite the message text in a comment: > + :catch /^Vim(\a\+):E108:/ " No such variable + + +IGNORING ERRORS *ignore-errors* + +You can ignore errors in a specific Vim command by catching them locally: > + + :try + : write + :catch + :endtry + +But you are strongly recommended NOT to use this simple form, since it could +catch more than you want. With the ":write" command, some autocommands could +be executed and cause errors not related to writing, for instance: > + + :au BufWritePre * unlet novar + +There could even be such errors you are not responsible for as a script +writer: a user of your script might have defined such autocommands. You would +then hide the error from the user. + It is much better to use > + + :try + : write + :catch /^Vim(write):/ + :endtry + +which only catches real write errors. So catch only what you'd like to ignore +intentionally. + +For a single command that does not cause execution of autocommands, you could +even suppress the conversion of errors to exceptions by the ":silent!" +command: > + :silent! nunmap k +This works also when a try conditional is active. + + +CATCHING INTERRUPTS *catch-interrupt* + +When there are active try conditionals, an interrupt (CTRL-C) is converted to +the exception "Vim:Interrupt". You can catch it like every exception. The +script is not terminated, then. + Example: > + + :function! TASK1() + : sleep 10 + :endfunction + + :function! TASK2() + : sleep 20 + :endfunction + + :while 1 + : let command = input("Type a command: ") + : try + : if command == "" + : continue + : elseif command == "END" + : break + : elseif command == "TASK1" + : call TASK1() + : elseif command == "TASK2" + : call TASK2() + : else + : echo "\nIllegal command:" command + : continue + : endif + : catch /^Vim:Interrupt$/ + : echo "\nCommand interrupted" + : " Caught the interrupt. Continue with next prompt. + : endtry + :endwhile + +You can interrupt a task here by pressing CTRL-C; the script then asks for +a new command. If you press CTRL-C at the prompt, the script is terminated. + +For testing what happens when CTRL-C would be pressed on a specific line in +your script, use the debug mode and execute the |>quit| or |>interrupt| +command on that line. See |debug-scripts|. + + +CATCHING ALL *catch-all* + +The commands > + + :catch /.*/ + :catch // + :catch + +catch everything, error exceptions, interrupt exceptions and exceptions +explicitly thrown by the |:throw| command. This is useful at the top level of +a script in order to catch unexpected things. + Example: > + + :try + : + : " do the hard work here + : + :catch /MyException/ + : + : " handle known problem + : + :catch /^Vim:Interrupt$/ + : echo "Script interrupted" + :catch /.*/ + : echo "Internal error (" . v:exception . ")" + : echo " - occurred at " . v:throwpoint + :endtry + :" end of script + +Note: Catching all might catch more things than you want. Thus, you are +strongly encouraged to catch only for problems that you can really handle by +specifying a pattern argument to the ":catch". + Example: Catching all could make it nearly impossible to interrupt a script +by pressing CTRL-C: > + + :while 1 + : try + : sleep 1 + : catch + : endtry + :endwhile + + +EXCEPTIONS AND AUTOCOMMANDS *except-autocmd* + +Exceptions may be used during execution of autocommands. Example: > + + :autocmd User x try + :autocmd User x throw "Oops!" + :autocmd User x catch + :autocmd User x echo v:exception + :autocmd User x endtry + :autocmd User x throw "Arrgh!" + :autocmd User x echo "Should not be displayed" + : + :try + : doautocmd User x + :catch + : echo v:exception + :endtry + +This displays "Oops!" and "Arrgh!". + + *except-autocmd-Pre* +For some commands, autocommands get executed before the main action of the +command takes place. If an exception is thrown and not caught in the sequence +of autocommands, the sequence and the command that caused its execution are +abandoned and the exception is propagated to the caller of the command. + Example: > + + :autocmd BufWritePre * throw "FAIL" + :autocmd BufWritePre * echo "Should not be displayed" + : + :try + : write + :catch + : echo "Caught:" v:exception "from" v:throwpoint + :endtry + +Here, the ":write" command does not write the file currently being edited (as +you can see by checking 'modified'), since the exception from the BufWritePre +autocommand abandons the ":write". The exception is then caught and the +script displays: > + + Caught: FAIL from BufWrite Auto commands for "*" +< + *except-autocmd-Post* +For some commands, autocommands get executed after the main action of the +command has taken place. If this main action fails and the command is inside +an active try conditional, the autocommands are skipped and an error exception +is thrown that can be caught by the caller of the command. + Example: > + + :autocmd BufWritePost * echo "File successfully written!" + : + :try + : write /i/m/p/o/s/s/i/b/l/e + :catch + : echo v:exception + :endtry + +This just displays: > + + Vim(write):E212: Can't open file for writing (/i/m/p/o/s/s/i/b/l/e) + +If you really need to execute the autocommands even when the main action +fails, trigger the event from the catch clause. + Example: > + + :autocmd BufWritePre * set noreadonly + :autocmd BufWritePost * set readonly + : + :try + : write /i/m/p/o/s/s/i/b/l/e + :catch + : doautocmd BufWritePost /i/m/p/o/s/s/i/b/l/e + :endtry +< +You can also use ":silent!": > + + :let x = "ok" + :let v:errmsg = "" + :autocmd BufWritePost * if v:errmsg != "" + :autocmd BufWritePost * let x = "after fail" + :autocmd BufWritePost * endif + :try + : silent! write /i/m/p/o/s/s/i/b/l/e + :catch + :endtry + :echo x + +This displays "after fail". + +If the main action of the command does not fail, exceptions from the +autocommands will be catchable by the caller of the command: > + + :autocmd BufWritePost * throw ":-(" + :autocmd BufWritePost * echo "Should not be displayed" + : + :try + : write + :catch + : echo v:exception + :endtry +< + *except-autocmd-Cmd* +For some commands, the normal action can be replaced by a sequence of +autocommands. Exceptions from that sequence will be catchable by the caller +of the command. + Example: For the ":write" command, the caller cannot know whether the file +had actually been written when the exception occurred. You need to tell it in +some way. > + + :if !exists("cnt") + : let cnt = 0 + : + : autocmd BufWriteCmd * if &modified + : autocmd BufWriteCmd * let cnt = cnt + 1 + : autocmd BufWriteCmd * if cnt % 3 == 2 + : autocmd BufWriteCmd * throw "BufWriteCmdError" + : autocmd BufWriteCmd * endif + : autocmd BufWriteCmd * write | set nomodified + : autocmd BufWriteCmd * if cnt % 3 == 0 + : autocmd BufWriteCmd * throw "BufWriteCmdError" + : autocmd BufWriteCmd * endif + : autocmd BufWriteCmd * echo "File successfully written!" + : autocmd BufWriteCmd * endif + :endif + : + :try + : write + :catch /^BufWriteCmdError$/ + : if &modified + : echo "Error on writing (file contents not changed)" + : else + : echo "Error after writing" + : endif + :catch /^Vim(write):/ + : echo "Error on writing" + :endtry + +When this script is sourced several times after making changes, it displays +first > + File successfully written! +then > + Error on writing (file contents not changed) +then > + Error after writing +etc. + + *except-autocmd-ill* +You cannot spread a try conditional over autocommands for different events. +The following code is ill-formed: > + + :autocmd BufWritePre * try + : + :autocmd BufWritePost * catch + :autocmd BufWritePost * echo v:exception + :autocmd BufWritePost * endtry + : + :write + + +EXCEPTION HIERARCHIES AND PARAMETERIZED EXCEPTIONS *except-hier-param* + +Some programming languages allow to use hierarchies of exception classes or to +pass additional information with the object of an exception class. You can do +similar things in Vim. + In order to throw an exception from a hierarchy, just throw the complete +class name with the components separated by a colon, for instance throw the +string "EXCEPT:MATHERR:OVERFLOW" for an overflow in a mathematical library. + When you want to pass additional information with your exception class, add +it in parentheses, for instance throw the string "EXCEPT:IO:WRITEERR(myfile)" +for an error when writing "myfile". + With the appropriate patterns in the ":catch" command, you can catch for +base classes or derived classes of your hierarchy. Additional information in +parentheses can be cut out from |v:exception| with the ":substitute" command. + Example: > + + :function! CheckRange(a, func) + : if a:a < 0 + : throw "EXCEPT:MATHERR:RANGE(" . a:func . ")" + : endif + :endfunction + : + :function! Add(a, b) + : call CheckRange(a:a, "Add") + : call CheckRange(a:b, "Add") + : let c = a:a + a:b + : if c < 0 + : throw "EXCEPT:MATHERR:OVERFLOW" + : endif + : return c + :endfunction + : + :function! Div(a, b) + : call CheckRange(a:a, "Div") + : call CheckRange(a:b, "Div") + : if (a:b == 0) + : throw "EXCEPT:MATHERR:ZERODIV" + : endif + : return a:a / a:b + :endfunction + : + :function! Write(file) + : try + : execute "write" fnameescape(a:file) + : catch /^Vim(write):/ + : throw "EXCEPT:IO(" . getcwd() . ", " . a:file . "):WRITEERR" + : endtry + :endfunction + : + :try + : + : " something with arithmetics and I/O + : + :catch /^EXCEPT:MATHERR:RANGE/ + : let function = substitute(v:exception, '.*(\(\a\+\)).*', '\1', "") + : echo "Range error in" function + : + :catch /^EXCEPT:MATHERR/ " catches OVERFLOW and ZERODIV + : echo "Math error" + : + :catch /^EXCEPT:IO/ + : let dir = substitute(v:exception, '.*(\(.\+\),\s*.\+).*', '\1', "") + : let file = substitute(v:exception, '.*(.\+,\s*\(.\+\)).*', '\1', "") + : if file !~ '^/' + : let file = dir . "/" . file + : endif + : echo 'I/O error for "' . file . '"' + : + :catch /^EXCEPT/ + : echo "Unspecified error" + : + :endtry + +The exceptions raised by Vim itself (on error or when pressing CTRL-C) use +a flat hierarchy: they are all in the "Vim" class. You cannot throw yourself +exceptions with the "Vim" prefix; they are reserved for Vim. + Vim error exceptions are parameterized with the name of the command that +failed, if known. See |catch-errors|. + + +PECULIARITIES + *except-compat* +The exception handling concept requires that the command sequence causing the +exception is aborted immediately and control is transferred to finally clauses +and/or a catch clause. + +In the Vim script language there are cases where scripts and functions +continue after an error: in functions without the "abort" flag or in a command +after ":silent!", control flow goes to the following line, and outside +functions, control flow goes to the line following the outermost ":endwhile" +or ":endif". On the other hand, errors should be catchable as exceptions +(thus, requiring the immediate abortion). + +This problem has been solved by converting errors to exceptions and using +immediate abortion (if not suppressed by ":silent!") only when a try +conditional is active. This is no restriction since an (error) exception can +be caught only from an active try conditional. If you want an immediate +termination without catching the error, just use a try conditional without +catch clause. (You can cause cleanup code being executed before termination +by specifying a finally clause.) + +When no try conditional is active, the usual abortion and continuation +behavior is used instead of immediate abortion. This ensures compatibility of +scripts written for Vim 6.1 and earlier. + +However, when sourcing an existing script that does not use exception handling +commands (or when calling one of its functions) from inside an active try +conditional of a new script, you might change the control flow of the existing +script on error. You get the immediate abortion on error and can catch the +error in the new script. If however the sourced script suppresses error +messages by using the ":silent!" command (checking for errors by testing +|v:errmsg| if appropriate), its execution path is not changed. The error is +not converted to an exception. (See |:silent|.) So the only remaining cause +where this happens is for scripts that don't care about errors and produce +error messages. You probably won't want to use such code from your new +scripts. + + *except-syntax-err* +Syntax errors in the exception handling commands are never caught by any of +the ":catch" commands of the try conditional they belong to. Its finally +clauses, however, is executed. + Example: > + + :try + : try + : throw 4711 + : catch /\(/ + : echo "in catch with syntax error" + : catch + : echo "inner catch-all" + : finally + : echo "inner finally" + : endtry + :catch + : echo 'outer catch-all caught "' . v:exception . '"' + : finally + : echo "outer finally" + :endtry + +This displays: > + inner finally + outer catch-all caught "Vim(catch):E54: Unmatched \(" + outer finally +The original exception is discarded and an error exception is raised, instead. + + *except-single-line* +The ":try", ":catch", ":finally", and ":endtry" commands can be put on +a single line, but then syntax errors may make it difficult to recognize the +"catch" line, thus you better avoid this. + Example: > + :try | unlet! foo # | catch | endtry +raises an error exception for the trailing characters after the ":unlet!" +argument, but does not see the ":catch" and ":endtry" commands, so that the +error exception is discarded and the "E488: Trailing characters" message gets +displayed. + + *except-several-errors* +When several errors appear in a single command, the first error message is +usually the most specific one and therefor converted to the error exception. + Example: > + echo novar +causes > + E121: Undefined variable: novar + E15: Invalid expression: novar +The value of the error exception inside try conditionals is: > + Vim(echo):E121: Undefined variable: novar +< *except-syntax-error* +But when a syntax error is detected after a normal error in the same command, +the syntax error is used for the exception being thrown. + Example: > + unlet novar # +causes > + E108: No such variable: "novar" + E488: Trailing characters +The value of the error exception inside try conditionals is: > + Vim(unlet):E488: Trailing characters +This is done because the syntax error might change the execution path in a way +not intended by the user. Example: > + try + try | unlet novar # | catch | echo v:exception | endtry + catch /.*/ + echo "outer catch:" v:exception + endtry +This displays "outer catch: Vim(unlet):E488: Trailing characters", and then +a "E600: Missing :endtry" error message is given, see |except-single-line|. + +============================================================================== +9. Examples *eval-examples* + +Printing in Binary ~ +> + :" The function Nr2Bin() returns the binary string representation of a number. + :func Nr2Bin(nr) + : let n = a:nr + : let r = "" + : while n + : let r = '01'[n % 2] . r + : let n = n / 2 + : endwhile + : return r + :endfunc + + :" The function String2Bin() converts each character in a string to a + :" binary string, separated with dashes. + :func String2Bin(str) + : let out = '' + : for ix in range(strlen(a:str)) + : let out = out . '-' . Nr2Bin(char2nr(a:str[ix])) + : endfor + : return out[1:] + :endfunc + +Example of its use: > + :echo Nr2Bin(32) +result: "100000" > + :echo String2Bin("32") +result: "110011-110010" + + +Sorting lines ~ + +This example sorts lines with a specific compare function. > + + :func SortBuffer() + : let lines = getline(1, '$') + : call sort(lines, function("Strcmp")) + : call setline(1, lines) + :endfunction + +As a one-liner: > + :call setline(1, sort(getline(1, '$'), function("Strcmp"))) + + +scanf() replacement ~ + *sscanf* +There is no sscanf() function in Vim. If you need to extract parts from a +line, you can use matchstr() and substitute() to do it. This example shows +how to get the file name, line number and column number out of a line like +"foobar.txt, 123, 45". > + :" Set up the match bit + :let mx='\(\f\+\),\s*\(\d\+\),\s*\(\d\+\)' + :"get the part matching the whole expression + :let l = matchstr(line, mx) + :"get each item out of the match + :let file = substitute(l, mx, '\1', '') + :let lnum = substitute(l, mx, '\2', '') + :let col = substitute(l, mx, '\3', '') + +The input is in the variable "line", the results in the variables "file", +"lnum" and "col". (idea from Michael Geddes) + + +getting the scriptnames in a Dictionary ~ + *scriptnames-dictionary* +The |:scriptnames| command can be used to get a list of all script files that +have been sourced. There is no equivalent function or variable for this +(because it's rarely needed). In case you need to manipulate the list this +code can be used: > + " Get the output of ":scriptnames" in the scriptnames_output variable. + let scriptnames_output = '' + redir => scriptnames_output + silent scriptnames + redir END + + " Split the output into lines and parse each line. Add an entry to the + " "scripts" dictionary. + let scripts = {} + for line in split(scriptnames_output, "\n") + " Only do non-blank lines. + if line =~ '\S' + " Get the first number in the line. + let nr = matchstr(line, '\d\+') + " Get the file name, remove the script number " 123: ". + let name = substitute(line, '.\+:\s*', '', '') + " Add an item to the Dictionary + let scripts[nr] = name + endif + endfor + unlet scriptnames_output + +============================================================================== +10. No +eval feature *no-eval-feature* + +When the |+eval| feature was disabled at compile time, none of the expression +evaluation commands are available. To prevent this from causing Vim scripts +to generate all kinds of errors, the ":if" and ":endif" commands are still +recognized, though the argument of the ":if" and everything between the ":if" +and the matching ":endif" is ignored. Nesting of ":if" blocks is allowed, but +only if the commands are at the start of the line. The ":else" command is not +recognized. + +Example of how to avoid executing commands when the |+eval| feature is +missing: > + + :if 1 + : echo "Expression evaluation is compiled in" + :else + : echo "You will _never_ see this message" + :endif + +============================================================================== +11. The sandbox *eval-sandbox* *sandbox* *E48* + +The 'foldexpr', 'formatexpr', 'includeexpr', 'indentexpr', 'statusline' and +'foldtext' options may be evaluated in a sandbox. This means that you are +protected from these expressions having nasty side effects. This gives some +safety for when these options are set from a modeline. It is also used when +the command from a tags file is executed and for CTRL-R = in the command line. +The sandbox is also used for the |:sandbox| command. + +These items are not allowed in the sandbox: + - changing the buffer text + - defining or changing mapping, autocommands, functions, user commands + - setting certain options (see |option-summary|) + - setting certain v: variables (see |v:var|) *E794* + - executing a shell command + - reading or writing a file + - jumping to another buffer or editing a file + - executing Python, Perl, etc. commands +This is not guaranteed 100% secure, but it should block most attacks. + + *:san* *:sandbox* +:san[dbox] {cmd} Execute {cmd} in the sandbox. Useful to evaluate an + option that may have been set from a modeline, e.g. + 'foldexpr'. + + *sandbox-option* +A few options contain an expression. When this expression is evaluated it may +have to be done in the sandbox to avoid a security risk. But the sandbox is +restrictive, thus this only happens when the option was set from an insecure +location. Insecure in this context are: +- sourcing a .vimrc or .exrc in the current directory +- while executing in the sandbox +- value coming from a modeline + +Note that when in the sandbox and saving an option value and restoring it, the +option will still be marked as it was set in the sandbox. + +============================================================================== +12. Textlock *textlock* + +In a few situations it is not allowed to change the text in the buffer, jump +to another window and some other things that might confuse or break what Vim +is currently doing. This mostly applies to things that happen when Vim is +actually doing something else. For example, evaluating the 'balloonexpr' may +happen any moment the mouse cursor is resting at some position. + +This is not allowed when the textlock is active: + - changing the buffer text + - jumping to another buffer or window + - editing another file + - closing a window or quitting Vim + - etc. + + + vim:tw=78:ts=8:ft=help:norl: diff -Naur vim73.orig/runtime/doc/if_cscop.txt vim73.patched/runtime/doc/if_cscop.txt --- vim73.orig/runtime/doc/if_cscop.txt 2010-08-15 07:23:20.000000000 -0500 +++ vim73.patched/runtime/doc/if_cscop.txt 2012-05-20 12:55:41.000000000 -0500 @@ -272,6 +272,15 @@ :set cst :set nocst < + *cscoperelative* *csre* +If 'cscoperelative' set, then in absence of a prefix given to cscope (prefx +is the argument to -P option of cscope), basename of cscope.out location +(usually the project root directory) will be used as the prefix to construt +absolute path.The default is off. Note: This option is only effective when +cscope (cscopeprg) is initialized without a prefix path (-P). Examples: > + :set csre + :set nocsre +< *cscopetagorder* *csto* The value of 'csto' determines the order in which |:cstag| performs a search. If 'csto' is set to zero, cscope database(s) are searched first, followed diff -Naur vim73.orig/runtime/doc/if_cscop.txt.orig vim73.patched/runtime/doc/if_cscop.txt.orig --- vim73.orig/runtime/doc/if_cscop.txt.orig 1969-12-31 18:00:00.000000000 -0600 +++ vim73.patched/runtime/doc/if_cscop.txt.orig 2010-08-15 07:23:20.000000000 -0500 @@ -0,0 +1,490 @@ +*if_cscop.txt* For Vim version 7.3. Last change: 2009 Mar 18 + + + VIM REFERENCE MANUAL by Andy Kahn + + *cscope* *Cscope* +This document explains how to use Vim's cscope interface. + +Cscope is a tool like ctags, but think of it as ctags on steroids since it +does a lot more than what ctags provides. In Vim, jumping to a result from +a cscope query is just like jumping to any tag; it is saved on the tag stack +so that with the right keyboard mappings, you can jump back and forth between +functions as you normally would with |tags|. + +1. Cscope introduction |cscope-intro| +2. Cscope related commands |cscope-commands| +3. Cscope options |cscope-options| +4. How to use cscope in Vim |cscope-howtouse| +5. Limitations |cscope-limitations| +6. Suggested usage |cscope-suggestions| +7. Availability & Information |cscope-info| + +This is currently for Unix and Win32 only. +{Vi does not have any of these commands} + +============================================================================== +1. Cscope introduction *cscope-intro* + +The following text is taken from a version of the cscope man page: + + ----- + + Cscope is an interactive screen-oriented tool that helps you: + + Learn how a C program works without endless flipping through a thick + listing. + + Locate the section of code to change to fix a bug without having to + learn the entire program. + + Examine the effect of a proposed change such as adding a value to an + enum variable. + + Verify that a change has been made in all source files such as adding + an argument to an existing function. + + Rename a global variable in all source files. + + Change a constant to a preprocessor symbol in selected lines of files. + + It is designed to answer questions like: + Where is this symbol used? + Where is it defined? + Where did this variable get its value? + What is this global symbol's definition? + Where is this function in the source files? + What functions call this function? + What functions are called by this function? + Where does the message "out of space" come from? + Where is this source file in the directory structure? + What files include this header file? + + Cscope answers these questions from a symbol database that it builds the + first time it is used on the source files. On a subsequent call, cscope + rebuilds the database only if a source file has changed or the list of + source files is different. When the database is rebuilt the data for the + unchanged files is copied from the old database, which makes rebuilding + much faster than the initial build. + + ----- + +When cscope is normally invoked, you will get a full-screen selection +screen allowing you to make a query for one of the above questions. +However, once a match is found to your query and you have entered your +text editor to edit the source file containing match, you cannot simply +jump from tag to tag as you normally would with vi's Ctrl-] or :tag +command. + +Vim's cscope interface is done by invoking cscope with its line-oriented +interface, and then parsing the output returned from a query. The end +result is that cscope query results become just like regular tags, so +you can jump to them just like you do with normal tags (Ctrl-] or :tag) +and then go back by popping off the tagstack with Ctrl-T. (Please note +however, that you don't actually jump to a cscope tag simply by doing +Ctrl-] or :tag without remapping these commands or setting an option. +See the remaining sections on how the cscope interface works and for +suggested use.) + + +============================================================================== +2. Cscope related commands *cscope-commands* + + *:cscope* *:cs* *:scs* *:scscope* *E259* *E262* *E561* *E560* +All cscope commands are accessed through suboptions to the main cscope +command ":cscope". The shortest abbreviation is ":cs". The ":scscope" +command does the same and also splits the window (short: "scs"). + +The available subcommands are: + + *E563* *E564* *E566* *E568* *E569* *E622* *E623* + *E625* *E626* *E609* + add : Add a new cscope database/connection. + + USAGE :cs add {file|dir} [pre-path] [flags] + + [pre-path] is the pathname used with the -P command to cscope. + + [flags] are any additional flags you want to pass to cscope. + + EXAMPLES > + :cscope add /usr/local/cdb/cscope.out + :cscope add /projects/vim/cscope.out /usr/local/vim + :cscope add cscope.out /usr/local/vim -C +< + *cscope-find* *cs-find* + *E565* *E567* + find : Query cscope. All cscope query options are available + except option #5 ("Change this grep pattern"). + + USAGE :cs find {querytype} {name} + + {querytype} corresponds to the actual cscope line + interface numbers as well as default nvi commands: + + 0 or s: Find this C symbol + 1 or g: Find this definition + 2 or d: Find functions called by this function + 3 or c: Find functions calling this function + 4 or t: Find this text string + 6 or e: Find this egrep pattern + 7 or f: Find this file + 8 or i: Find files #including this file + + For all types, except 4 and 6, leading white space for {name} is + removed. For 4 and 6 there is exactly one space between {querytype} + and {name}. Further white space is included in {name}. + + EXAMPLES > + :cscope find c vim_free + :cscope find 3 vim_free +< + These two examples perform the same query: functions calling + "vim_free". > + + :cscope find t initOnce + :cscope find t initOnce +< + The first one searches for the text "initOnce", the second one for + " initOnce". > + + :cscope find 0 DEFAULT_TERM +< + Executing this example on the source code for Vim 5.1 produces the + following output: + + Cscope tag: DEFAULT_TERM + # line filename / context / line + 1 1009 vim-5.1-gtk/src/term.c <> + #define DEFAULT_TERM (char_u *)"amiga" + 2 1013 vim-5.1-gtk/src/term.c <> + #define DEFAULT_TERM (char_u *)"win32" + 3 1017 vim-5.1-gtk/src/term.c <> + #define DEFAULT_TERM (char_u *)"pcterm" + 4 1021 vim-5.1-gtk/src/term.c <> + #define DEFAULT_TERM (char_u *)"ansi" + 5 1025 vim-5.1-gtk/src/term.c <> + #define DEFAULT_TERM (char_u *)"vt52" + 6 1029 vim-5.1-gtk/src/term.c <> + #define DEFAULT_TERM (char_u *)"os2ansi" + 7 1033 vim-5.1-gtk/src/term.c <> + #define DEFAULT_TERM (char_u *)"ansi" + 8 1037 vim-5.1-gtk/src/term.c <> + # undef DEFAULT_TERM + 9 1038 vim-5.1-gtk/src/term.c <> + #define DEFAULT_TERM (char_u *)"beos-ansi" + 10 1042 vim-5.1-gtk/src/term.c <> + #define DEFAULT_TERM (char_u *)"mac-ansi" + 11 1335 vim-5.1-gtk/src/term.c <> + term = DEFAULT_TERM; + 12 1459 vim-5.1-gtk/src/term.c <> + if (STRCMP(term, DEFAULT_TERM)) + 13 1826 vim-5.1-gtk/src/term.c <> + term = DEFAULT_TERM; + 14 1833 vim-5.1-gtk/src/term.c <> + term = DEFAULT_TERM; + 15 3635 vim-5.1-gtk/src/term.c <> + p = find_builtin_term(DEFAULT_TERM); + Enter nr of choice ( to abort): + + The output shows several pieces of information: + 1. The tag number (there are 15 in this example). + 2. The line number where the tag occurs. + 3. The filename where the tag occurs. + 4. The context of the tag (e.g., global, or the function name). + 5. The line from the file itself. + + help : Show a brief synopsis. + + USAGE :cs help + + *E260* *E261* + kill : Kill a cscope connection (or kill all cscope connections). + + USAGE :cs kill {num|partial_name} + + To kill a cscope connection, the connection number or a partial + name must be specified. The partial name is simply any part of + the pathname of the cscope database. Kill a cscope connection + using the partial name with caution! + + If the specified connection number is -1, then _ALL_ cscope + connections will be killed. + + reset : Reinit all cscope connections. + + USAGE :cs reset + + show : Show cscope connections. + + USAGE :cs show + + *:lcscope* *:lcs* +This command is same as the ":cscope" command, except when the +'cscopequickfix' option is set, the location list for the current window is +used instead of the quickfix list to show the cscope results. + + *:cstag* *E257* *E562* +If you use cscope as well as ctags, |:cstag| allows you to search one or +the other before making a jump. For example, you can choose to first +search your cscope database(s) for a match, and if one is not found, then +your tags file(s) will be searched. The order in which this happens +is determined by the value of |csto|. See |cscope-options| for more +details. + +|:cstag| performs the equivalent of ":cs find g" on the identifier when +searching through the cscope database(s). + +|:cstag| performs the equivalent of |:tjump| on the identifier when searching +through your tags file(s). + + +============================================================================== +3. Cscope options *cscope-options* + +Use the |:set| command to set all cscope options. Ideally, you would do +this in one of your startup files (e.g., .vimrc). Some cscope related +variables are only valid within |.vimrc|. Setting them after vim has +started will have no effect! + + *cscopeprg* *csprg* +'cscopeprg' specifies the command to execute cscope. The default is +"cscope". For example: > + :set csprg=/usr/local/bin/cscope +< + *cscopequickfix* *csqf* *E469* +{not available when compiled without the |+quickfix| feature} +'cscopequickfix' specifies whether to use quickfix window to show cscope +results. This is a list of comma-separated values. Each item consists of +|cscope-find| command (s, g, d, c, t, e, f or i) and flag (+, - or 0). +'+' indicates that results must be appended to quickfix window, +'-' implies previous results clearance, '0' or command absence - don't use +quickfix. Search is performed from start until first command occurrence. +The default value is "" (don't use quickfix anyway). The following value +seems to be useful: > + :set cscopequickfix=s-,c-,d-,i-,t-,e- +< + *cscopetag* *cst* +If 'cscopetag' set, the commands ":tag" and CTRL-] as well as "vim -t" will +always use |:cstag| instead of the default :tag behavior. Effectively, by +setting 'cst', you will always search your cscope databases as well as your +tag files. The default is off. Examples: > + :set cst + :set nocst +< + *cscopetagorder* *csto* +The value of 'csto' determines the order in which |:cstag| performs a search. +If 'csto' is set to zero, cscope database(s) are searched first, followed +by tag file(s) if cscope did not return any matches. If 'csto' is set to +one, tag file(s) are searched before cscope database(s). The default is zero. +Examples: > + :set csto=0 + :set csto=1 +< + *cscopeverbose* *csverb* +If 'cscopeverbose' is not set (the default), messages will not be printed +indicating success or failure when adding a cscope database. Ideally, you +should reset this option in your |.vimrc| before adding any cscope databases, +and after adding them, set it. From then on, when you add more databases +within Vim, you will get a (hopefully) useful message should the database fail +to be added. Examples: > + :set csverb + :set nocsverb +< + *cscopepathcomp* *cspc* +The value of 'cspc' determines how many components of a file's path to +display. With the default value of zero the entire path will be displayed. +The value one will display only the filename with no path. Other values +display that many components. For example: > + :set cspc=3 +will display the last 3 components of the file's path, including the file +name itself. + +============================================================================== +4. How to use cscope in Vim *cscope-howtouse* + +The first thing you need to do is to build a cscope database for your +source files. For the most basic case, simply do "cscope -b". Please +refer to the cscope man page for more details. + +Assuming you have a cscope database, you need to "add" the database to Vim. +This establishes a cscope "connection" and makes it available for Vim to use. +You can do this in your .vimrc file, or you can do it manually after starting +vim. For example, to add the cscope database "cscope.out", you would do: + + :cs add cscope.out + +You can double-check the result of this by executing ":cs show". This will +produce output which looks like this: + + # pid database name prepend path + 0 28806 cscope.out + +Note: +Because of the Microsoft RTL limitations, Win32 version shows 0 instead +of the real pid. + +Once a cscope connection is established, you can make queries to cscope and +the results will be printed to you. Queries are made using the command +":cs find". For example: + + :cs find g ALIGN_SIZE + +This can get a little cumbersome since one ends up doing a significant +amount of typing. Fortunately, there are ways around this by mapping +shortcut keys. See |cscope-suggestions| for suggested usage. + +If the results return only one match, you will automatically be taken to it. +If there is more than one match, you will be given a selection screen to pick +the match you want to go to. After you have jumped to the new location, +simply hit Ctrl-T to get back to the previous one. + + +============================================================================== +5. Limitations *cscope-limitations* + +Cscope support for Vim is only available on systems that support these four +system calls: fork(), pipe(), execl(), waitpid(). This means it is mostly +limited to Unix systems. + +Additionally Cscope support works for Win32. For more information and a +cscope version for Win32 see: + + http://iamphet.nm.ru/cscope/index.html + +The DJGPP-built version from http://cscope.sourceforge.net is known to not +work with Vim. + +Hard-coded limitation: doing a |:tjump| when |:cstag| searches the tag files +is not configurable (e.g., you can't do a tselect instead). + +============================================================================== +6. Suggested usage *cscope-suggestions* + +Put these entries in your .vimrc (adjust the pathname accordingly to your +setup): > + + if has("cscope") + set csprg=/usr/local/bin/cscope + set csto=0 + set cst + set nocsverb + " add any database in current directory + if filereadable("cscope.out") + cs add cscope.out + " else add database pointed to by environment + elseif $CSCOPE_DB != "" + cs add $CSCOPE_DB + endif + set csverb + endif + +By setting 'cscopetag', we have effectively replaced all instances of the :tag +command with :cstag. This includes :tag, Ctrl-], and "vim -t". In doing +this, the regular tag command not only searches your ctags generated tag +files, but your cscope databases as well. + +Some users may want to keep the regular tag behavior and have a different +shortcut to access :cstag. For example, one could map Ctrl-_ (underscore) +to :cstag with the following command: > + + map :cstag =expand("") + +A couple of very commonly used cscope queries (using ":cs find") is to +find all functions calling a certain function and to find all occurrences +of a particular C symbol. To do this, you can use these mappings as an +example: > + + map g :cs find 3 =expand("") + map g :cs find 0 =expand("") + +These mappings for Ctrl-] (right bracket) and Ctrl-\ (backslash) allow you to +place your cursor over the function name or C symbol and quickly query cscope +for any matches. + +Or you may use the following scheme, inspired by Vim/Cscope tutorial from +Cscope Home Page (http://cscope.sourceforge.net/): > + + nmap s :cs find s =expand("") + nmap g :cs find g =expand("") + nmap c :cs find c =expand("") + nmap t :cs find t =expand("") + nmap e :cs find e =expand("") + nmap f :cs find f =expand("") + nmap i :cs find i ^=expand("")$ + nmap d :cs find d =expand("") + + " Using 'CTRL-spacebar' then a search type makes the vim window + " split horizontally, with search result displayed in + " the new window. + + nmap s :scs find s =expand("") + nmap g :scs find g =expand("") + nmap c :scs find c =expand("") + nmap t :scs find t =expand("") + nmap e :scs find e =expand("") + nmap f :scs find f =expand("") + nmap i :scs find i ^=expand("")$ + nmap d :scs find d =expand("") + + " Hitting CTRL-space *twice* before the search type does a vertical + " split instead of a horizontal one + + nmap s + \:vert scs find s =expand("") + nmap g + \:vert scs find g =expand("") + nmap c + \:vert scs find c =expand("") + nmap t + \:vert scs find t =expand("") + nmap e + \:vert scs find e =expand("") + nmap i + \:vert scs find i ^=expand("")$ + nmap d + \:vert scs find d =expand("") + +============================================================================== +7. Cscope availability and information *cscope-info* + +If you do not already have cscope (it did not come with your compiler +license or OS distribution), then you can download it for free from: + http://cscope.sourceforge.net/ +This is released by SCO under the BSD license. + +If you want a newer version of cscope, you will probably have to buy it. +According to the (old) nvi documentation: + + You can buy version 13.3 source with an unrestricted license + for $400 from AT&T Software Solutions by calling +1-800-462-8146. + +Also you can download cscope 13.x and mlcscope 14.x (multi-lingual cscope +which supports C, C++, Java, lex, yacc, breakpoint listing, Ingres, and SDL) +from World-Wide Exptools Open Source packages page: + http://www.bell-labs.com/project/wwexptools/packages.html + +In Solaris 2.x, if you have the C compiler license, you will also have +cscope. Both are usually located under /opt/SUNWspro/bin + +SGI developers can also get it. Search for Cscope on this page: + http://freeware.sgi.com/index-by-alpha.html + https://toolbox.sgi.com/toolbox/utilities/cscope/ +The second one is for those who have a password for the SGI toolbox. + +There is source to an older version of a cscope clone (called "cs") available +on the net. Due to various reasons, this is not supported with Vim. + +The cscope interface/support for Vim was originally written by +Andy Kahn . The original structure (as well as a tiny +bit of code) was adapted from the cscope interface in nvi. Please report +any problems, suggestions, patches, et al., you have for the usage of +cscope within Vim to him. + *cscope-win32* +For a cscope version for Win32 see: + http://code.google.com/p/cscope-win32/ + +Win32 support was added by Sergey Khorev . Contact +him if you have Win32-specific issues. + + vim:tw=78:ts=8:ft=help:norl: diff -Naur vim73.orig/runtime/doc/if_lua.txt vim73.patched/runtime/doc/if_lua.txt --- vim73.orig/runtime/doc/if_lua.txt 2010-08-15 07:23:20.000000000 -0500 +++ vim73.patched/runtime/doc/if_lua.txt 2012-05-20 12:55:43.000000000 -0500 @@ -1,4 +1,4 @@ -*if_lua.txt* For Vim version 7.3. Last change: 2010 Jul 22 +*if_lua.txt* For Vim version 7.3. Last change: 2012 Jan 16 VIM REFERENCE MANUAL by Luis Carvalho @@ -8,8 +8,11 @@ 1. Commands |lua-commands| 2. The vim module |lua-vim| -3. Buffer userdata |lua-buffer| -4. Window userdata |lua-window| +3. List userdata |lua-list| +4. Dict userdata |lua-dict| +5. Buffer userdata |lua-buffer| +6. Window userdata |lua-window| +7. The luaeval function |lua-luaeval| {Vi does not have any of these commands} @@ -88,11 +91,9 @@ All these commands execute a Lua chunk from either the command line (:lua and :luado) or a file (:luafile) with the given line [range]. Similarly to the Lua interpreter, each chunk has its own scope and so only global variables are -shared between command calls. Lua default libraries "table", "string", "math", -and "package" are available, "io" and "debug" are not, and "os" is restricted -to functions "date", "clock", "time", "difftime", and "getenv". In addition, -Lua "print" function has its output redirected to the Vim message area, with -arguments separated by a white space instead of a tab. +shared between command calls. All Lua default libraries are available. In +addition, Lua "print" function has its output redirected to the Vim message +area, with arguments separated by a white space instead of a tab. Lua uses the "vim" module (see |lua-vim|) to issue commands to Vim and manage buffers (|lua-buffer|) and windows (|lua-window|). However, @@ -108,9 +109,9 @@ module also includes routines for buffer, window, and current line queries, Vim evaluation and command execution, and others. - vim.isbuffer(value) Returns 'true' (boolean, not string) if - "value" is a buffer userdata and 'false' - otherwise (see |lua-buffer|). + vim.list() Returns an empty list (see |List|). + + vim.dict() Returns an empty dictionary (see |Dictionary|). vim.buffer([arg]) If "arg" is a number, returns buffer with number "arg" in the buffer list or, if "arg" @@ -121,16 +122,21 @@ 'true' returns the first buffer in the buffer list or else the current buffer. - vim.iswindow(value) Returns 'true' (boolean, not string) if - "value" is a window userdata and - 'false' otherwise (see |lua-window|). - vim.window([arg]) If "arg" is a number, returns window with number "arg" or 'nil' (nil value, not string) if not found. Otherwise, if "toboolean(arg)" is 'true' returns the first window or else the current window. + vim.type({arg}) Returns the type of {arg}. It is equivalent to + Lua's "type" function, but returns "list", + "dict", "buffer", or "window" if {arg} is a + list, dictionary, buffer, or window, + respectively. Examples: > + :lua l = vim.list() + :lua print(type(l), vim.type(l)) + :" userdata list +< vim.command({cmd}) Executes the vim (ex-mode) command {cmd}. Examples: > :lua vim.command"set tw=60" @@ -141,7 +147,7 @@ Vim strings and numbers are directly converted to Lua strings and numbers respectively. Vim lists and dictionaries are converted to Lua - tables (lists become integer-keyed tables). + userdata (see |lua-list| and |lua-dict|). Examples: > :lua tw = vim.eval"&tw" :lua print(vim.eval"{'a': 'one'}".a) @@ -157,7 +163,72 @@ ============================================================================== -3. Buffer userdata *lua-buffer* +3. List userdata *lua-list* + +List userdata represent vim lists, and the interface tries to follow closely +Vim's syntax for lists. Since lists are objects, changes in list references in +Lua are reflected in Vim and vice-versa. A list "l" has the following +properties and methods: + +Properties +---------- + o "#l" is the number of items in list "l", equivalent to "len(l)" + in Vim. + o "l[k]" returns the k-th item in "l"; "l" is zero-indexed, as in Vim. + To modify the k-th item, simply do "l[k] = newitem"; in + particular, "l[k] = nil" removes the k-th item from "l". + o "l()" returns an iterator for "l". + +Methods +------- + o "l:add(item)" appends "item" to the end of "l". + o "l:insert(item[, pos])" inserts "item" at (optional) + position "pos" in the list. The default value for "pos" is 0. + +Examples: +> + :let l = [1, 'item'] + :lua l = vim.eval('l') -- same 'l' + :lua l:add(vim.list()) + :lua l[0] = math.pi + :echo l[0] " 3.141593 + :lua l[0] = nil -- remove first item + :lua l:insert(true, 1) + :lua print(l, #l, l[0], l[1], l[-1]) + :lua for item in l() do print(item) end +< + +============================================================================== +4. Dict userdata *lua-dict* + +Similarly to list userdata, dict userdata represent vim dictionaries; since +dictionaries are also objects, references are kept between Lua and Vim. A dict +"d" has the following properties: + +Properties +---------- + o "#d" is the number of items in dict "d", equivalent to "len(d)" + in Vim. + o "d.key" or "d['key']" returns the value at entry "key" in "d". + To modify the entry at this key, simply do "d.key = newvalue"; in + particular, "d.key = nil" removes the entry from "d". + o "d()" returns an iterator for "d" and is equivalent to "items(d)" in + Vim. + +Examples: +> + :let d = {'n':10} + :lua d = vim.eval('d') -- same 'd' + :lua print(d, d.n, #d) + :let d.self = d + :lua for k, v in d() do print(d, k, v) end + :lua d.x = math.pi + :lua d.self = nil -- remove entry + :echo d +< + +============================================================================== +5. Buffer userdata *lua-buffer* Buffer userdata represent vim buffers. A buffer userdata "b" has the following properties and methods: @@ -209,7 +280,7 @@ < ============================================================================== -4. Window userdata *lua-window* +6. Window userdata *lua-window* Window objects represent vim windows. A window userdata "w" has the following properties and methods: @@ -241,4 +312,29 @@ < ============================================================================== - vim:tw=78:ts=8:ft=help:norl: +7. The luaeval function *lua-luaeval* + +The (dual) equivalent of "vim.eval" for passing Lua values to Vim is +"luaeval". "luaeval" takes an expression string and an optional argument and +returns the result of the expression. It is semantically equivalent in Lua to: +> + local chunkheader = "local _A = select(1, ...) return " + function luaeval (expstr, arg) + local chunk = assert(loadstring(chunkheader .. expstr, "luaeval")) + return chunk(arg) -- return typval + end +< +Note that "_A" receives the argument to "luaeval". Examples: > + + :echo luaeval('math.pi') + :lua a = vim.list():add('newlist') + :let a = luaeval('a') + :echo a[0] " 'newlist' + :function Rand(x,y) " random uniform between x and y + : return luaeval('(_A.y-_A.x)*math.random()+_A.x', {'x':a:x,'y':a:y}) + : endfunction + :echo Rand(1,10) + + +============================================================================== + vim:tw=78:ts=8:noet:ft=help:norl: diff -Naur vim73.orig/runtime/doc/indent.txt vim73.patched/runtime/doc/indent.txt --- vim73.orig/runtime/doc/indent.txt 2010-08-15 07:23:20.000000000 -0500 +++ vim73.patched/runtime/doc/indent.txt 2012-05-20 12:55:43.000000000 -0500 @@ -128,13 +128,20 @@ used CTRL-T or CTRL-D. *cinoptions-values* -The 'cinoptions' option sets how Vim performs indentation. In the list below, +The 'cinoptions' option sets how Vim performs indentation. The value after +the option character can be one of these (N is any number): + N indent N spaces + -N indent N spaces to the left + Ns N times 'shiftwidth spaces + -Ns N times 'shiftwidth spaces to the left + +In the list below, "N" represents a number of your choice (the number can be negative). When there is an 's' after the number, Vim multiplies the number by 'shiftwidth': "1s" is 'shiftwidth', "2s" is two times 'shiftwidth', etc. You can use a -decimal point, too: "-0.5s" is minus half a 'shiftwidth'. The examples below -assume a 'shiftwidth' of 4. - +decimal point, too: "-0.5s" is minus half a 'shiftwidth'. +The examples below assume a 'shiftwidth' of 4. + *cino->* >N Amount added for "normal" indent. Used after a line that should increase the indent (lines starting with "if", an opening brace, etc.). (default 'shiftwidth'). @@ -145,6 +152,7 @@ foo; foo; foo; } } } < + *cino-e* eN Add N to the prevailing indent inside a set of braces if the opening brace at the End of the line (more precise: is not the first character in a line). This is useful if you want a @@ -160,6 +168,7 @@ bar; bar; bar; } } } < + *cino-n* nN Add N to the prevailing indent for a statement after an "if", "while", etc., if it is NOT inside a set of braces. This is useful if you want a different indent when there is no '{' @@ -174,6 +183,7 @@ bar; bar; bar; } } } < + *cino-f* fN Place the first opening brace of a function or other block in column N. This applies only for an opening brace that is not inside other braces and is at the start of the line. What comes @@ -184,6 +194,7 @@ { { { int foo; int foo; int foo; < + *cino-{* {N Place opening braces N characters from the prevailing indent. This applies only for opening braces that are inside other braces. (default 0). @@ -193,6 +204,7 @@ { { { foo; foo; foo; < + *cino-}* }N Place closing braces N characters from the matching opening brace. (default 0). @@ -202,6 +214,7 @@ foo; foo; foo; } } } < + *cino-^* ^N Add N to the prevailing indent inside a set of braces if the opening brace is in column 0. This can specify a different indent for whole of a function (some may like to set it to a @@ -216,6 +229,7 @@ } } } } } } < + *cino-L* LN Controls placement of jump labels. If N is negative, the label will be placed at column 1. If N is non-negative, the indent of the label will be the prevailing indent minus N. (default -1). @@ -229,6 +243,7 @@ } } } } } } < + *cino-:* :N Place case labels N characters from the indent of the switch(). (default 'shiftwidth'). @@ -240,6 +255,7 @@ default: default: } } < + *cino-=* =N Place statements occurring after a case label N characters from the indent of the label. (default 'shiftwidth'). @@ -247,6 +263,7 @@ case 11: case 11: a = a + 1; a = a + 1; b = b + 1; < + *cino-l* lN If N != 0 Vim will align with a case label instead of the statement after it in the same line. @@ -256,6 +273,7 @@ break; break; } } < + *cino-b* bN If N != 0 Vim will align a final "break" with the case label, so that case..break looks like a sort of block. (default: 0). @@ -271,6 +289,7 @@ break; break; } } < + *cino-g* gN Place C++ scope declarations N characters from the indent of the block they are in. (default 'shiftwidth'). A scope declaration can be "public:", "protected:" or "private:". @@ -282,6 +301,7 @@ private: private: } } < + *cino-h* hN Place statements occurring after a C++ scope declaration N characters from the indent of the label. (default 'shiftwidth'). @@ -290,6 +310,21 @@ public: public: a = a + 1; a = a + 1; b = b + 1; < + *cino-N* + NN Indent inside C++ namespace N characters extra compared to a + normal block. (default 0). + + cino= cino=N-s > + namespace { namespace { + void function(); void function(); + } } + + namespace my namespace my + { { + void function(); void function(); + } } +< + *cino-p* pN Parameter declarations for K&R-style function declarations will be indented N characters from the margin. (default 'shiftwidth'). @@ -299,6 +334,7 @@ int a; int a; int a; char b; char b; char b; < + *cino-t* tN Indent a function return type declaration N characters from the margin. (default 'shiftwidth'). @@ -306,6 +342,7 @@ int int int func() func() func() < + *cino-i* iN Indent C++ base class declarations and constructor initializations, if they start in a new line (otherwise they are aligned at the right side of the ':'). @@ -319,13 +356,18 @@ BaseClass(3) BaseClass(3) {} {} < - +N Indent a continuation line (a line that spills onto the next) N - additional characters. (default 'shiftwidth'). + *cino-+* + +N Indent a continuation line (a line that spills onto the next) + inside a function N additional characters. (default + 'shiftwidth'). + Outside of a function, when the previous line ended in a + backslash, the 2 * N is used. cino= cino=+10 > a = b + 9 * a = b + 9 * c; c; < + *cino-c* cN Indent comment lines after the comment opener, when there is no other text with which to align, N characters from the comment opener. (default 3). See also |format-comments|. @@ -335,6 +377,7 @@ text. text. */ */ < + *cino-C* CN When N is non-zero, indent comment lines by the amount specified with the c flag above even if there is other text behind the comment opener. (default 0). @@ -345,12 +388,14 @@ ********/ ********/ < (Example uses ":set comments& comments-=s1:/* comments^=s0:/*") + *cino-/* /N Indent comment lines N characters extra. (default 0). cino= cino=/4 > a = b; a = b; /* comment */ /* comment */ c = d; c = d; < + *cino-(* (N When in unclosed parentheses, indent N characters from the line with the unclosed parentheses. Add a 'shiftwidth' for every unclosed parentheses. When N is 0 or the unclosed parentheses @@ -366,6 +411,7 @@ (c2 || c3)) (c2 || c3)) { { < + *cino-u* uN Same as (N, but for one level deeper. (default 'shiftwidth'). cino= cino=u2 > @@ -373,6 +419,7 @@ && (c22345 && (c22345 || c3)) || c3)) < + *cino-U* UN When N is non-zero, do not ignore the indenting specified by ( or u in case that the unclosed parentheses is the first non-white character in its line. (default 0). @@ -384,6 +431,7 @@ c3 c3 ) && c4; ) && c4; < + *cino-2* wN When in unclosed parentheses and N is non-zero and either using "(0" or "u0", respectively, or using "U0" and the unclosed parentheses is the first non-white character in its line, line @@ -396,6 +444,7 @@ || c3)) || c3)) foo; foo; < + *cino-W* WN When in unclosed parentheses and N is non-zero and either using "(0" or "u0", respectively and the unclosed parentheses is the last non-white character in its line and it is not the @@ -410,6 +459,23 @@ a_short_line(argument, a_short_line(argument, argument); argument); < + *cino-k* + kN When in unclosed parentheses which follow "if", "for" or + "while" and N is non-zero, overrides the behaviour defined by + "(N": causes the indent to be N characters relative to the outer + context (i.e. the line where "if", "for" or "while" is). Has + no effect on deeper levels of nesting. Affects flags like "wN" + only for the "if", "for" and "while" conditions. If 0, defaults + to behaviour defined by the "(N" flag. (default: 0). + + cino=(0 cino=(0,ks > + if (condition1 if (condition1 + && condition2) && condition2) + action(); action(); + function(argument1 function(argument1 + && argument2); && argument2); +< + *cino-m* mN When N is non-zero, line up a line starting with a closing parentheses with the first character of the line with the matching opening parentheses. (default 0). @@ -424,6 +490,7 @@ ) ) foo; foo; < + *cino-M* MN When N is non-zero, line up a line starting with a closing parentheses with the first character of the previous line. (default 0). @@ -433,7 +500,7 @@ cond2 cond2 ) ) < - *java-cinoptions* *java-indenting* + *java-cinoptions* *java-indenting* *cino-j* jN Indent java anonymous classes correctly. The value 'N' is currently unused but must be non-zero (e.g. 'j1'). 'j1' will indent for example the following code snippet correctly: > @@ -444,7 +511,7 @@ } }); < - *javascript-cinoptions* *javascript-indenting* + *javascript-cinoptions* *javascript-indenting* *cino-J* JN Indent JavaScript object declarations correctly by not confusing them with labels. The value 'N' is currently unused but must be non-zero (e.g. 'J1'). > @@ -462,23 +529,28 @@ } } < + *cino-)* )N Vim searches for unclosed parentheses at most N lines away. This limits the time needed to search for parentheses. (default 20 lines). + *cino-star* *N Vim searches for unclosed comments at most N lines away. This limits the time needed to search for the start of a comment. + If your /* */ comments stop indenting afer N lines this is the + value you will want to change. (default 70 lines). + *cino-#* #N When N is non-zero recognize shell/Perl comments, starting with - '#'. Default N is zero: don't recognizes '#' comments. Note + '#'. Default N is zero: don't recognize '#' comments. Note that lines starting with # will still be seen as preprocessor lines. The defaults, spelled out in full, are: - cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,ps,ts,is,+s, - c3,C0,/0,(2s,us,U0,w0,W0,m0,j0,J0,)20,*70,#0 + cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,ps,ts,is,+s, + c3,C0,/0,(2s,us,U0,w0,W0,k0,m0,j0,J0,)20,*70,#0 Vim puts a line in column 1 if: - It starts with '#' (preprocessor directives), if 'cinkeys' contains '#'. diff -Naur vim73.orig/runtime/doc/indent.txt.orig vim73.patched/runtime/doc/indent.txt.orig --- vim73.orig/runtime/doc/indent.txt.orig 1969-12-31 18:00:00.000000000 -0600 +++ vim73.patched/runtime/doc/indent.txt.orig 2010-08-15 07:23:20.000000000 -0500 @@ -0,0 +1,811 @@ +*indent.txt* For Vim version 7.3. Last change: 2010 Jul 30 + + + VIM REFERENCE MANUAL by Bram Moolenaar + + +This file is about indenting C programs and other files. + +1. Indenting C style programs |C-indenting| +2. Indenting by expression |indent-expression| + +============================================================================== +1. Indenting C style programs *C-indenting* + +The basics for C style indenting are explained in section |30.2| of the user +manual. + +Vim has options for automatically indenting C style program files. Many +programming languages including Java and C++ follow very closely the +formatting conventions established with C. These options affect only the +indent and do not perform other formatting. There are additional options that +affect other kinds of formatting as well as indenting, see |format-comments|, +|fo-table|, |gq| and |formatting| for the main ones. + +Note that this will not work when the |+smartindent| or |+cindent| features +have been disabled at compile time. + +There are in fact four main methods available for indentation, each one +overrides the previous if it is enabled, or non-empty for 'indentexpr': +'autoindent' uses the indent from the previous line. +'smartindent' is like 'autoindent' but also recognizes some C syntax to + increase/reduce the indent where appropriate. +'cindent' Works more cleverly than the other two and is configurable to + different indenting styles. +'indentexpr' The most flexible of all: Evaluates an expression to compute + the indent of a line. When non-empty this method overrides + the other ones. See |indent-expression|. +The rest of this section describes the 'cindent' option. + +Note that 'cindent' indenting does not work for every code scenario. Vim +is not a C compiler: it does not recognize all syntax. One requirement is +that toplevel functions have a '{' in the first column. Otherwise they are +easily confused with declarations. + +These four options control C program indenting: +'cindent' Enables Vim to perform C program indenting automatically. +'cinkeys' Specifies which keys trigger reindenting in insert mode. +'cinoptions' Sets your preferred indent style. +'cinwords' Defines keywords that start an extra indent in the next line. + +If 'lisp' is not on and 'equalprg' is empty, the "=" operator indents using +Vim's built-in algorithm rather than calling an external program. + +See |autocommand| for how to set the 'cindent' option automatically for C code +files and reset it for others. + + *cinkeys-format* *indentkeys-format* +The 'cinkeys' option is a string that controls Vim's indenting in response to +typing certain characters or commands in certain contexts. Note that this not +only triggers C-indenting. When 'indentexpr' is not empty 'indentkeys' is +used instead. The format of 'cinkeys' and 'indentkeys' is equal. + +The default is "0{,0},0),:,0#,!^F,o,O,e" which specifies that indenting occurs +as follows: + + "0{" if you type '{' as the first character in a line + "0}" if you type '}' as the first character in a line + "0)" if you type ')' as the first character in a line + ":" if you type ':' after a label or case statement + "0#" if you type '#' as the first character in a line + "!^F" if you type CTRL-F (which is not inserted) + "o" if you type a anywhere or use the "o" command (not in + insert mode!) + "O" if you use the "O" command (not in insert mode!) + "e" if you type the second 'e' for an "else" at the start of a + line + +Characters that can precede each key: *i_CTRL-F* +! When a '!' precedes the key, Vim will not insert the key but will + instead reindent the current line. This allows you to define a + command key for reindenting the current line. CTRL-F is the default + key for this. Be careful if you define CTRL-I for this because CTRL-I + is the ASCII code for . +* When a '*' precedes the key, Vim will reindent the line before + inserting the key. If 'cinkeys' contains "*", Vim reindents + the current line before opening a new line. +0 When a zero precedes the key (but appears after '!' or '*') Vim will + reindent the line only if the key is the first character you type in + the line. When used before "=" Vim will only reindent the line if + there is only white space before the word. + +When neither '!' nor '*' precedes the key, Vim reindents the line after you +type the key. So ';' sets the indentation of a line which includes the ';'. + +Special key names: +<> Angle brackets mean spelled-out names of keys. For example: "", + "" (see |key-notation|). +^ Letters preceded by a caret (^) are control characters. For example: + "^F" is CTRL-F. +o Reindent a line when you use the "o" command or when Vim opens a new + line below the current one (e.g., when you type in insert + mode). +O Reindent a line when you use the "O" command. +e Reindent a line that starts with "else" when you type the second 'e'. +: Reindent a line when a ':' is typed which is after a label or case + statement. Don't reindent for a ":" in "class::method" for C++. To + Reindent for any ":", use "<:>". +=word Reindent when typing the last character of "word". "word" may + actually be part of another word. Thus "=end" would cause reindenting + when typing the "d" in "endif" or "endwhile". But not when typing + "bend". Also reindent when completion produces a word that starts + with "word". "0=word" reindents when there is only white space before + the word. +=~word Like =word, but ignore case. + +If you really want to reindent when you type 'o', 'O', 'e', '0', '<', '>', +'*', ':' or '!', use "", "", "", "<0>", "<<>", "<>>", "<*>", "<:>" or +"", respectively, for those keys. + +For an emacs-style indent mode where lines aren't indented every time you +press but only if you press , I suggest: + :set cinkeys=0{,0},:,0#,!,!^F +You might also want to switch off 'autoindent' then. + +Note: If you change the current line's indentation manually, Vim ignores the +cindent settings for that line. This prevents vim from reindenting after you +have changed the indent by typing , , or in the indent or +used CTRL-T or CTRL-D. + + *cinoptions-values* +The 'cinoptions' option sets how Vim performs indentation. In the list below, +"N" represents a number of your choice (the number can be negative). When +there is an 's' after the number, Vim multiplies the number by 'shiftwidth': +"1s" is 'shiftwidth', "2s" is two times 'shiftwidth', etc. You can use a +decimal point, too: "-0.5s" is minus half a 'shiftwidth'. The examples below +assume a 'shiftwidth' of 4. + + >N Amount added for "normal" indent. Used after a line that should + increase the indent (lines starting with "if", an opening brace, + etc.). (default 'shiftwidth'). + + cino= cino=>2 cino=>2s > + if (cond) if (cond) if (cond) + { { { + foo; foo; foo; + } } } +< + eN Add N to the prevailing indent inside a set of braces if the + opening brace at the End of the line (more precise: is not the + first character in a line). This is useful if you want a + different indent when the '{' is at the start of the line from + when '{' is at the end of the line. (default 0). + + cino= cino=e2 cino=e-2 > + if (cond) { if (cond) { if (cond) { + foo; foo; foo; + } } } + else else else + { { { + bar; bar; bar; + } } } +< + nN Add N to the prevailing indent for a statement after an "if", + "while", etc., if it is NOT inside a set of braces. This is + useful if you want a different indent when there is no '{' + before the statement from when there is a '{' before it. + (default 0). + + cino= cino=n2 cino=n-2 > + if (cond) if (cond) if (cond) + foo; foo; foo; + else else else + { { { + bar; bar; bar; + } } } +< + fN Place the first opening brace of a function or other block in + column N. This applies only for an opening brace that is not + inside other braces and is at the start of the line. What comes + after the brace is put relative to this brace. (default 0). + + cino= cino=f.5s cino=f1s > + func() func() func() + { { { + int foo; int foo; int foo; +< + {N Place opening braces N characters from the prevailing indent. + This applies only for opening braces that are inside other + braces. (default 0). + + cino= cino={.5s cino={1s > + if (cond) if (cond) if (cond) + { { { + foo; foo; foo; +< + }N Place closing braces N characters from the matching opening + brace. (default 0). + + cino= cino={2,}-0.5s cino=}2 > + if (cond) if (cond) if (cond) + { { { + foo; foo; foo; + } } } +< + ^N Add N to the prevailing indent inside a set of braces if the + opening brace is in column 0. This can specify a different + indent for whole of a function (some may like to set it to a + negative number). (default 0). + + cino= cino=^-2 cino=^-s > + func() func() func() + { { { + if (cond) if (cond) if (cond) + { { { + a = b; a = b; a = b; + } } } + } } } +< + LN Controls placement of jump labels. If N is negative, the label + will be placed at column 1. If N is non-negative, the indent of + the label will be the prevailing indent minus N. (default -1). + + cino= cino=L2 cino=Ls > + func() func() func() + { { { + { { { + stmt; stmt; stmt; + LABEL: LABEL: LABEL: + } } } + } } } +< + :N Place case labels N characters from the indent of the switch(). + (default 'shiftwidth'). + + cino= cino=:0 > + switch (x) switch(x) + { { + case 1: case 1: + a = b; a = b; + default: default: + } } +< + =N Place statements occurring after a case label N characters from + the indent of the label. (default 'shiftwidth'). + + cino= cino==10 > + case 11: case 11: a = a + 1; + a = a + 1; b = b + 1; +< + lN If N != 0 Vim will align with a case label instead of the + statement after it in the same line. + + cino= cino=l1 > + switch (a) { switch (a) { + case 1: { case 1: { + break; break; + } } +< + bN If N != 0 Vim will align a final "break" with the case label, + so that case..break looks like a sort of block. (default: 0). + + cino= cino=b1 > + switch (x) switch(x) + { { + case 1: case 1: + a = b; a = b; + break; break; + + default: default: + a = 0; a = 0; + break; break; + } } +< + gN Place C++ scope declarations N characters from the indent of the + block they are in. (default 'shiftwidth'). A scope declaration + can be "public:", "protected:" or "private:". + + cino= cino=g0 > + { { + public: public: + a = b; a = b; + private: private: + } } +< + hN Place statements occurring after a C++ scope declaration N + characters from the indent of the label. (default + 'shiftwidth'). + + cino= cino=h10 > + public: public: a = a + 1; + a = a + 1; b = b + 1; +< + pN Parameter declarations for K&R-style function declarations will + be indented N characters from the margin. (default + 'shiftwidth'). + + cino= cino=p0 cino=p2s > + func(a, b) func(a, b) func(a, b) + int a; int a; int a; + char b; char b; char b; +< + tN Indent a function return type declaration N characters from the + margin. (default 'shiftwidth'). + + cino= cino=t0 cino=t7 > + int int int + func() func() func() +< + iN Indent C++ base class declarations and constructor + initializations, if they start in a new line (otherwise they + are aligned at the right side of the ':'). + (default 'shiftwidth'). + + cino= cino=i0 > + class MyClass : class MyClass : + public BaseClass public BaseClass + {} {} + MyClass::MyClass() : MyClass::MyClass() : + BaseClass(3) BaseClass(3) + {} {} +< + +N Indent a continuation line (a line that spills onto the next) N + additional characters. (default 'shiftwidth'). + + cino= cino=+10 > + a = b + 9 * a = b + 9 * + c; c; +< + cN Indent comment lines after the comment opener, when there is no + other text with which to align, N characters from the comment + opener. (default 3). See also |format-comments|. + + cino= cino=c5 > + /* /* + text. text. + */ */ +< + CN When N is non-zero, indent comment lines by the amount specified + with the c flag above even if there is other text behind the + comment opener. (default 0). + + cino=c0 cino=c0,C1 > + /******** /******** + text. text. + ********/ ********/ +< (Example uses ":set comments& comments-=s1:/* comments^=s0:/*") + + /N Indent comment lines N characters extra. (default 0). + cino= cino=/4 > + a = b; a = b; + /* comment */ /* comment */ + c = d; c = d; +< + (N When in unclosed parentheses, indent N characters from the line + with the unclosed parentheses. Add a 'shiftwidth' for every + unclosed parentheses. When N is 0 or the unclosed parentheses + is the first non-white character in its line, line up with the + next non-white character after the unclosed parentheses. + (default 'shiftwidth' * 2). + + cino= cino=(0 > + if (c1 && (c2 || if (c1 && (c2 || + c3)) c3)) + foo; foo; + if (c1 && if (c1 && + (c2 || c3)) (c2 || c3)) + { { +< + uN Same as (N, but for one level deeper. (default 'shiftwidth'). + + cino= cino=u2 > + if (c123456789 if (c123456789 + && (c22345 && (c22345 + || c3)) || c3)) +< + UN When N is non-zero, do not ignore the indenting specified by + ( or u in case that the unclosed parentheses is the first + non-white character in its line. (default 0). + + cino= or cino=(s cino=(s,U1 > + c = c1 && c = c1 && + ( ( + c2 || c2 || + c3 c3 + ) && c4; ) && c4; +< + wN When in unclosed parentheses and N is non-zero and either + using "(0" or "u0", respectively, or using "U0" and the unclosed + parentheses is the first non-white character in its line, line + up with the character immediately after the unclosed parentheses + rather than the first non-white character. (default 0). + + cino=(0 cino=(0,w1 > + if ( c1 if ( c1 + && ( c2 && ( c2 + || c3)) || c3)) + foo; foo; +< + WN When in unclosed parentheses and N is non-zero and either + using "(0" or "u0", respectively and the unclosed parentheses is + the last non-white character in its line and it is not the + closing parentheses, indent the following line N characters + relative to the outer context (i.e. start of the line or the + next unclosed parentheses). (default: 0). + + cino=(0 cino=(0,W4 > + a_long_line( a_long_line( + argument, argument, + argument); argument); + a_short_line(argument, a_short_line(argument, + argument); argument); +< + mN When N is non-zero, line up a line starting with a closing + parentheses with the first character of the line with the + matching opening parentheses. (default 0). + + cino=(s cino=(s,m1 > + c = c1 && ( c = c1 && ( + c2 || c2 || + c3 c3 + ) && c4; ) && c4; + if ( if ( + c1 && c2 c1 && c2 + ) ) + foo; foo; +< + MN When N is non-zero, line up a line starting with a closing + parentheses with the first character of the previous line. + (default 0). + + cino= cino=M1 > + if (cond1 && if (cond1 && + cond2 cond2 + ) ) +< + *java-cinoptions* *java-indenting* + jN Indent java anonymous classes correctly. The value 'N' is + currently unused but must be non-zero (e.g. 'j1'). 'j1' will + indent for example the following code snippet correctly: > + + object.add(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + do_something(); + } + }); +< + *javascript-cinoptions* *javascript-indenting* + JN Indent JavaScript object declarations correctly by not confusing + them with labels. The value 'N' is currently unused but must be + non-zero (e.g. 'J1'). > + + var bar = { + foo: { + that: this, + some: ok, + }, + "bar":{ + a : 2, + b: "123abc", + x: 4, + "y": 5 + } + } +< + )N Vim searches for unclosed parentheses at most N lines away. + This limits the time needed to search for parentheses. (default + 20 lines). + + *N Vim searches for unclosed comments at most N lines away. This + limits the time needed to search for the start of a comment. + (default 70 lines). + + #N When N is non-zero recognize shell/Perl comments, starting with + '#'. Default N is zero: don't recognizes '#' comments. Note + that lines starting with # will still be seen as preprocessor + lines. + + +The defaults, spelled out in full, are: + cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,ps,ts,is,+s, + c3,C0,/0,(2s,us,U0,w0,W0,m0,j0,J0,)20,*70,#0 + +Vim puts a line in column 1 if: +- It starts with '#' (preprocessor directives), if 'cinkeys' contains '#'. +- It starts with a label (a keyword followed by ':', other than "case" and + "default") and 'cinoptions' does not contain an 'L' entry with a positive + value. +- Any combination of indentations causes the line to have less than 0 + indentation. + +============================================================================== +2. Indenting by expression *indent-expression* + +The basics for using flexible indenting are explained in section |30.3| of the +user manual. + +If you want to write your own indent file, it must set the 'indentexpr' +option. Setting the 'indentkeys' option is often useful. See the +$VIMRUNTIME/indent directory for examples. + + +REMARKS ABOUT SPECIFIC INDENT FILES ~ + + +FORTRAN *ft-fortran-indent* + +Block if, select case, and where constructs are indented. Comments, labelled +statements and continuation lines are indented if the Fortran is in free +source form, whereas they are not indented if the Fortran is in fixed source +form because of the left margin requirements. Hence manual indent corrections +will be necessary for labelled statements and continuation lines when fixed +source form is being used. For further discussion of the method used for the +detection of source format see |ft-fortran-syntax|. + +Do loops ~ +All do loops are left unindented by default. Do loops can be unstructured in +Fortran with (possibly multiple) loops ending on a labelled executable +statement of almost arbitrary type. Correct indentation requires +compiler-quality parsing. Old code with do loops ending on labelled statements +of arbitrary type can be indented with elaborate programs such as Tidy +(http://www.unb.ca/chem/ajit/f_tidy.htm). Structured do/continue loops are +also left unindented because continue statements are also used for purposes +other than ending a do loop. Programs such as Tidy can convert structured +do/continue loops to the do/enddo form. Do loops of the do/enddo variety can +be indented. If you use only structured loops of the do/enddo form, you should +declare this by setting the fortran_do_enddo variable in your .vimrc as +follows > + + let fortran_do_enddo=1 + +in which case do loops will be indented. If all your loops are of do/enddo +type only in, say, .f90 files, then you should set a buffer flag with an +autocommand such as > + + au! BufRead,BufNewFile *.f90 let b:fortran_do_enddo=1 + +to get do loops indented in .f90 files and left alone in Fortran files with +other extensions such as .for. + + +PHP *ft-php-indent* *php-indent* *php-indenting* + +NOTE: PHP files will be indented correctly only if PHP |syntax| is active. + +If you are editing a file in Unix 'fileformat' and '\r' characters are present +before new lines, indentation won't proceed correctly ; you have to remove +those useless characters first with a command like: > + + :%s /\r$//g + +Or, you can simply |:let| the variable PHP_removeCRwhenUnix to 1 and the +script will silently remove them when Vim loads a PHP file (at each|BufRead|). + +OPTIONS: ~ + +PHP indenting can be altered in several ways by modifying the values of some +variables: + + *php-comment* +To not enable auto-formating of comments by default (if you want to use your +own 'formatoptions'): > + :let g:PHP_autoformatcomment = 0 + +Else, 't' will be removed from the 'formatoptions' string and "qrowcb" will be +added, see|fo-table|for more information. +------------- + +To add an extra indent to every PHP lines with N being the number of +'shiftwidth' to add: > + :let g:PHP_default_indenting = N + +For example, with N = 1, this will give: +> + +(Notice the extra indent between the PHP container markers and the code) +------------- + +To indent PHP tags as the surrounding code: > + :let g:PHP_outdentphpescape = 0 +------------- + +To automatically remove '\r' characters when the 'fileformat' is set to Unix: > + :let g:PHP_removeCRwhenUnix = 1 +------------- + +To indent braces at the same level than the code they contain: > + :let g:PHP_BracesAtCodeLevel = 1 + +This will give the following result: > + if ($foo) + { + foo(); + } +Instead of: > + if ($foo) + { + foo(); + } + +NOTE: Indenting will be a bit slower if this option is used because some + optimizations won't be available. +------------- + +To indent 'case:' and 'default:' statements in switch() blocks: > + :let g:PHP_vintage_case_default_indent = 1 + +(Since in PHP braces are not required inside 'case/default' blocks, by default they are indented at the same level than the 'switch()' to avoid +unnecessary indentation) + + +PYTHON *ft-python-indent* + +The amount of indent can be set for the following situations. The examples +given are the defaults. Note that the variables are set to an expression, so +that you can change the value of 'shiftwidth' later. + +Indent after an open paren: > + let g:pyindent_open_paren = '&sw * 2' +Indent after a nested paren: > + let g:pyindent_nested_paren = '&sw' +Indent for a continuation line: > + let g:pyindent_continue = '&sw * 2' + + +SHELL *ft-sh-indent* + +The amount of indent applied under various circumstances in a shell file can +be configured by setting the following keys in the |Dictionary| +b:sh_indent_defaults to a specific amount or to a |Funcref| that references a +function that will return the amount desired: + +b:sh_indent_options['default'] Default amount of indent. + +b:sh_indent_options['continuation-line'] + Amount of indent to add to a continued line. + +b:sh_indent_options['case-labels'] + Amount of indent to add for case labels. + (not actually implemented) + +b:sh_indent_options['case-statements'] + Amount of indent to add for case statements. + +b:sh_indent_options['case-breaks'] + Amount of indent to add (or more likely + remove) for case breaks. + +VERILOG *ft-verilog-indent* + +General block statements such as if, for, case, always, initial, function, +specify and begin, etc., are indented. The module block statements (first +level blocks) are not indented by default. you can turn on the indent with +setting a variable in the .vimrc as follows: > + + let b:verilog_indent_modules = 1 + +then the module blocks will be indented. To stop this, remove the variable: > + + :unlet b:verilog_indent_modules + +To set the variable only for Verilog file. The following statements can be +used: > + + au BufReadPost * if exists("b:current_syntax") + au BufReadPost * if b:current_syntax == "verilog" + au BufReadPost * let b:verilog_indent_modules = 1 + au BufReadPost * endif + au BufReadPost * endif + +Furthermore, setting the variable b:verilog_indent_width to change the +indenting width (default is 'shiftwidth'): > + + let b:verilog_indent_width = 4 + let b:verilog_indent_width = &sw * 2 + +In addition, you can turn the verbose mode for debug issue: > + + let b:verilog_indent_verbose = 1 + +Make sure to do ":set cmdheight=2" first to allow the display of the message. + + +VHDL *ft-vhdl-indent* + +Alignment of generic/port mapping statements are performed by default. This +causes the following alignment example: > + + ENTITY sync IS + PORT ( + clk : IN STD_LOGIC; + reset_n : IN STD_LOGIC; + data_input : IN STD_LOGIC; + data_out : OUT STD_LOGIC + ); + END ENTITY sync; + +To turn this off, add > + + let g:vhdl_indent_genportmap = 0 + +to the .vimrc file, which causes the previous alignment example to change: > + + ENTITY sync IS + PORT ( + clk : IN STD_LOGIC; + reset_n : IN STD_LOGIC; + data_input : IN STD_LOGIC; + data_out : OUT STD_LOGIC + ); + END ENTITY sync; + +---------------------------------------- + +Alignment of right-hand side assignment "<=" statements are performed by +default. This causes the following alignment example: > + + sig_out <= (bus_a(1) AND + (sig_b OR sig_c)) OR + (bus_a(0) AND sig_d); + +To turn this off, add > + + let g:vhdl_indent_rhsassign = 0 + +to the .vimrc file, which causes the previous alignment example to change: > + + sig_out <= (bus_a(1) AND + (sig_b OR sig_c)) OR + (bus_a(0) AND sig_d); + +---------------------------------------- + +Full-line comments (lines that begin with "--") are indented to be aligned with +the very previous line's comment, PROVIDED that a whitespace follows after +"--". + +For example: > + + sig_a <= sig_b; -- start of a comment + -- continuation of the comment + -- more of the same comment + +While in Insert mode, after typing "-- " (note the space " "), hitting CTRL-F +will align the current "-- " with the previous line's "--". + +If the very previous line does not contain "--", THEN the full-line comment +will be aligned with the start of the next non-blank line that is NOT a +full-line comment. + +Indenting the following code: > + + sig_c <= sig_d; -- comment 0 + -- comment 1 + -- comment 2 + --debug_code: + --PROCESS(debug_in) + --BEGIN + -- FOR i IN 15 DOWNTO 0 LOOP + -- debug_out(8*i+7 DOWNTO 8*i) <= debug_in(15-i); + -- END LOOP; + --END PROCESS debug_code; + + -- comment 3 + sig_e <= sig_f; -- comment 4 + -- comment 5 + +results in: > + + sig_c <= sig_d; -- comment 0 + -- comment 1 + -- comment 2 + --debug_code: + --PROCESS(debug_in) + --BEGIN + -- FOR i IN 15 DOWNTO 0 LOOP + -- debug_out(8*i+7 DOWNTO 8*i) <= debug_in(15-i); + -- END LOOP; + --END PROCESS debug_code; + + -- comment 3 + sig_e <= sig_f; -- comment 4 + -- comment 5 + +Notice that "--debug_code:" does not align with "-- comment 2" +because there is no whitespace that follows after "--" in "--debug_code:". + +Given the dynamic nature of indenting comments, indenting should be done TWICE. +On the first pass, code will be indented. On the second pass, full-line +comments will be indented according to the correctly indented code. + + +VIM *ft-vim-indent* + +For indenting Vim scripts there is one variable that specifies the amount of +indent for a continuation line, a line that starts with a backslash: > + + :let g:vim_indent_cont = &sw * 3 + +Three times shiftwidth is the default value. + + + vim:tw=78:ts=8:ft=help:norl: diff -Naur vim73.orig/runtime/doc/map.txt vim73.patched/runtime/doc/map.txt --- vim73.orig/runtime/doc/map.txt 2010-08-15 07:23:21.000000000 -0500 +++ vim73.patched/runtime/doc/map.txt 2012-05-20 12:55:43.000000000 -0500 @@ -226,7 +226,7 @@ For abbreviations |v:char| is set to the character that was typed to trigger the abbreviation. You can use this to decide how to expand the {lhs}. You -can't change v:char and you should not insert it. +you should not either insert or change the v:char. Be very careful about side effects! The expression is evaluated while obtaining characters, you may very well make the command dysfunctional. @@ -1202,20 +1202,28 @@ -complete=augroup autocmd groups -complete=buffer buffer names + -complete=behave :behave suboptions + -complete=color color schemes -complete=command Ex command (and arguments) + -complete=compiler compilers + -complete=cscope |:cscope| suboptions -complete=dir directory names -complete=environment environment variable names -complete=event autocommand events -complete=expression Vim expression -complete=file file and directory names + -complete=file_in_path file and directory names in |'path'| -complete=filetype filetype names |'filetype'| -complete=function function name -complete=help help subjects -complete=highlight highlight groups + -complete=history :history suboptions + -complete=locale locale names (as output of locale -a) -complete=mapping mapping name -complete=menu menus -complete=option options -complete=shellcmd Shell command + -complete=sign |:sign| suboptions -complete=syntax syntax file names |'syntax'| -complete=tag tags -complete=tag_listfiles tags, file names are shown when CTRL-D is hit diff -Naur vim73.orig/runtime/doc/motion.txt vim73.patched/runtime/doc/motion.txt --- vim73.orig/runtime/doc/motion.txt 2010-08-15 07:23:21.000000000 -0500 +++ vim73.patched/runtime/doc/motion.txt 2012-05-20 12:55:42.000000000 -0500 @@ -269,11 +269,11 @@ {char} can be entered like with the |f| command. *;* -; Repeat latest f, t, F or T [count] times. +; Repeat latest f, t, F or T [count] times. See |cpo-;| *,* , Repeat latest f, t, F or T in opposite direction - [count] times. + [count] times. See also |cpo-;| ============================================================================== 3. Up-down motions *up-down-motions* diff -Naur vim73.orig/runtime/doc/netbeans.txt vim73.patched/runtime/doc/netbeans.txt --- vim73.orig/runtime/doc/netbeans.txt 2010-08-15 07:23:21.000000000 -0500 +++ vim73.patched/runtime/doc/netbeans.txt 2012-05-20 12:55:42.000000000 -0500 @@ -1,4 +1,4 @@ -*netbeans.txt* For Vim version 7.3. Last change: 2010 Jul 20 +*netbeans.txt* For Vim version 7.3. Last change: 2011 Oct 20 VIM REFERENCE MANUAL by Gordon Prieur et al. @@ -118,7 +118,8 @@ uncommenting a line with "--disable-netbeans" in the Makefile. Currently the NetBeans interface is supported by Vim running in a terminal and -by GVim when it is run with one of the following GUIs: GTK, GNOME, and Motif. +by GVim when it is run with one of the following GUIs: GTK, GNOME, Windows, +Athena and Motif. If Motif support is required the user must supply XPM libraries. See |workshop-xpm| for details on obtaining the latest version of XPM. @@ -262,6 +263,12 @@ plain UTF-8 text this protocol could also be used with any other communication mechanism. +Netbeans messages are processed when Vim is idle, waiting for user input. +When Vim is run in non-interactive mode, for example when running an automated +test case that sources a Vim script, the idle loop may not be called often +enough. In that case, insert |sleep| commands in the Vim script. The |sleep| +command does invoke Netbeans messages processing. + 6.1 Kinds of messages |nb-messages| 6.2 Terms |nb-terms| 6.3 Commands |nb-commands| @@ -819,7 +826,7 @@ ============================================================================== 7. NetBeans commands *netbeans-commands* - *:nbstart* *E511* + *:nbstart* *E511* *E838* :nbs[tart] {connection} Start a new Netbeans session with {connection} as the socket connection parameters. The format of {connection} is described in |netbeans-parameters|. @@ -832,11 +839,16 @@ signs. *:nbkey* -:nb[key] {key} Pass the {key} to the Vim Controller for processing - -When a hot-key has been installed with the specialKeys command, this command -can be used to generate a hotkey messages to the Vim Controller. The events -newDotAndMark, keyCommand and keyAtPos are generated (in this order). +:nb[key] {key} Pass the {key} to the Vim Controller for processing. + When a hot-key has been installed with the specialKeys + command, this command can be used to generate a hotkey + message to the Vim Controller. + This command can also be used to pass any text to the + Vim Controller. It is used by Pyclewn, for example, + to build the complete set of gdb commands as Vim user + commands. + The events newDotAndMark, keyCommand and keyAtPos are + generated (in this order). ============================================================================== diff -Naur vim73.orig/runtime/doc/options.txt vim73.patched/runtime/doc/options.txt --- vim73.orig/runtime/doc/options.txt 2010-08-15 07:23:21.000000000 -0500 +++ vim73.patched/runtime/doc/options.txt 2012-05-20 12:55:43.000000000 -0500 @@ -150,6 +150,18 @@ (the ^[ is a real here, use CTRL-V to enter it) The advantage over a mapping is that it works in all situations. +You can define any key codes, e.g.: > + :set t_xy=^[foo; +There is no warning for using a name that isn't recognized. You can map these +codes as you like: > + :map something +< *E846* +When a key code is not set, it's like it does not exist. Trying to get its +value will result in an error: > + :set t_kb= + :set t_kb + E846: Key code not set: t_kb + The t_xx options cannot be set from a |modeline| or in the |sandbox|, for security reasons. @@ -1434,6 +1446,15 @@ explicitly accessed using the "* notation. Also see |gui-clipboard|. + unnamedplus A variant of "unnamed" flag which uses the clipboard + register '+' (|quoteplus|) instead of register '*' for + all operations except yank. Yank shall copy the text + into register '+' and also into '*' when "unnamed" is + included. + Only available with the |+x11| feature. + Availability can be checked with: > + if has('unnamedplus') +< autoselect Works like the 'a' flag in 'guioptions': If present, then whenever Visual mode is started, or the Visual area extended, Vim tries to become the owner of the @@ -2069,6 +2090,12 @@ *cpo->* > When appending to a register, put a line break before the appended text. + *cpo-;* + ; When using |,| or |;| to repeat the last |t| search + and the cursor is right in front of the searched + character, the cursor won't move. When not included, + the cursor would skip over it and jump to the + following occurence. POSIX flags. These are not included in the Vi default value, except when $VIM_POSIX was set on startup. |posix| @@ -2161,6 +2188,16 @@ Specifies whether to use quickfix window to show cscope results. See |cscopequickfix|. + *'cscoperelative'* *'csre'* +'cscoperelative' 'csre' boolean (default off) + global + {not available when compiled without the |+cscope| + feature} + {not in Vi} + In the absence of a prefix (-P) for cscope. setting this option enables + to use the basename of cscope.out path as the prefix. + See |cscoperelative|. + *'cscopetag'* *'cst'* *'nocscopetag'* *'nocst'* 'cscopetag' 'cst' boolean (default off) global @@ -5843,16 +5880,21 @@ security reasons. *'shellcmdflag'* *'shcf'* -'shellcmdflag' 'shcf' string (default: "-c", MS-DOS and Win32, when 'shell' - does not contain "sh" somewhere: "/c") +'shellcmdflag' 'shcf' string (default: "-c"; + Win32, when 'shell' is cmd.exe: "/s /c"; + MS-DOS and Win32, when 'shell' neither is + cmd.exe nor contains "sh" somewhere: "/c") global {not in Vi} Flag passed to the shell to execute "!" and ":!" commands; e.g., "bash.exe -c ls" or "command.com /c dir". For the MS-DOS-like systems, the default is set according to the value of 'shell', to reduce the need to set this option by the user. It's not used for - OS/2 (EMX figures this out itself). See |option-backslash| about - including spaces and backslashes. See |dos-shell|. + OS/2 (EMX figures this out itself). + On Unix it can have more than one flag. Each white space separated + part is passed as an argument to the shell command. + See |option-backslash| about including spaces and backslashes. + Also see |dos-shell| for MS-DOS and MS-Windows. This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. @@ -5873,9 +5915,10 @@ For Unix the default it "| tee". The stdout of the compiler is saved in a file and echoed to the screen. If the 'shell' option is "csh" or "tcsh" after initializations, the default becomes "|& tee". If the - 'shell' option is "sh", "ksh", "zsh" or "bash" the default becomes - "2>&1| tee". This means that stderr is also included. Before using - the 'shell' option a path is removed, thus "/bin/sh" uses "sh". + 'shell' option is "sh", "ksh", "mksh", "pdksh", "zsh" or "bash" the + default becomes "2>&1| tee". This means that stderr is also included. + Before using the 'shell' option a path is removed, thus "/bin/sh" uses + "sh". The initialization of this option is done after reading the ".vimrc" and the other initializations, so that when the 'shell' option is set there, the 'shellpipe' option changes automatically, unless it was @@ -5980,6 +6023,7 @@ *'shellxquote'* *'sxq'* 'shellxquote' 'sxq' string (default: ""; + for Win32, when 'shell' is cmd.exe: "(" for Win32, when 'shell' contains "sh" somewhere: "\"" for Unix, when using system(): "\"") @@ -5989,14 +6033,28 @@ the "!" and ":!" commands. Includes the redirection. See 'shellquote' to exclude the redirection. It's probably not useful to set both options. - This is an empty string by default. Known to be useful for - third-party shells when using the Win32 version, such as the MKS Korn - Shell or bash, where it should be "\"". The default is adjusted - according the value of 'shell', to reduce the need to set this option - by the user. See |dos-shell|. + When the value is '(' then ')' is appended. When the value is '"(' + then ')"' is appended. + When the value is '(' then also see 'shellxescape'. + This is an empty string by default on most systems, but is known to be + useful for on Win32 version, either for cmd.exe which automatically + strips off the first and last quote on a command, or 3rd-party shells + such as the MKS Korn Shell or bash, where it should be "\"". The + default is adjusted according the value of 'shell', to reduce the need + to set this option by the user. See |dos-shell|. This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. + *'shellxescape'* *'sxe'* +'shellxescape' 'sxe' string (default: ""; + for MS-DOS and MS-Windows: "\"&|<>()@^") + global + {not in Vi} + When 'shellxquote' is set to "(" then the characters listed in this + option will be escaped with a '^' character. This makes it possible + to execute most external commands with cmd.exe. + + *'shiftround'* *'sr'* *'noshiftround'* *'nosr'* 'shiftround' 'sr' boolean (default off) global @@ -7530,8 +7588,9 @@ ! When included, save and restore global variables that start with an uppercase letter, and don't contain a lowercase letter. Thus "KEEPTHIS and "K_L_M" are stored, but "KeepThis" - and "_K_L_M" are not. Only String and Number types are - stored. + and "_K_L_M" are not. Nested List and Dict items may not be + read back correctly, you end up with a string representation + instead. " Maximum number of lines saved for each register. Old name of the '<' item, with the disadvantage that you need to put a backslash before the ", otherwise it will be recognized as the @@ -7747,6 +7806,17 @@ a pattern from the list. This avoids problems when a future version uses another default. + + *'wildignorecase* *'wic'* *'nowildignorecase* *'nowic'* +'wildignorecase' 'wic' boolean (default off) + global + {not in Vi} + When set case is ignored when completing file names and directories. + Has no effect on systems where file name case is generally ignored. + Does not apply when the shell is used to expand wildcards, which + happens when there are special characters. + + *'wildmenu'* *'wmnu'* *'nowildmenu'* *'nowmnu'* 'wildmenu' 'wmnu' boolean (default off) global diff -Naur vim73.orig/runtime/doc/options.txt.orig vim73.patched/runtime/doc/options.txt.orig --- vim73.orig/runtime/doc/options.txt.orig 1969-12-31 18:00:00.000000000 -0600 +++ vim73.patched/runtime/doc/options.txt.orig 2012-05-20 12:55:41.000000000 -0500 @@ -0,0 +1,8079 @@ +*options.txt* For Vim version 7.3. Last change: 2010 Aug 15 + + + VIM REFERENCE MANUAL by Bram Moolenaar + + +Options *options* + +1. Setting options |set-option| +2. Automatically setting options |auto-setting| +3. Options summary |option-summary| + +For an overview of options see help.txt |option-list|. + +Vim has a number of internal variables and switches which can be set to +achieve special effects. These options come in three forms: + boolean can only be on or off *boolean* *toggle* + number has a numeric value + string has a string value + +============================================================================== +1. Setting options *set-option* *E764* + + *:se* *:set* +:se[t] Show all options that differ from their default value. + +:se[t] all Show all but terminal options. + +:se[t] termcap Show all terminal options. Note that in the GUI the + key codes are not shown, because they are generated + internally and can't be changed. Changing the terminal + codes in the GUI is not useful either... + + *E518* *E519* +:se[t] {option}? Show value of {option}. + +:se[t] {option} Toggle option: set, switch it on. + Number option: show value. + String option: show value. + +:se[t] no{option} Toggle option: Reset, switch it off. + + *:set-!* *:set-inv* +:se[t] {option}! or +:se[t] inv{option} Toggle option: Invert value. {not in Vi} + + *:set-default* *:set-&* *:set-&vi* *:set-&vim* +:se[t] {option}& Reset option to its default value. May depend on the + current value of 'compatible'. {not in Vi} +:se[t] {option}&vi Reset option to its Vi default value. {not in Vi} +:se[t] {option}&vim Reset option to its Vim default value. {not in Vi} + +:se[t] all& Set all options, except terminal options, to their + default value. The values of 'term', 'lines' and + 'columns' are not changed. {not in Vi} + + *:set-args* *E487* *E521* +:se[t] {option}={value} or +:se[t] {option}:{value} + Set string or number option to {value}. + For numeric options the value can be given in decimal, + hex (preceded with 0x) or octal (preceded with '0') + (hex and octal are only available for machines which + have the strtol() function). + The old value can be inserted by typing 'wildchar' (by + default this is a or CTRL-E if 'compatible' is + set). See |cmdline-completion|. + White space between {option} and '=' is allowed and + will be ignored. White space between '=' and {value} + is not allowed. + See |option-backslash| for using white space and + backslashes in {value}. + +:se[t] {option}+={value} *:set+=* + Add the {value} to a number option, or append the + {value} to a string option. When the option is a + comma separated list, a comma is added, unless the + value was empty. + If the option is a list of flags, superfluous flags + are removed. When adding a flag that was already + present the option value doesn't change. + Also see |:set-args| above. + {not in Vi} + +:se[t] {option}^={value} *:set^=* + Multiply the {value} to a number option, or prepend + the {value} to a string option. When the option is a + comma separated list, a comma is added, unless the + value was empty. + Also see |:set-args| above. + {not in Vi} + +:se[t] {option}-={value} *:set-=* + Subtract the {value} from a number option, or remove + the {value} from a string option, if it is there. + If the {value} is not found in a string option, there + is no error or warning. When the option is a comma + separated list, a comma is deleted, unless the option + becomes empty. + When the option is a list of flags, {value} must be + exactly as they appear in the option. Remove flags + one by one to avoid problems. + Also see |:set-args| above. + {not in Vi} + +The {option} arguments to ":set" may be repeated. For example: > + :set ai nosi sw=3 ts=3 +If you make an error in one of the arguments, an error message will be given +and the following arguments will be ignored. + + *:set-verbose* +When 'verbose' is non-zero, displaying an option value will also tell where it +was last set. Example: > + :verbose set shiftwidth cindent? +< shiftwidth=4 ~ + Last set from modeline ~ + cindent ~ + Last set from /usr/local/share/vim/vim60/ftplugin/c.vim ~ +This is only done when specific option values are requested, not for ":verbose +set all" or ":verbose set" without an argument. +When the option was set by hand there is no "Last set" message. +When the option was set while executing a function, user command or +autocommand, the script in which it was defined is reported. +Note that an option may also have been set as a side effect of setting +'compatible'. +A few special texts: + Last set from modeline ~ + Option was set in a |modeline|. + Last set from --cmd argument ~ + Option was set with command line argument |--cmd| or +. + Last set from -c argument ~ + Option was set with command line argument |-c|, +, |-S| or + |-q|. + Last set from environment variable ~ + Option was set from an environment variable, $VIMINIT, + $GVIMINIT or $EXINIT. + Last set from error handler ~ + Option was cleared when evaluating it resulted in an error. + +{not available when compiled without the |+eval| feature} + + *:set-termcap* *E522* +For {option} the form "t_xx" may be used to set a terminal option. This will +override the value from the termcap. You can then use it in a mapping. If +the "xx" part contains special characters, use the form: > + :set =^[Ot +This can also be used to translate a special code for a normal key. For +example, if Alt-b produces b, use this: > + :set =^[b +(the ^[ is a real here, use CTRL-V to enter it) +The advantage over a mapping is that it works in all situations. + +You can define any key codes, e.g.: > + :set t_xy=^[foo; +There is no warning for using a name that isn't recognized. You can map these +codes as you like: > + :map something +< *E846* +When a key code is not set, it's like it does not exist. Trying to get its +value will result in an error: > + :set t_kb= + :set t_kb + E846: Key code not set: t_kb + +The t_xx options cannot be set from a |modeline| or in the |sandbox|, for +security reasons. + +The listing from ":set" looks different from Vi. Long string options are put +at the end of the list. The number of options is quite large. The output of +"set all" probably does not fit on the screen, causing Vim to give the +|more-prompt|. + + *option-backslash* +To include white space in a string option value it has to be preceded with a +backslash. To include a backslash you have to use two. Effectively this +means that the number of backslashes in an option value is halved (rounded +down). +A few examples: > + :set tags=tags\ /usr/tags results in "tags /usr/tags" + :set tags=tags\\,file results in "tags\,file" + :set tags=tags\\\ file results in "tags\ file" + +The "|" character separates a ":set" command from a following command. To +include the "|" in the option value, use "\|" instead. This example sets the +'titlestring' option to "hi|there": > + :set titlestring=hi\|there +This sets the 'titlestring' option to "hi" and 'iconstring' to "there": > + :set titlestring=hi|set iconstring=there + +Similarly, the double quote character starts a comment. To include the '"' in +the option value, use '\"' instead. This example sets the 'titlestring' +option to 'hi "there"': > + :set titlestring=hi\ \"there\" + +For MS-DOS and WIN32 backslashes in file names are mostly not removed. More +precise: For options that expect a file name (those where environment +variables are expanded) a backslash before a normal file name character is not +removed. But a backslash before a special character (space, backslash, comma, +etc.) is used like explained above. +There is one special situation, when the value starts with "\\": > + :set dir=\\machine\path results in "\\machine\path" + :set dir=\\\\machine\\path results in "\\machine\path" + :set dir=\\path\\file results in "\\path\file" (wrong!) +For the first one the start is kept, but for the second one the backslashes +are halved. This makes sure it works both when you expect backslashes to be +halved and when you expect the backslashes to be kept. The third gives a +result which is probably not what you want. Avoid it. + + *add-option-flags* *remove-option-flags* + *E539* *E550* *E551* *E552* +Some options are a list of flags. When you want to add a flag to such an +option, without changing the existing ones, you can do it like this: > + :set guioptions+=a +Remove a flag from an option like this: > + :set guioptions-=a +This removes the 'a' flag from 'guioptions'. +Note that you should add or remove one flag at a time. If 'guioptions' has +the value "ab", using "set guioptions-=ba" won't work, because the string "ba" +doesn't appear. + + *:set_env* *expand-env* *expand-environment-var* +Environment variables in specific string options will be expanded. If the +environment variable exists the '$' and the following environment variable +name is replaced with its value. If it does not exist the '$' and the name +are not modified. Any non-id character (not a letter, digit or '_') may +follow the environment variable name. That character and what follows is +appended to the value of the environment variable. Examples: > + :set term=$TERM.new + :set path=/usr/$INCLUDE,$HOME/include,. +When adding or removing a string from an option with ":set opt-=val" or ":set +opt+=val" the expansion is done before the adding or removing. + + +Handling of local options *local-options* + +Some of the options only apply to a window or buffer. Each window or buffer +has its own copy of this option, thus can each have their own value. This +allows you to set 'list' in one window but not in another. And set +'shiftwidth' to 3 in one buffer and 4 in another. + +The following explains what happens to these local options in specific +situations. You don't really need to know all of this, since Vim mostly uses +the option values you would expect. Unfortunately, doing what the user +expects is a bit complicated... + +When splitting a window, the local options are copied to the new window. Thus +right after the split the contents of the two windows look the same. + +When editing a new buffer, its local option values must be initialized. Since +the local options of the current buffer might be specifically for that buffer, +these are not used. Instead, for each buffer-local option there also is a +global value, which is used for new buffers. With ":set" both the local and +global value is changed. With "setlocal" only the local value is changed, +thus this value is not used when editing a new buffer. + +When editing a buffer that has been edited before, the last used window +options are used again. If this buffer has been edited in this window, the +values from back then are used. Otherwise the values from the window where +the buffer was edited last are used. + +It's possible to set a local window option specifically for a type of buffer. +When you edit another buffer in the same window, you don't want to keep +using these local window options. Therefore Vim keeps a global value of the +local window options, which is used when editing another buffer. Each window +has its own copy of these values. Thus these are local to the window, but +global to all buffers in the window. With this you can do: > + :e one + :set list + :e two +Now the 'list' option will also be set in "two", since with the ":set list" +command you have also set the global value. > + :set nolist + :e one + :setlocal list + :e two +Now the 'list' option is not set, because ":set nolist" resets the global +value, ":setlocal list" only changes the local value and ":e two" gets the +global value. Note that if you do this next: > + :e one +You will not get back the 'list' value as it was the last time you edited +"one". The options local to a window are not remembered for each buffer. + + *:setl* *:setlocal* +:setl[ocal] ... Like ":set" but set only the value local to the + current buffer or window. Not all options have a + local value. If the option does not have a local + value the global value is set. + With the "all" argument: display local values for all + local options. + Without argument: Display local values for all local + options which are different from the default. + When displaying a specific local option, show the + local value. For a global/local boolean option, when + the global value is being used, "--" is displayed + before the option name. + For a global option the global value is + shown (but that might change in the future). + {not in Vi} + +:setl[ocal] {option}< Set the local value of {option} to its global value by + copying the value. + {not in Vi} + +:se[t] {option}< Set the local value of {option} to its global value by + making it empty. Only makes sense for |global-local| + options. + {not in Vi} + + *:setg* *:setglobal* +:setg[lobal] ... Like ":set" but set only the global value for a local + option without changing the local value. + When displaying an option, the global value is shown. + With the "all" argument: display global values for all + local options. + Without argument: display global values for all local + options which are different from the default. + {not in Vi} + +For buffer-local and window-local options: + Command global value local value ~ + :set option=value set set + :setlocal option=value - set +:setglobal option=value set - + :set option? - display + :setlocal option? - display +:setglobal option? display - + + +Global options with a local value *global-local* + +Options are global when you mostly use one value for all buffers and windows. +For some global options it's useful to sometimes have a different local value. +You can set the local value with ":setlocal". That buffer or window will then +use the local value, while other buffers and windows continue using the global +value. + +For example, you have two windows, both on C source code. They use the global +'makeprg' option. If you do this in one of the two windows: > + :set makeprg=gmake +then the other window will switch to the same value. There is no need to set +the 'makeprg' option in the other C source window too. +However, if you start editing a Perl file in a new window, you want to use +another 'makeprg' for it, without changing the value used for the C source +files. You use this command: > + :setlocal makeprg=perlmake +You can switch back to using the global value by making the local value empty: > + :setlocal makeprg= +This only works for a string option. For a boolean option you need to use the +"<" flag, like this: > + :setlocal autoread< +Note that for non-boolean options using "<" copies the global value to the +local value, it doesn't switch back to using the global value (that matters +when the global value changes later). You can also use: > + :set path< +This will make the local value of 'path' empty, so that the global value is +used. Thus it does the same as: > + :setlocal path= +Note: In the future more global options can be made global-local. Using +":setlocal" on a global option might work differently then. + + +Setting the filetype + +:setf[iletype] {filetype} *:setf* *:setfiletype* + Set the 'filetype' option to {filetype}, but only if + not done yet in a sequence of (nested) autocommands. + This is short for: > + :if !did_filetype() + : setlocal filetype={filetype} + :endif +< This command is used in a filetype.vim file to avoid + setting the 'filetype' option twice, causing different + settings and syntax files to be loaded. + {not in Vi} + +:bro[wse] se[t] *:set-browse* *:browse-set* *:opt* *:options* +:opt[ions] Open a window for viewing and setting all options. + Options are grouped by function. + Offers short help for each option. Hit on the + short help to open a help window with more help for + the option. + Modify the value of the option and hit on the + "set" line to set the new value. For window and + buffer specific options, the last accessed window is + used to set the option value in, unless this is a help + window, in which case the window below help window is + used (skipping the option-window). + {not available when compiled without the |+eval| or + |+autocmd| features} + + *$HOME* +Using "~" is like using "$HOME", but it is only recognized at the start of an +option and after a space or comma. + +On Unix systems "~user" can be used too. It is replaced by the home directory +of user "user". Example: > + :set path=~mool/include,/usr/include,. + +On Unix systems the form "${HOME}" can be used too. The name between {} can +contain non-id characters then. Note that if you want to use this for the +"gf" command, you need to add the '{' and '}' characters to 'isfname'. + +NOTE: expanding environment variables and "~/" is only done with the ":set" +command, not when assigning a value to an option with ":let". + + +Note the maximum length of an expanded option is limited. How much depends on +the system, mostly it is something like 256 or 1024 characters. + + *:fix* *:fixdel* +:fix[del] Set the value of 't_kD': + 't_kb' is 't_kD' becomes ~ + CTRL-? CTRL-H + not CTRL-? CTRL-? + + (CTRL-? is 0177 octal, 0x7f hex) {not in Vi} + + If your delete key terminal code is wrong, but the + code for backspace is alright, you can put this in + your .vimrc: > + :fixdel +< This works no matter what the actual code for + backspace is. + + If the backspace key terminal code is wrong you can + use this: > + :if &term == "termname" + : set t_kb=^V + : fixdel + :endif +< Where "^V" is CTRL-V and "" is the backspace key + (don't type four characters!). Replace "termname" + with your terminal name. + + If your key sends a strange key sequence (not + CTRL-? or CTRL-H) you cannot use ":fixdel". Then use: > + :if &term == "termname" + : set t_kD=^V + :endif +< Where "^V" is CTRL-V and "" is the delete key + (don't type eight characters!). Replace "termname" + with your terminal name. + + *Linux-backspace* + Note about Linux: By default the backspace key + produces CTRL-?, which is wrong. You can fix it by + putting this line in your rc.local: > + echo "keycode 14 = BackSpace" | loadkeys +< + *NetBSD-backspace* + Note about NetBSD: If your backspace doesn't produce + the right code, try this: > + xmodmap -e "keycode 22 = BackSpace" +< If this works, add this in your .Xmodmap file: > + keysym 22 = BackSpace +< You need to restart for this to take effect. + +============================================================================== +2. Automatically setting options *auto-setting* + +Besides changing options with the ":set" command, there are three alternatives +to set options automatically for one or more files: + +1. When starting Vim initializations are read from various places. See + |initialization|. Most of them are performed for all editing sessions, + and some of them depend on the directory where Vim is started. + You can create an initialization file with |:mkvimrc|, |:mkview| and + |:mksession|. +2. If you start editing a new file, the automatic commands are executed. + This can be used to set options for files matching a particular pattern and + many other things. See |autocommand|. +3. If you start editing a new file, and the 'modeline' option is on, a + number of lines at the beginning and end of the file are checked for + modelines. This is explained here. + + *modeline* *vim:* *vi:* *ex:* *E520* +There are two forms of modelines. The first form: + [text]{white}{vi:|vim:|ex:}[white]{options} + +[text] any text or empty +{white} at least one blank character ( or ) +{vi:|vim:|ex:} the string "vi:", "vim:" or "ex:" +[white] optional white space +{options} a list of option settings, separated with white space or ':', + where each part between ':' is the argument for a ":set" + command (can be empty) + +Example: + vi:noai:sw=3 ts=6 ~ + +The second form (this is compatible with some versions of Vi): + + [text]{white}{vi:|vim:|ex:}[white]se[t] {options}:[text] + +[text] any text or empty +{white} at least one blank character ( or ) +{vi:|vim:|ex:} the string "vi:", "vim:" or "ex:" +[white] optional white space +se[t] the string "set " or "se " (note the space) +{options} a list of options, separated with white space, which is the + argument for a ":set" command +: a colon +[text] any text or empty + +Example: + /* vim: set ai tw=75: */ ~ + +The white space before {vi:|vim:|ex:} is required. This minimizes the chance +that a normal word like "lex:" is caught. There is one exception: "vi:" and +"vim:" can also be at the start of the line (for compatibility with version +3.0). Using "ex:" at the start of the line will be ignored (this could be +short for "example:"). + + *modeline-local* +The options are set like with ":setlocal": The new value only applies to the +buffer and window that contain the file. Although it's possible to set global +options from a modeline, this is unusual. If you have two windows open and +the files in it set the same global option to a different value, the result +depends on which one was opened last. + +When editing a file that was already loaded, only the window-local options +from the modeline are used. Thus if you manually changed a buffer-local +option after opening the file, it won't be changed if you edit the same buffer +in another window. But window-local options will be set. + + *modeline-version* +If the modeline is only to be used for some versions of Vim, the version +number can be specified where "vim:" is used: + vim{vers}: version {vers} or later + vim<{vers}: version before {vers} + vim={vers}: version {vers} + vim>{vers}: version after {vers} +{vers} is 600 for Vim 6.0 (hundred times the major version plus minor). +For example, to use a modeline only for Vim 6.0 and later: + /* vim600: set foldmethod=marker: */ ~ +To use a modeline for Vim before version 5.7: + /* vim<570: set sw=4: */ ~ +There can be no blanks between "vim" and the ":". + + +The number of lines that are checked can be set with the 'modelines' option. +If 'modeline' is off or 'modelines' is 0 no lines are checked. + +Note that for the first form all of the rest of the line is used, thus a line +like: + /* vi:ts=4: */ ~ +will give an error message for the trailing "*/". This line is OK: + /* vi:set ts=4: */ ~ + +If an error is detected the rest of the line is skipped. + +If you want to include a ':' in a set command precede it with a '\'. The +backslash in front of the ':' will be removed. Example: + /* vi:set dir=c\:\tmp: */ ~ +This sets the 'dir' option to "c:\tmp". Only a single backslash before the +':' is removed. Thus to include "\:" you have to specify "\\:". + +No other commands than "set" are supported, for security reasons (somebody +might create a Trojan horse text file with modelines). And not all options +can be set. For some options a flag is set, so that when it's used the +|sandbox| is effective. Still, there is always a small risk that a modeline +causes trouble. E.g., when some joker sets 'textwidth' to 5 all your lines +are wrapped unexpectedly. So disable modelines before editing untrusted text. +The mail ftplugin does this, for example. + +Hint: If you would like to do something else than setting an option, you could +define an autocommand that checks the file for a specific string. For +example: > + au BufReadPost * if getline(1) =~ "VAR" | call SetVar() | endif +And define a function SetVar() that does something with the line containing +"VAR". + +============================================================================== +3. Options summary *option-summary* + +In the list below all the options are mentioned with their full name and with +an abbreviation if there is one. Both forms may be used. + +In this document when a boolean option is "set" that means that ":set option" +is entered. When an option is "reset", ":set nooption" is used. + +For some options there are two default values: The "Vim default", which is +used when 'compatible' is not set, and the "Vi default", which is used when +'compatible' is set. + +Most options are the same in all windows and buffers. There are a few that +are specific to how the text is presented in a window. These can be set to a +different value in each window. For example the 'list' option can be set in +one window and reset in another for the same text, giving both types of view +at the same time. There are a few options that are specific to a certain +file. These can have a different value for each file or buffer. For example +the 'textwidth' option can be 78 for a normal text file and 0 for a C +program. + + global one option for all buffers and windows + local to window each window has its own copy of this option + local to buffer each buffer has its own copy of this option + +When creating a new window the option values from the currently active window +are used as a default value for the window-specific options. For the +buffer-specific options this depends on the 's' and 'S' flags in the +'cpoptions' option. If 's' is included (which is the default) the values for +buffer options are copied from the currently active buffer when a buffer is +first entered. If 'S' is present the options are copied each time the buffer +is entered, this is almost like having global options. If 's' and 'S' are not +present, the options are copied from the currently active buffer when the +buffer is created. + +Hidden options *hidden-options* + +Not all options are supported in all versions. This depends on the supported +features and sometimes on the system. A remark about this is in curly braces +below. When an option is not supported it may still be set without getting an +error, this is called a hidden option. You can't get the value of a hidden +option though, it is not stored. + +To test if option "foo" can be used with ":set" use something like this: > + if exists('&foo') +This also returns true for a hidden option. To test if option "foo" is really +supported use something like this: > + if exists('+foo') +< + *E355* +A jump table for the options with a short description can be found at |Q_op|. + + *'aleph'* *'al'* *aleph* *Aleph* +'aleph' 'al' number (default 128 for MS-DOS, 224 otherwise) + global + {not in Vi} + {only available when compiled with the |+rightleft| + feature} + The ASCII code for the first letter of the Hebrew alphabet. The + routine that maps the keyboard in Hebrew mode, both in Insert mode + (when hkmap is set) and on the command-line (when hitting CTRL-_) + outputs the Hebrew characters in the range [aleph..aleph+26]. + aleph=128 applies to PC code, and aleph=224 applies to ISO 8859-8. + See |rileft.txt|. + + *'allowrevins'* *'ari'* *'noallowrevins'* *'noari'* +'allowrevins' 'ari' boolean (default off) + global + {not in Vi} + {only available when compiled with the |+rightleft| + feature} + Allow CTRL-_ in Insert and Command-line mode. This is default off, to + avoid that users that accidentally type CTRL-_ instead of SHIFT-_ get + into reverse Insert mode, and don't know how to get out. See + 'revins'. + NOTE: This option is reset when 'compatible' is set. + + *'altkeymap'* *'akm'* *'noaltkeymap'* *'noakm'* +'altkeymap' 'akm' boolean (default off) + global + {not in Vi} + {only available when compiled with the |+farsi| + feature} + When on, the second language is Farsi. In editing mode CTRL-_ toggles + the keyboard map between Farsi and English, when 'allowrevins' set. + + When off, the keyboard map toggles between Hebrew and English. This + is useful to start the Vim in native mode i.e. English (left-to-right + mode) and have default second language Farsi or Hebrew (right-to-left + mode). See |farsi.txt|. + + *'ambiwidth'* *'ambw'* +'ambiwidth' 'ambw' string (default: "single") + global + {not in Vi} + {only available when compiled with the |+multi_byte| + feature} + Only effective when 'encoding' is "utf-8" or another Unicode encoding. + Tells Vim what to do with characters with East Asian Width Class + Ambiguous (such as Euro, Registered Sign, Copyright Sign, Greek + letters, Cyrillic letters). + + There are currently two possible values: + "single": Use the same width as characters in US-ASCII. This is + expected by most users. + "double": Use twice the width of ASCII characters. + *E834* *E835* + The value "double" cannot be used if 'listchars' or 'fillchars' + contains a character that would be double width. + + There are a number of CJK fonts for which the width of glyphs for + those characters are solely based on how many octets they take in + legacy/traditional CJK encodings. In those encodings, Euro, + Registered sign, Greek/Cyrillic letters are represented by two octets, + therefore those fonts have "wide" glyphs for them. This is also + true of some line drawing characters used to make tables in text + file. Therefore, when a CJK font is used for GUI Vim or + Vim is running inside a terminal (emulators) that uses a CJK font + (or Vim is run inside an xterm invoked with "-cjkwidth" option.), + this option should be set to "double" to match the width perceived + by Vim with the width of glyphs in the font. Perhaps it also has + to be set to "double" under CJK Windows 9x/ME or Windows 2k/XP + when the system locale is set to one of CJK locales. See Unicode + Standard Annex #11 (http://www.unicode.org/reports/tr11). + + *'antialias'* *'anti'* *'noantialias'* *'noanti'* +'antialias' 'anti' boolean (default: off) + global + {not in Vi} + {only available when compiled with GUI enabled + on Mac OS X} + This option only has an effect in the GUI version of Vim on Mac OS X + v10.2 or later. When on, Vim will use smooth ("antialiased") fonts, + which can be easier to read at certain sizes on certain displays. + Setting this option can sometimes cause problems if 'guifont' is set + to its default (empty string). + + *'autochdir'* *'acd'* *'noautochdir'* *'noacd'* +'autochdir' 'acd' boolean (default off) + global + {not in Vi} + {only available when compiled with it, use + exists("+autochdir") to check} + When on, Vim will change the current working directory whenever you + open a file, switch buffers, delete a buffer or open/close a window. + It will change to the directory containing the file which was opened + or selected. + This option is provided for backward compatibility with the Vim + released with Sun ONE Studio 4 Enterprise Edition. + Note: When this option is on some plugins may not work. + + *'arabic'* *'arab'* *'noarabic'* *'noarab'* +'arabic' 'arab' boolean (default off) + local to window + {not in Vi} + {only available when compiled with the |+arabic| + feature} + This option can be set to start editing Arabic text. + Setting this option will: + - Set the 'rightleft' option, unless 'termbidi' is set. + - Set the 'arabicshape' option, unless 'termbidi' is set. + - Set the 'keymap' option to "arabic"; in Insert mode CTRL-^ toggles + between typing English and Arabic key mapping. + - Set the 'delcombine' option + Note that 'encoding' must be "utf-8" for working with Arabic text. + + Resetting this option will: + - Reset the 'rightleft' option. + - Disable the use of 'keymap' (without changing its value). + Note that 'arabicshape' and 'delcombine' are not reset (it is a global + option. + Also see |arabic.txt|. + + *'arabicshape'* *'arshape'* + *'noarabicshape'* *'noarshape'* +'arabicshape' 'arshape' boolean (default on) + global + {not in Vi} + {only available when compiled with the |+arabic| + feature} + When on and 'termbidi' is off, the required visual character + corrections that need to take place for displaying the Arabic language + take affect. Shaping, in essence, gets enabled; the term is a broad + one which encompasses: + a) the changing/morphing of characters based on their location + within a word (initial, medial, final and stand-alone). + b) the enabling of the ability to compose characters + c) the enabling of the required combining of some characters + When disabled the display shows each character's true stand-alone + form. + Arabic is a complex language which requires other settings, for + further details see |arabic.txt|. + + *'autoindent'* *'ai'* *'noautoindent'* *'noai'* +'autoindent' 'ai' boolean (default off) + local to buffer + Copy indent from current line when starting a new line (typing + in Insert mode or when using the "o" or "O" command). If you do not + type anything on the new line except or CTRL-D and then type + , CTRL-O or , the indent is deleted again. Moving the cursor + to another line has the same effect, unless the 'I' flag is included + in 'cpoptions'. + When autoindent is on, formatting (with the "gq" command or when you + reach 'textwidth' in Insert mode) uses the indentation of the first + line. + When 'smartindent' or 'cindent' is on the indent is changed in + a different way. + The 'autoindent' option is reset when the 'paste' option is set. + {small difference from Vi: After the indent is deleted when typing + or , the cursor position when moving up or down is after the + deleted indent; Vi puts the cursor somewhere in the deleted indent}. + + *'autoread'* *'ar'* *'noautoread'* *'noar'* +'autoread' 'ar' boolean (default off) + global or local to buffer |global-local| + {not in Vi} + When a file has been detected to have been changed outside of Vim and + it has not been changed inside of Vim, automatically read it again. + When the file has been deleted this is not done. |timestamp| + If this option has a local value, use this command to switch back to + using the global value: > + :set autoread< +< + *'autowrite'* *'aw'* *'noautowrite'* *'noaw'* +'autowrite' 'aw' boolean (default off) + global + Write the contents of the file, if it has been modified, on each + :next, :rewind, :last, :first, :previous, :stop, :suspend, :tag, :!, + :make, CTRL-] and CTRL-^ command; and when a :buffer, CTRL-O, CTRL-I, + '{A-Z0-9}, or `{A-Z0-9} command takes one to another file. + Note that for some commands the 'autowrite' option is not used, see + 'autowriteall' for that. + + *'autowriteall'* *'awa'* *'noautowriteall'* *'noawa'* +'autowriteall' 'awa' boolean (default off) + global + {not in Vi} + Like 'autowrite', but also used for commands ":edit", ":enew", ":quit", + ":qall", ":exit", ":xit", ":recover" and closing the Vim window. + Setting this option also implies that Vim behaves like 'autowrite' has + been set. + + *'background'* *'bg'* +'background' 'bg' string (default "dark" or "light") + global + {not in Vi} + When set to "dark", Vim will try to use colors that look good on a + dark background. When set to "light", Vim will try to use colors that + look good on a light background. Any other value is illegal. + Vim tries to set the default value according to the terminal used. + This will not always be correct. + Setting this option does not change the background color, it tells Vim + what the background color looks like. For changing the background + color, see |:hi-normal|. + + When 'background' is set Vim will adjust the default color groups for + the new value. But the colors used for syntax highlighting will not + change. *g:colors_name* + When a color scheme is loaded (the "g:colors_name" variable is set) + setting 'background' will cause the color scheme to be reloaded. If + the color scheme adjusts to the value of 'background' this will work. + However, if the color scheme sets 'background' itself the effect may + be undone. First delete the "g:colors_name" variable when needed. + + When setting 'background' to the default value with: > + :set background& +< Vim will guess the value. In the GUI this should work correctly, + in other cases Vim might not be able to guess the right value. + + When starting the GUI, the default value for 'background' will be + "light". When the value is not set in the .gvimrc, and Vim detects + that the background is actually quite dark, 'background' is set to + "dark". But this happens only AFTER the .gvimrc file has been read + (because the window needs to be opened to find the actual background + color). To get around this, force the GUI window to be opened by + putting a ":gui" command in the .gvimrc file, before where the value + of 'background' is used (e.g., before ":syntax on"). + Normally this option would be set in the .vimrc file. Possibly + depending on the terminal name. Example: > + :if &term == "pcterm" + : set background=dark + :endif +< When this option is set, the default settings for the highlight groups + will change. To use other settings, place ":highlight" commands AFTER + the setting of the 'background' option. + This option is also used in the "$VIMRUNTIME/syntax/syntax.vim" file + to select the colors for syntax highlighting. After changing this + option, you must load syntax.vim again to see the result. This can be + done with ":syntax on". + + *'backspace'* *'bs'* +'backspace' 'bs' string (default "") + global + {not in Vi} + Influences the working of , , CTRL-W and CTRL-U in Insert + mode. This is a list of items, separated by commas. Each item allows + a way to backspace over something: + value effect ~ + indent allow backspacing over autoindent + eol allow backspacing over line breaks (join lines) + start allow backspacing over the start of insert; CTRL-W and CTRL-U + stop once at the start of insert. + + When the value is empty, Vi compatible backspacing is used. + + For backwards compatibility with version 5.4 and earlier: + value effect ~ + 0 same as ":set backspace=" (Vi compatible) + 1 same as ":set backspace=indent,eol" + 2 same as ":set backspace=indent,eol,start" + + See |:fixdel| if your or key does not do what you want. + NOTE: This option is set to "" when 'compatible' is set. + + *'backup'* *'bk'* *'nobackup'* *'nobk'* +'backup' 'bk' boolean (default off) + global + {not in Vi} + Make a backup before overwriting a file. Leave it around after the + file has been successfully written. If you do not want to keep the + backup file, but you do want a backup while the file is being + written, reset this option and set the 'writebackup' option (this is + the default). If you do not want a backup file at all reset both + options (use this if your file system is almost full). See the + |backup-table| for more explanations. + When the 'backupskip' pattern matches, a backup is not made anyway. + When 'patchmode' is set, the backup may be renamed to become the + oldest version of a file. + NOTE: This option is reset when 'compatible' is set. + + *'backupcopy'* *'bkc'* +'backupcopy' 'bkc' string (Vi default for Unix: "yes", otherwise: "auto") + global + {not in Vi} + When writing a file and a backup is made, this option tells how it's + done. This is a comma separated list of words. + + The main values are: + "yes" make a copy of the file and overwrite the original one + "no" rename the file and write a new one + "auto" one of the previous, what works best + + Extra values that can be combined with the ones above are: + "breaksymlink" always break symlinks when writing + "breakhardlink" always break hardlinks when writing + + Making a copy and overwriting the original file: + - Takes extra time to copy the file. + + When the file has special attributes, is a (hard/symbolic) link or + has a resource fork, all this is preserved. + - When the file is a link the backup will have the name of the link, + not of the real file. + + Renaming the file and writing a new one: + + It's fast. + - Sometimes not all attributes of the file can be copied to the new + file. + - When the file is a link the new file will not be a link. + + The "auto" value is the middle way: When Vim sees that renaming file + is possible without side effects (the attributes can be passed on and + the file is not a link) that is used. When problems are expected, a + copy will be made. + + The "breaksymlink" and "breakhardlink" values can be used in + combination with any of "yes", "no" and "auto". When included, they + force Vim to always break either symbolic or hard links by doing + exactly what the "no" option does, renaming the original file to + become the backup and writing a new file in its place. This can be + useful for example in source trees where all the files are symbolic or + hard links and any changes should stay in the local source tree, not + be propagated back to the original source. + *crontab* + One situation where "no" and "auto" will cause problems: A program + that opens a file, invokes Vim to edit that file, and then tests if + the open file was changed (through the file descriptor) will check the + backup file instead of the newly created file. "crontab -e" is an + example. + + When a copy is made, the original file is truncated and then filled + with the new text. This means that protection bits, owner and + symbolic links of the original file are unmodified. The backup file + however, is a new file, owned by the user who edited the file. The + group of the backup is set to the group of the original file. If this + fails, the protection bits for the group are made the same as for + others. + + When the file is renamed this is the other way around: The backup has + the same attributes of the original file, and the newly written file + is owned by the current user. When the file was a (hard/symbolic) + link, the new file will not! That's why the "auto" value doesn't + rename when the file is a link. The owner and group of the newly + written file will be set to the same ones as the original file, but + the system may refuse to do this. In that case the "auto" value will + again not rename the file. + + *'backupdir'* *'bdir'* +'backupdir' 'bdir' string (default for Amiga: ".,t:", + for MS-DOS and Win32: ".,c:/tmp,c:/temp" + for Unix: ".,~/tmp,~/") + global + {not in Vi} + List of directories for the backup file, separated with commas. + - The backup file will be created in the first directory in the list + where this is possible. The directory must exist, Vim will not + create it for you. + - Empty means that no backup file will be created ('patchmode' is + impossible!). Writing may fail because of this. + - A directory "." means to put the backup file in the same directory + as the edited file. + - A directory starting with "./" (or ".\" for MS-DOS et al.) means to + put the backup file relative to where the edited file is. The + leading "." is replaced with the path name of the edited file. + ("." inside a directory name has no special meaning). + - Spaces after the comma are ignored, other spaces are considered part + of the directory name. To have a space at the start of a directory + name, precede it with a backslash. + - To include a comma in a directory name precede it with a backslash. + - A directory name may end in an '/'. + - Environment variables are expanded |:set_env|. + - Careful with '\' characters, type one before a space, type two to + get one in the option (see |option-backslash|), for example: > + :set bdir=c:\\tmp,\ dir\\,with\\,commas,\\\ dir\ with\ spaces +< - For backwards compatibility with Vim version 3.0 a '>' at the start + of the option is removed. + See also 'backup' and 'writebackup' options. + If you want to hide your backup files on Unix, consider this value: > + :set backupdir=./.backup,~/.backup,.,/tmp +< You must create a ".backup" directory in each directory and in your + home directory for this to work properly. + The use of |:set+=| and |:set-=| is preferred when adding or removing + directories from the list. This avoids problems when a future version + uses another default. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'backupext'* *'bex'* *E589* +'backupext' 'bex' string (default "~", for VMS: "_") + global + {not in Vi} + String which is appended to a file name to make the name of the + backup file. The default is quite unusual, because this avoids + accidentally overwriting existing files with a backup file. You might + prefer using ".bak", but make sure that you don't have files with + ".bak" that you want to keep. + Only normal file name characters can be used, "/\*?[|<>" are illegal. + + If you like to keep a lot of backups, you could use a BufWritePre + autocommand to change 'backupext' just before writing the file to + include a timestamp. > + :au BufWritePre * let &bex = '-' . strftime("%Y%b%d%X") . '~' +< Use 'backupdir' to put the backup in a different directory. + + *'backupskip'* *'bsk'* +'backupskip' 'bsk' string (default: "/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*") + global + {not in Vi} + {not available when compiled without the |+wildignore| + feature} + A list of file patterns. When one of the patterns matches with the + name of the file which is written, no backup file is created. Both + the specified file name and the full path name of the file are used. + The pattern is used like with |:autocmd|, see |autocmd-patterns|. + Watch out for special characters, see |option-backslash|. + When $TMPDIR, $TMP or $TEMP is not defined, it is not used for the + default value. "/tmp/*" is only used for Unix. + + Note that environment variables are not expanded. If you want to use + $HOME you must expand it explicitly, e.g.: > + :let backupskip = escape(expand('$HOME'), '\') . '/tmp/*' + +< Note that the default also makes sure that "crontab -e" works (when a + backup would be made by renaming the original file crontab won't see + the newly created file). Also see 'backupcopy' and |crontab|. + + *'balloondelay'* *'bdlay'* +'balloondelay' 'bdlay' number (default: 600) + global + {not in Vi} + {only available when compiled with the |+balloon_eval| + feature} + Delay in milliseconds before a balloon may pop up. See |balloon-eval|. + + *'ballooneval'* *'beval'* *'noballooneval'* *'nobeval'* +'ballooneval' 'beval' boolean (default off) + global + {not in Vi} + {only available when compiled with the |+balloon_eval| + feature} + Switch on the |balloon-eval| functionality. + + *'balloonexpr'* *'bexpr'* +'balloonexpr' 'bexpr' string (default "") + global or local to buffer |global-local| + {not in Vi} + {only available when compiled with the |+balloon_eval| + feature} + Expression for text to show in evaluation balloon. It is only used + when 'ballooneval' is on. These variables can be used: + + v:beval_bufnr number of the buffer in which balloon is going to show + v:beval_winnr number of the window + v:beval_lnum line number + v:beval_col column number (byte index) + v:beval_text word under or after the mouse pointer + + The evaluation of the expression must not have side effects! + Example: > + function! MyBalloonExpr() + return 'Cursor is at line ' . v:beval_lnum . + \', column ' . v:beval_col . + \ ' of file ' . bufname(v:beval_bufnr) . + \ ' on word "' . v:beval_text . '"' + endfunction + set bexpr=MyBalloonExpr() + set ballooneval +< + NOTE: The balloon is displayed only if the cursor is on a text + character. If the result of evaluating 'balloonexpr' is not empty, + Vim does not try to send a message to an external debugger (Netbeans + or Sun Workshop). + + The expression may be evaluated in the |sandbox|, see + |sandbox-option|. + + It is not allowed to change text or jump to another window while + evaluating 'balloonexpr' |textlock|. + + To check whether line breaks in the balloon text work use this check: > + if has("balloon_multiline") +< When they are supported "\n" characters will start a new line. If the + expression evaluates to a |List| this is equal to using each List item + as a string and putting "\n" in between them. + + *'binary'* *'bin'* *'nobinary'* *'nobin'* +'binary' 'bin' boolean (default off) + local to buffer + {not in Vi} + This option should be set before editing a binary file. You can also + use the |-b| Vim argument. When this option is switched on a few + options will be changed (also when it already was on): + 'textwidth' will be set to 0 + 'wrapmargin' will be set to 0 + 'modeline' will be off + 'expandtab' will be off + Also, 'fileformat' and 'fileformats' options will not be used, the + file is read and written like 'fileformat' was "unix" (a single + separates lines). + The 'fileencoding' and 'fileencodings' options will not be used, the + file is read without conversion. + NOTE: When you start editing a(nother) file while the 'bin' option is + on, settings from autocommands may change the settings again (e.g., + 'textwidth'), causing trouble when editing. You might want to set + 'bin' again when the file has been loaded. + The previous values of these options are remembered and restored when + 'bin' is switched from on to off. Each buffer has its own set of + saved option values. + To edit a file with 'binary' set you can use the |++bin| argument. + This avoids you have to do ":set bin", which would have effect for all + files you edit. + When writing a file the for the last line is only written if + there was one in the original file (normally Vim appends an to + the last line if there is none; this would make the file longer). See + the 'endofline' option. + + *'bioskey'* *'biosk'* *'nobioskey'* *'nobiosk'* +'bioskey' 'biosk' boolean (default on) + global + {not in Vi} {only for MS-DOS} + When on the BIOS is called to obtain a keyboard character. This works + better to detect CTRL-C, but only works for the console. When using a + terminal over a serial port reset this option. + Also see |'conskey'|. + + *'bomb'* *'nobomb'* +'bomb' boolean (default off) + local to buffer + {not in Vi} + {only available when compiled with the |+multi_byte| + feature} + When writing a file and the following conditions are met, a BOM (Byte + Order Mark) is prepended to the file: + - this option is on + - the 'binary' option is off + - 'fileencoding' is "utf-8", "ucs-2", "ucs-4" or one of the little/big + endian variants. + Some applications use the BOM to recognize the encoding of the file. + Often used for UCS-2 files on MS-Windows. For other applications it + causes trouble, for example: "cat file1 file2" makes the BOM of file2 + appear halfway the resulting file. Gcc doesn't accept a BOM. + When Vim reads a file and 'fileencodings' starts with "ucs-bom", a + check for the presence of the BOM is done and 'bomb' set accordingly. + Unless 'binary' is set, it is removed from the first line, so that you + don't see it when editing. When you don't change the options, the BOM + will be restored when writing the file. + + *'breakat'* *'brk'* +'breakat' 'brk' string (default " ^I!@*-+;:,./?") + global + {not in Vi} + {not available when compiled without the |+linebreak| + feature} + This option lets you choose which characters might cause a line + break if 'linebreak' is on. Only works for ASCII and also for 8-bit + characters when 'encoding' is an 8-bit encoding. + + *'browsedir'* *'bsdir'* +'browsedir' 'bsdir' string (default: "last") + global + {not in Vi} {only for Motif, Athena, GTK, Mac and + Win32 GUI} + Which directory to use for the file browser: + last Use same directory as with last file browser, where a + file was opened or saved. + buffer Use the directory of the related buffer. + current Use the current directory. + {path} Use the specified directory + + *'bufhidden'* *'bh'* +'bufhidden' 'bh' string (default: "") + local to buffer + {not in Vi} + {not available when compiled without the |+quickfix| + feature} + This option specifies what happens when a buffer is no longer + displayed in a window: + follow the global 'hidden' option + hide hide the buffer (don't unload it), also when 'hidden' + is not set + unload unload the buffer, also when 'hidden' is set or using + |:hide| + delete delete the buffer from the buffer list, also when + 'hidden' is set or using |:hide|, like using + |:bdelete| + wipe wipe out the buffer from the buffer list, also when + 'hidden' is set or using |:hide|, like using + |:bwipeout| + + CAREFUL: when "unload", "delete" or "wipe" is used changes in a buffer + are lost without a warning. + This option is used together with 'buftype' and 'swapfile' to specify + special kinds of buffers. See |special-buffers|. + + *'buflisted'* *'bl'* *'nobuflisted'* *'nobl'* *E85* +'buflisted' 'bl' boolean (default: on) + local to buffer + {not in Vi} + When this option is set, the buffer shows up in the buffer list. If + it is reset it is not used for ":bnext", "ls", the Buffers menu, etc. + This option is reset by Vim for buffers that are only used to remember + a file name or marks. Vim sets it when starting to edit a buffer. + But not when moving to a buffer with ":buffer". + + *'buftype'* *'bt'* *E382* +'buftype' 'bt' string (default: "") + local to buffer + {not in Vi} + {not available when compiled without the |+quickfix| + feature} + The value of this option specifies the type of a buffer: + normal buffer + nofile buffer which is not related to a file and will not be + written + nowrite buffer which will not be written + acwrite buffer which will always be written with BufWriteCmd + autocommands. {not available when compiled without the + |+autocmd| feature} + quickfix quickfix buffer, contains list of errors |:cwindow| + or list of locations |:lwindow| + help help buffer (you are not supposed to set this + manually) + + This option is used together with 'bufhidden' and 'swapfile' to + specify special kinds of buffers. See |special-buffers|. + + Be careful with changing this option, it can have many side effects! + + A "quickfix" buffer is only used for the error list and the location + list. This value is set by the |:cwindow| and |:lwindow| commands and + you are not supposed to change it. + + "nofile" and "nowrite" buffers are similar: + both: The buffer is not to be written to disk, ":w" doesn't + work (":w filename" does work though). + both: The buffer is never considered to be |'modified'|. + There is no warning when the changes will be lost, for + example when you quit Vim. + both: A swap file is only created when using too much memory + (when 'swapfile' has been reset there is never a swap + file). + nofile only: The buffer name is fixed, it is not handled like a + file name. It is not modified in response to a |:cd| + command. + *E676* + "acwrite" implies that the buffer name is not related to a file, like + "nofile", but it will be written. Thus, in contrast to "nofile" and + "nowrite", ":w" does work and a modified buffer can't be abandoned + without saving. For writing there must be matching |BufWriteCmd|, + |FileWriteCmd| or |FileAppendCmd| autocommands. + + *'casemap'* *'cmp'* +'casemap' 'cmp' string (default: "internal,keepascii") + global + {not in Vi} + {only available when compiled with the |+multi_byte| + feature} + Specifies details about changing the case of letters. It may contain + these words, separated by a comma: + internal Use internal case mapping functions, the current + locale does not change the case mapping. This only + matters when 'encoding' is a Unicode encoding, + "latin1" or "iso-8859-15". When "internal" is + omitted, the towupper() and towlower() system library + functions are used when available. + keepascii For the ASCII characters (0x00 to 0x7f) use the US + case mapping, the current locale is not effective. + This probably only matters for Turkish. + + *'cdpath'* *'cd'* *E344* *E346* +'cdpath' 'cd' string (default: equivalent to $CDPATH or ",,") + global + {not in Vi} + {not available when compiled without the + |+file_in_path| feature} + This is a list of directories which will be searched when using the + |:cd| and |:lcd| commands, provided that the directory being searched + for has a relative path, not an absolute part starting with "/", "./" + or "../", the 'cdpath' option is not used then. + The 'cdpath' option's value has the same form and semantics as + |'path'|. Also see |file-searching|. + The default value is taken from $CDPATH, with a "," prepended to look + in the current directory first. + If the default value taken from $CDPATH is not what you want, include + a modified version of the following command in your vimrc file to + override it: > + :let &cdpath = ',' . substitute(substitute($CDPATH, '[, ]', '\\\0', 'g'), ':', ',', 'g') +< This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + (parts of 'cdpath' can be passed to the shell to expand file names). + + *'cedit'* +'cedit' string (Vi default: "", Vim default: CTRL-F) + global + {not in Vi} + {not available when compiled without the |+vertsplit| + feature} + The key used in Command-line Mode to open the command-line window. + The default is CTRL-F when 'compatible' is off. + Only non-printable keys are allowed. + The key can be specified as a single character, but it is difficult to + type. The preferred way is to use the <> notation. Examples: > + :set cedit= + :set cedit= +< |Nvi| also has this option, but it only uses the first character. + See |cmdwin|. + + *'charconvert'* *'ccv'* *E202* *E214* *E513* +'charconvert' 'ccv' string (default "") + global + {only available when compiled with the |+multi_byte| + and |+eval| features} + {not in Vi} + An expression that is used for character encoding conversion. It is + evaluated when a file that is to be read or has been written has a + different encoding from what is desired. + 'charconvert' is not used when the internal iconv() function is + supported and is able to do the conversion. Using iconv() is + preferred, because it is much faster. + 'charconvert' is not used when reading stdin |--|, because there is no + file to convert from. You will have to save the text in a file first. + The expression must return zero or an empty string for success, + non-zero for failure. + The possible encoding names encountered are in 'encoding'. + Additionally, names given in 'fileencodings' and 'fileencoding' are + used. + Conversion between "latin1", "unicode", "ucs-2", "ucs-4" and "utf-8" + is done internally by Vim, 'charconvert' is not used for this. + 'charconvert' is also used to convert the viminfo file, if the 'c' + flag is present in 'viminfo'. Also used for Unicode conversion. + Example: > + set charconvert=CharConvert() + fun CharConvert() + system("recode " + \ . v:charconvert_from . ".." . v:charconvert_to + \ . " <" . v:fname_in . " >" v:fname_out) + return v:shell_error + endfun +< The related Vim variables are: + v:charconvert_from name of the current encoding + v:charconvert_to name of the desired encoding + v:fname_in name of the input file + v:fname_out name of the output file + Note that v:fname_in and v:fname_out will never be the same. + Note that v:charconvert_from and v:charconvert_to may be different + from 'encoding'. Vim internally uses UTF-8 instead of UCS-2 or UCS-4. + Encryption is not done by Vim when using 'charconvert'. If you want + to encrypt the file after conversion, 'charconvert' should take care + of this. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'cindent'* *'cin'* *'nocindent'* *'nocin'* +'cindent' 'cin' boolean (default off) + local to buffer + {not in Vi} + {not available when compiled without the |+cindent| + feature} + Enables automatic C program indenting. See 'cinkeys' to set the keys + that trigger reindenting in insert mode and 'cinoptions' to set your + preferred indent style. + If 'indentexpr' is not empty, it overrules 'cindent'. + If 'lisp' is not on and both 'indentexpr' and 'equalprg' are empty, + the "=" operator indents using this algorithm rather than calling an + external program. + See |C-indenting|. + When you don't like the way 'cindent' works, try the 'smartindent' + option or 'indentexpr'. + This option is not used when 'paste' is set. + NOTE: This option is reset when 'compatible' is set. + + *'cinkeys'* *'cink'* +'cinkeys' 'cink' string (default "0{,0},0),:,0#,!^F,o,O,e") + local to buffer + {not in Vi} + {not available when compiled without the |+cindent| + feature} + A list of keys that, when typed in Insert mode, cause reindenting of + the current line. Only used if 'cindent' is on and 'indentexpr' is + empty. + For the format of this option see |cinkeys-format|. + See |C-indenting|. + + *'cinoptions'* *'cino'* +'cinoptions' 'cino' string (default "") + local to buffer + {not in Vi} + {not available when compiled without the |+cindent| + feature} + The 'cinoptions' affect the way 'cindent' reindents lines in a C + program. See |cinoptions-values| for the values of this option, and + |C-indenting| for info on C indenting in general. + + + *'cinwords'* *'cinw'* +'cinwords' 'cinw' string (default "if,else,while,do,for,switch") + local to buffer + {not in Vi} + {not available when compiled without both the + |+cindent| and the |+smartindent| features} + These keywords start an extra indent in the next line when + 'smartindent' or 'cindent' is set. For 'cindent' this is only done at + an appropriate place (inside {}). + Note that 'ignorecase' isn't used for 'cinwords'. If case doesn't + matter, include the keyword both the uppercase and lowercase: + "if,If,IF". + + *'clipboard'* *'cb'* +'clipboard' 'cb' string (default "autoselect,exclude:cons\|linux" + for X-windows, "" otherwise) + global + {not in Vi} + {only in GUI versions or when the |+xterm_clipboard| + feature is included} + This option is a list of comma separated names. + These names are recognized: + + unnamed When included, Vim will use the clipboard register '*' + for all yank, delete, change and put operations which + would normally go to the unnamed register. When a + register is explicitly specified, it will always be + used regardless of whether "unnamed" is in 'clipboard' + or not. The clipboard register can always be + explicitly accessed using the "* notation. Also see + |gui-clipboard|. + + unnamedplus A variant of "unnamed" flag which uses the clipboard + register '+' (|quoteplus|) instead of register '*' for + all operations except yank. Yank shall copy the text + into register '+' and also into '*' when "unnamed" is + included. + Only available with the |+x11| feature. + Availability can be checked with: > + if has('unnamedplus') +< + autoselect Works like the 'a' flag in 'guioptions': If present, + then whenever Visual mode is started, or the Visual + area extended, Vim tries to become the owner of the + windowing system's global selection or put the + selected text on the clipboard used by the selection + register "*. See |guioptions_a| and |quotestar| for + details. When the GUI is active, the 'a' flag in + 'guioptions' is used, when the GUI is not active, this + "autoselect" flag is used. + Also applies to the modeless selection. + + autoselectml Like "autoselect", but for the modeless selection + only. Compare to the 'A' flag in 'guioptions'. + + html When the clipboard contains HTML, use this when + pasting. When putting text on the clipboard, mark it + as HTML. This works to copy rendered HTML from + Firefox, paste it as raw HTML in Vim, select the HTML + in Vim and paste it in a rich edit box in Firefox. + You probably want to add this only temporarily, + possibly use BufEnter autocommands. + Only supported for GTK version 2 and later. + Only available with the |+multi_byte| feature. + + exclude:{pattern} + Defines a pattern that is matched against the name of + the terminal 'term'. If there is a match, no + connection will be made to the X server. This is + useful in this situation: + - Running Vim in a console. + - $DISPLAY is set to start applications on another + display. + - You do not want to connect to the X server in the + console, but do want this in a terminal emulator. + To never connect to the X server use: > + exclude:.* +< This has the same effect as using the |-X| argument. + Note that when there is no connection to the X server + the window title won't be restored and the clipboard + cannot be accessed. + The value of 'magic' is ignored, {pattern} is + interpreted as if 'magic' was on. + The rest of the option value will be used for + {pattern}, this must be the last entry. + + *'cmdheight'* *'ch'* +'cmdheight' 'ch' number (default 1) + global + {not in Vi} + Number of screen lines to use for the command-line. Helps avoiding + |hit-enter| prompts. + The value of this option is stored with the tab page, so that each tab + page can have a different value. + + *'cmdwinheight'* *'cwh'* +'cmdwinheight' 'cwh' number (default 7) + global + {not in Vi} + {not available when compiled without the |+vertsplit| + feature} + Number of screen lines to use for the command-line window. |cmdwin| + + *'columns'* *'co'* *E594* +'columns' 'co' number (default 80 or terminal width) + global + {not in Vi} + Number of columns of the screen. Normally this is set by the terminal + initialization and does not have to be set by hand. Also see + |posix-screen-size|. + When Vim is running in the GUI or in a resizable window, setting this + option will cause the window size to be changed. When you only want + to use the size for the GUI, put the command in your |gvimrc| file. + When you set this option and Vim is unable to change the physical + number of columns of the display, the display may be messed up. For + the GUI it is always possible and Vim limits the number of columns to + what fits on the screen. You can use this command to get the widest + window possible: > + :set columns=9999 +< Minimum value is 12, maximum value is 10000. + + *'comments'* *'com'* *E524* *E525* +'comments' 'com' string (default + "s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-") + local to buffer + {not in Vi} + {not available when compiled without the |+comments| + feature} + A comma separated list of strings that can start a comment line. See + |format-comments|. See |option-backslash| about using backslashes to + insert a space. + + *'commentstring'* *'cms'* *E537* +'commentstring' 'cms' string (default "/*%s*/") + local to buffer + {not in Vi} + {not available when compiled without the |+folding| + feature} + A template for a comment. The "%s" in the value is replaced with the + comment text. Currently only used to add markers for folding, see + |fold-marker|. + + *'compatible'* *'cp'* *'nocompatible'* *'nocp'* +'compatible' 'cp' boolean (default on, off when a |vimrc| or |gvimrc| + file is found) + global + {not in Vi} + This option has the effect of making Vim either more Vi-compatible, or + make Vim behave in a more useful way. + This is a special kind of option, because when it's set or reset, + other options are also changed as a side effect. CAREFUL: Setting or + resetting this option can have a lot of unexpected effects: Mappings + are interpreted in another way, undo behaves differently, etc. If you + set this option in your vimrc file, you should probably put it at the + very start. + By default this option is on and the Vi defaults are used for the + options. This default was chosen for those people who want to use Vim + just like Vi, and don't even (want to) know about the 'compatible' + option. + When a |vimrc| or |gvimrc| file is found while Vim is starting up, + this option is switched off, and all options that have not been + modified will be set to the Vim defaults. Effectively, this means + that when a |vimrc| or |gvimrc| file exists, Vim will use the Vim + defaults, otherwise it will use the Vi defaults. (Note: This doesn't + happen for the system-wide vimrc or gvimrc file, nor for a file given + with the |-u| argument). Also see |compatible-default| and + |posix-compliance|. + You can also set this option with the "-C" argument, and reset it with + "-N". See |-C| and |-N|. + Switching this option off makes the Vim defaults be used for options + that have a different Vi and Vim default value. See the options + marked with a '+' below. Other options are not modified. + At the moment this option is set, several other options will be set + or reset to make Vim as Vi-compatible as possible. See the table + below. This can be used if you want to revert to Vi compatible + editing. + See also 'cpoptions'. + + option + set value effect ~ + + 'allowrevins' off no CTRL-_ command + 'backupcopy' Unix: "yes" backup file is a copy + others: "auto" copy or rename backup file + 'backspace' "" normal backspace + 'backup' off no backup file + 'cindent' off no C code indentation + 'cedit' + "" no key to open the |cmdwin| + 'cpoptions' + (all flags) Vi-compatible flags + 'cscopetag' off don't use cscope for ":tag" + 'cscopetagorder' 0 see |cscopetagorder| + 'cscopeverbose' off see |cscopeverbose| + 'digraph' off no digraphs + 'esckeys' + off no -keys in Insert mode + 'expandtab' off tabs not expanded to spaces + 'fileformats' + "" no automatic file format detection, + "dos,unix" except for DOS, Windows and OS/2 + 'formatoptions' + "vt" Vi compatible formatting + 'gdefault' off no default 'g' flag for ":s" + 'history' + 0 no commandline history + 'hkmap' off no Hebrew keyboard mapping + 'hkmapp' off no phonetic Hebrew keyboard mapping + 'hlsearch' off no highlighting of search matches + 'incsearch' off no incremental searching + 'indentexpr' "" no indenting by expression + 'insertmode' off do not start in Insert mode + 'iskeyword' + "@,48-57,_" keywords contain alphanumeric + characters and '_' + 'joinspaces' on insert 2 spaces after period + 'modeline' + off no modelines + 'more' + off no pauses in listings + 'revins' off no reverse insert + 'ruler' off no ruler + 'scrolljump' 1 no jump scroll + 'scrolloff' 0 no scroll offset + 'shiftround' off indent not rounded to shiftwidth + 'shortmess' + "" no shortening of messages + 'showcmd' + off command characters not shown + 'showmode' + off current mode not shown + 'smartcase' off no automatic ignore case switch + 'smartindent' off no smart indentation + 'smarttab' off no smart tab size + 'softtabstop' 0 tabs are always 'tabstop' positions + 'startofline' on goto startofline with some commands + 'tagrelative' + off tag file names are not relative + 'textauto' + off no automatic textmode detection + 'textwidth' 0 no automatic line wrap + 'tildeop' off tilde is not an operator + 'ttimeout' off no terminal timeout + 'whichwrap' + "" left-right movements don't wrap + 'wildchar' + CTRL-E only when the current value is + use CTRL-E for cmdline completion + 'writebackup' on or off depends on the |+writebackup| feature + + *'complete'* *'cpt'* *E535* +'complete' 'cpt' string (default: ".,w,b,u,t,i") + local to buffer + {not in Vi} + This option specifies how keyword completion |ins-completion| works + when CTRL-P or CTRL-N are used. It is also used for whole-line + completion |i_CTRL-X_CTRL-L|. It indicates the type of completion + and the places to scan. It is a comma separated list of flags: + . scan the current buffer ('wrapscan' is ignored) + w scan buffers from other windows + b scan other loaded buffers that are in the buffer list + u scan the unloaded buffers that are in the buffer list + U scan the buffers that are not in the buffer list + k scan the files given with the 'dictionary' option + kspell use the currently active spell checking |spell| + k{dict} scan the file {dict}. Several "k" flags can be given, + patterns are valid too. For example: > + :set cpt=k/usr/dict/*,k~/spanish +< s scan the files given with the 'thesaurus' option + s{tsr} scan the file {tsr}. Several "s" flags can be given, patterns + are valid too. + i scan current and included files + d scan current and included files for defined name or macro + |i_CTRL-X_CTRL-D| + ] tag completion + t same as "]" + + Unloaded buffers are not loaded, thus their autocmds |:autocmd| are + not executed, this may lead to unexpected completions from some files + (gzipped files for example). Unloaded buffers are not scanned for + whole-line completion. + + The default is ".,w,b,u,t,i", which means to scan: + 1. the current buffer + 2. buffers in other windows + 3. other loaded buffers + 4. unloaded buffers + 5. tags + 6. included files + + As you can see, CTRL-N and CTRL-P can be used to do any 'iskeyword'- + based expansion (e.g., dictionary |i_CTRL-X_CTRL-K|, included patterns + |i_CTRL-X_CTRL-I|, tags |i_CTRL-X_CTRL-]| and normal expansions). + + *'completefunc'* *'cfu'* +'completefunc' 'cfu' string (default: empty) + local to buffer + {not in Vi} + {not available when compiled without the |+eval| + or |+insert_expand| features} + This option specifies a function to be used for Insert mode completion + with CTRL-X CTRL-U. |i_CTRL-X_CTRL-U| + See |complete-functions| for an explanation of how the function is + invoked and what it should return. + + + *'completeopt'* *'cot'* +'completeopt' 'cot' string (default: "menu,preview") + global + {not available when compiled without the + |+insert_expand| feature} + {not in Vi} + A comma separated list of options for Insert mode completion + |ins-completion|. The supported values are: + + menu Use a popup menu to show the possible completions. The + menu is only shown when there is more than one match and + sufficient colors are available. |ins-completion-menu| + + menuone Use the popup menu also when there is only one match. + Useful when there is additional information about the + match, e.g., what file it comes from. + + longest Only insert the longest common text of the matches. If + the menu is displayed you can use CTRL-L to add more + characters. Whether case is ignored depends on the kind + of completion. For buffer text the 'ignorecase' option is + used. + + preview Show extra information about the currently selected + completion in the preview window. Only works in + combination with "menu" or "menuone". + + + *'concealcursor'* *'cocu'* +'concealcursor' 'cocu' string (default: "") + local to window + {not in Vi} + {not available when compiled without the |+conceal| + feature} + Sets the modes in which text in the cursor line can also be concealed. + When the current mode is listed then concealing happens just like in + other lines. + n Normal mode + v Visual mode + i Insert mode + c Command line editing, for 'incsearch' + + 'v' applies to all lines in the Visual area, not only the cursor. + A useful value is "nc". This is used in help files. So long as you + are moving around text is concealed, but when starting to insert text + or selecting a Visual area the concealed text is displayed, so that + you can see what you are doing. + Keep in mind that the cursor position is not always where it's + displayed. E.g., when moving vertically it may change column. + + +'conceallevel' 'cole' *'conceallevel'* *'cole'* + number (default 0) + local to window + {not in Vi} + {not available when compiled without the |+conceal| + feature} + Determine how text with the "conceal" syntax attribute |:syn-conceal| + is shown: + + Value Effect ~ + 0 Text is shown normally + 1 Each block of concealed text is replaced with one + character. If the syntax item does not have a custom + replacement character defined (see |:syn-cchar|) the + character defined in 'listchars' is used (default is a + space). + It is highlighted with the "Conceal" highlight group. + 2 Concealed text is completely hidden unless it has a + custom replacement character defined (see + |:syn-cchar|). + 3 Concealed text is completely hidden. + + Note: in the cursor line concealed text is not hidden, so that you can + edit and copy the text. This can be changed with the 'concealcursor' + option. + + *'confirm'* *'cf'* *'noconfirm'* *'nocf'* +'confirm' 'cf' boolean (default off) + global + {not in Vi} + When 'confirm' is on, certain operations that would normally + fail because of unsaved changes to a buffer, e.g. ":q" and ":e", + instead raise a |dialog| asking if you wish to save the current + file(s). You can still use a ! to unconditionally |abandon| a buffer. + If 'confirm' is off you can still activate confirmation for one + command only (this is most useful in mappings) with the |:confirm| + command. + Also see the |confirm()| function and the 'v' flag in 'guioptions'. + + *'conskey'* *'consk'* *'noconskey'* *'noconsk'* +'conskey' 'consk' boolean (default off) + global + {not in Vi} {only for MS-DOS} + When on direct console I/O is used to obtain a keyboard character. + This should work in most cases. Also see |'bioskey'|. Together, + three methods of console input are available: + 'conskey' 'bioskey' action ~ + on on or off direct console input + off on BIOS + off off STDIN + + *'copyindent'* *'ci'* *'nocopyindent'* *'noci'* +'copyindent' 'ci' boolean (default off) + local to buffer + {not in Vi} + Copy the structure of the existing lines indent when autoindenting a + new line. Normally the new indent is reconstructed by a series of + tabs followed by spaces as required (unless |'expandtab'| is enabled, + in which case only spaces are used). Enabling this option makes the + new line copy whatever characters were used for indenting on the + existing line. 'expandtab' has no effect on these characters, a Tab + remains a Tab. If the new indent is greater than on the existing + line, the remaining space is filled in the normal manner. + NOTE: 'copyindent' is reset when 'compatible' is set. + Also see 'preserveindent'. + + *'cpoptions'* *'cpo'* +'cpoptions' 'cpo' string (Vim default: "aABceFs", + Vi default: all flags) + global + {not in Vi} + A sequence of single character flags. When a character is present + this indicates vi-compatible behavior. This is used for things where + not being vi-compatible is mostly or sometimes preferred. + 'cpoptions' stands for "compatible-options". + Commas can be added for readability. + To avoid problems with flags that are added in the future, use the + "+=" and "-=" feature of ":set" |add-option-flags|. + NOTE: This option is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + NOTE: This option is set to the POSIX default value at startup when + the Vi default value would be used and the $VIM_POSIX environment + variable exists |posix|. This means Vim tries to behave like the + POSIX specification. + + contains behavior ~ + *cpo-a* + a When included, a ":read" command with a file name + argument will set the alternate file name for the + current window. + *cpo-A* + A When included, a ":write" command with a file name + argument will set the alternate file name for the + current window. + *cpo-b* + b "\|" in a ":map" command is recognized as the end of + the map command. The '\' is included in the mapping, + the text after the '|' is interpreted as the next + command. Use a CTRL-V instead of a backslash to + include the '|' in the mapping. Applies to all + mapping, abbreviation, menu and autocmd commands. + See also |map_bar|. + *cpo-B* + B A backslash has no special meaning in mappings, + abbreviations and the "to" part of the menu commands. + Remove this flag to be able to use a backslash like a + CTRL-V. For example, the command ":map X \" + results in X being mapped to: + 'B' included: "\^[" (^[ is a real ) + 'B' excluded: "" (5 characters) + ('<' excluded in both cases) + *cpo-c* + c Searching continues at the end of any match at the + cursor position, but not further than the start of the + next line. When not present searching continues + one character from the cursor position. With 'c' + "abababababab" only gets three matches when repeating + "/abab", without 'c' there are five matches. + *cpo-C* + C Do not concatenate sourced lines that start with a + backslash. See |line-continuation|. + *cpo-d* + d Using "./" in the 'tags' option doesn't mean to use + the tags file relative to the current file, but the + tags file in the current directory. + *cpo-D* + D Can't use CTRL-K to enter a digraph after Normal mode + commands with a character argument, like |r|, |f| and + |t|. + *cpo-e* + e When executing a register with ":@r", always add a + to the last line, also when the register is not + linewise. If this flag is not present, the register + is not linewise and the last line does not end in a + , then the last line is put on the command-line + and can be edited before hitting . + *cpo-E* + E It is an error when using "y", "d", "c", "g~", "gu" or + "gU" on an Empty region. The operators only work when + at least one character is to be operate on. Example: + This makes "y0" fail in the first column. + *cpo-f* + f When included, a ":read" command with a file name + argument will set the file name for the current buffer, + if the current buffer doesn't have a file name yet. + *cpo-F* + F When included, a ":write" command with a file name + argument will set the file name for the current + buffer, if the current buffer doesn't have a file name + yet. Also see |cpo-P|. + *cpo-g* + g Goto line 1 when using ":edit" without argument. + *cpo-H* + H When using "I" on a line with only blanks, insert + before the last blank. Without this flag insert after + the last blank. + *cpo-i* + i When included, interrupting the reading of a file will + leave it modified. + *cpo-I* + I When moving the cursor up or down just after inserting + indent for 'autoindent', do not delete the indent. + *cpo-j* + j When joining lines, only add two spaces after a '.', + not after '!' or '?'. Also see 'joinspaces'. + *cpo-J* + J A |sentence| has to be followed by two spaces after + the '.', '!' or '?'. A is not recognized as + white space. + *cpo-k* + k Disable the recognition of raw key codes in + mappings, abbreviations, and the "to" part of menu + commands. For example, if sends ^[OA (where ^[ + is ), the command ":map X ^[OA" results in X + being mapped to: + 'k' included: "^[OA" (3 characters) + 'k' excluded: "" (one key code) + Also see the '<' flag below. + *cpo-K* + K Don't wait for a key code to complete when it is + halfway a mapping. This breaks mapping when + only part of the second has been read. It + enables cancelling the mapping by typing . + *cpo-l* + l Backslash in a [] range in a search pattern is taken + literally, only "\]", "\^", "\-" and "\\" are special. + See |/[]| + 'l' included: "/[ \t]" finds , '\' and 't' + 'l' excluded: "/[ \t]" finds and + Also see |cpo-\|. + *cpo-L* + L When the 'list' option is set, 'wrapmargin', + 'textwidth', 'softtabstop' and Virtual Replace mode + (see |gR|) count a as two characters, instead of + the normal behavior of a . + *cpo-m* + m When included, a showmatch will always wait half a + second. When not included, a showmatch will wait half + a second or until a character is typed. |'showmatch'| + *cpo-M* + M When excluded, "%" matching will take backslashes into + account. Thus in "( \( )" and "\( ( \)" the outer + parenthesis match. When included "%" ignores + backslashes, which is Vi compatible. + *cpo-n* + n When included, the column used for 'number' and + 'relativenumber' will also be used for text of wrapped + lines. + *cpo-o* + o Line offset to search command is not remembered for + next search. + *cpo-O* + O Don't complain if a file is being overwritten, even + when it didn't exist when editing it. This is a + protection against a file unexpectedly created by + someone else. Vi didn't complain about this. + *cpo-p* + p Vi compatible Lisp indenting. When not present, a + slightly better algorithm is used. + *cpo-P* + P When included, a ":write" command that appends to a + file will set the file name for the current buffer, if + the current buffer doesn't have a file name yet and + the 'F' flag is also included |cpo-F|. + *cpo-q* + q When joining multiple lines leave the cursor at the + position where it would be when joining two lines. + *cpo-r* + r Redo ("." command) uses "/" to repeat a search + command, instead of the actually used search string. + *cpo-R* + R Remove marks from filtered lines. Without this flag + marks are kept like |:keepmarks| was used. + *cpo-s* + s Set buffer options when entering the buffer for the + first time. This is like it is in Vim version 3.0. + And it is the default. If not present the options are + set when the buffer is created. + *cpo-S* + S Set buffer options always when entering a buffer + (except 'readonly', 'fileformat', 'filetype' and + 'syntax'). This is the (most) Vi compatible setting. + The options are set to the values in the current + buffer. When you change an option and go to another + buffer, the value is copied. Effectively makes the + buffer options global to all buffers. + + 's' 'S' copy buffer options + no no when buffer created + yes no when buffer first entered (default) + X yes each time when buffer entered (vi comp.) + *cpo-t* + t Search pattern for the tag command is remembered for + "n" command. Otherwise Vim only puts the pattern in + the history for search pattern, but doesn't change the + last used search pattern. + *cpo-u* + u Undo is Vi compatible. See |undo-two-ways|. + *cpo-v* + v Backspaced characters remain visible on the screen in + Insert mode. Without this flag the characters are + erased from the screen right away. With this flag the + screen newly typed text overwrites backspaced + characters. + *cpo-w* + w When using "cw" on a blank character, only change one + character and not all blanks until the start of the + next word. + *cpo-W* + W Don't overwrite a readonly file. When omitted, ":w!" + overwrites a readonly file, if possible. + *cpo-x* + x on the command-line executes the command-line. + The default in Vim is to abandon the command-line, + because normally aborts a command. |c_| + *cpo-X* + X When using a count with "R" the replaced text is + deleted only once. Also when repeating "R" with "." + and a count. + *cpo-y* + y A yank command can be redone with ".". + *cpo-Z* + Z When using "w!" while the 'readonly' option is set, + don't reset 'readonly'. + *cpo-!* + ! When redoing a filter command, use the last used + external command, whatever it was. Otherwise the last + used -filter- command is used. + *cpo-$* + $ When making a change to one line, don't redisplay the + line, but put a '$' at the end of the changed text. + The changed text will be overwritten when you type the + new text. The line is redisplayed if you type any + command that moves the cursor from the insertion + point. + *cpo-%* + % Vi-compatible matching is done for the "%" command. + Does not recognize "#if", "#endif", etc. + Does not recognize "/*" and "*/". + Parens inside single and double quotes are also + counted, causing a string that contains a paren to + disturb the matching. For example, in a line like + "if (strcmp("foo(", s))" the first paren does not + match the last one. When this flag is not included, + parens inside single and double quotes are treated + specially. When matching a paren outside of quotes, + everything inside quotes is ignored. When matching a + paren inside quotes, it will find the matching one (if + there is one). This works very well for C programs. + This flag is also used for other features, such as + C-indenting. + *cpo--* + - When included, a vertical movement command fails when + it would go above the first line or below the last + line. Without it the cursor moves to the first or + last line, unless it already was in that line. + Applies to the commands "-", "k", CTRL-P, "+", "j", + CTRL-N, CTRL-J and ":1234". + *cpo-+* + + When included, a ":write file" command will reset the + 'modified' flag of the buffer, even though the buffer + itself may still be different from its file. + *cpo-star* + * Use ":*" in the same way as ":@". When not included, + ":*" is an alias for ":'<,'>", select the Visual area. + *cpo-<* + < Disable the recognition of special key codes in |<>| + form in mappings, abbreviations, and the "to" part of + menu commands. For example, the command + ":map X " results in X being mapped to: + '<' included: "" (5 characters) + '<' excluded: "^I" (^I is a real ) + Also see the 'k' flag above. + *cpo->* + > When appending to a register, put a line break before + the appended text. + + POSIX flags. These are not included in the Vi default value, except + when $VIM_POSIX was set on startup. |posix| + + contains behavior ~ + *cpo-#* + # A count before "D", "o" and "O" has no effect. + *cpo-&* + & When ":preserve" was used keep the swap file when + exiting normally while this buffer is still loaded. + This flag is tested when exiting. + *cpo-\* + \ Backslash in a [] range in a search pattern is taken + literally, only "\]" is special See |/[]| + '\' included: "/[ \-]" finds , '\' and '-' + '\' excluded: "/[ \-]" finds and '-' + Also see |cpo-l|. + *cpo-/* + / When "%" is used as the replacement string in a |:s| + command, use the previous replacement string. |:s%| + *cpo-{* + { The |{| and |}| commands also stop at a "{" character + at the start of a line. + *cpo-.* + . The ":chdir" and ":cd" commands fail if the current + buffer is modified, unless ! is used. Vim doesn't + need this, since it remembers the full path of an + opened file. + *cpo-bar* + | The value of the $LINES and $COLUMNS environment + variables overrule the terminal size values obtained + with system specific functions. + + + *'cryptmethod'* *'cm'* +'cryptmethod' string (default "zip") + global or local to buffer |global-local| + {not in Vi} + Method used for encryption when the buffer is written to a file: + *pkzip* + zip PkZip compatible method. A weak kind of encryption. + Backwards compatible with Vim 7.2 and older. + *blowfish* + blowfish Blowfish method. Strong encryption. Requires Vim 7.3 + or later, files can NOT be read by Vim 7.2 and older. + This adds a "seed" to the file, every time you write + the file the encrypted bytes will be different. + + When reading an encrypted file 'cryptmethod' will be set automatically + to the detected method of the file being read. Thus if you write it + without changing 'cryptmethod' the same method will be used. + Changing 'cryptmethod' does not mark the file as modified, you have to + explicitly write it, you don't get a warning unless there are other + modifications. Also see |:X|. + + When setting the global value to an empty string, it will end up with + the value "zip". When setting the local value to an empty string the + buffer will use the global value. + + When a new encryption method is added in a later version of Vim, and + the current version does not recognize it, you will get *E821* . + You need to edit this file with the later version of Vim. + + + *'cscopepathcomp'* *'cspc'* +'cscopepathcomp' 'cspc' number (default 0) + global + {not available when compiled without the |+cscope| + feature} + {not in Vi} + Determines how many components of the path to show in a list of tags. + See |cscopepathcomp|. + + *'cscopeprg'* *'csprg'* +'cscopeprg' 'csprg' string (default "cscope") + global + {not available when compiled without the |+cscope| + feature} + {not in Vi} + Specifies the command to execute cscope. See |cscopeprg|. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'cscopequickfix'* *'csqf'* +'cscopequickfix' 'csqf' string (default "") + global + {not available when compiled without the |+cscope| + or |+quickfix| features} + {not in Vi} + Specifies whether to use quickfix window to show cscope results. + See |cscopequickfix|. + + *'cscopetag'* *'cst'* *'nocscopetag'* *'nocst'* +'cscopetag' 'cst' boolean (default off) + global + {not available when compiled without the |+cscope| + feature} + {not in Vi} + Use cscope for tag commands. See |cscope-options|. + NOTE: This option is reset when 'compatible' is set. + + *'cscopetagorder'* *'csto'* +'cscopetagorder' 'csto' number (default 0) + global + {not available when compiled without the |+cscope| + feature} + {not in Vi} + Determines the order in which ":cstag" performs a search. See + |cscopetagorder|. + NOTE: This option is set to 0 when 'compatible' is set. + + *'cscopeverbose'* *'csverb'* + *'nocscopeverbose'* *'nocsverb'* +'cscopeverbose' 'csverb' boolean (default off) + global + {not available when compiled without the |+cscope| + feature} + {not in Vi} + Give messages when adding a cscope database. See |cscopeverbose|. + NOTE: This option is reset when 'compatible' is set. + + *'cursorbind'* *'crb'* *'nocursorbind'* *'nocrb'* +'cursorbind' 'crb' boolean (default off) + local to window + {not in Vi} + {not available when compiled without the |+cursorbind| + feature} + When this option is set, as the cursor in the current + window moves other cursorbound windows (windows that also have + this option set) move their cursors to the corresponding line and + column. This option is useful for viewing the + differences between two versions of a file (see 'diff'); in diff mode, + inserted and deleted lines (though not characters within a line) are + taken into account. + + + *'cursorcolumn'* *'cuc'* *'nocursorcolumn'* *'nocuc'* +'cursorcolumn' 'cuc' boolean (default off) + local to window + {not in Vi} + {not available when compiled without the |+syntax| + feature} + Highlight the screen column of the cursor with CursorColumn + |hl-CursorColumn|. Useful to align text. Will make screen redrawing + slower. + If you only want the highlighting in the current window you can use + these autocommands: > + au WinLeave * set nocursorline nocursorcolumn + au WinEnter * set cursorline cursorcolumn +< + + *'cursorline'* *'cul'* *'nocursorline'* *'nocul'* +'cursorline' 'cul' boolean (default off) + local to window + {not in Vi} + {not available when compiled without the |+syntax| + feature} + Highlight the screen line of the cursor with CursorLine + |hl-CursorLine|. Useful to easily spot the cursor. Will make screen + redrawing slower. + When Visual mode is active the highlighting isn't used to make it + easier to see the selected text. + + + *'debug'* +'debug' string (default "") + global + {not in Vi} + These values can be used: + msg Error messages that would otherwise be omitted will be given + anyway. + throw Error messages that would otherwise be omitted will be given + anyway and also throw an exception and set |v:errmsg|. + beep A message will be given when otherwise only a beep would be + produced. + The values can be combined, separated by a comma. + "msg" and "throw" are useful for debugging 'foldexpr', 'formatexpr' or + 'indentexpr'. + + *'define'* *'def'* +'define' 'def' string (default "^\s*#\s*define") + global or local to buffer |global-local| + {not in Vi} + Pattern to be used to find a macro definition. It is a search + pattern, just like for the "/" command. This option is used for the + commands like "[i" and "[d" |include-search|. The 'isident' option is + used to recognize the defined name after the match: + {match with 'define'}{non-ID chars}{defined name}{non-ID char} + See |option-backslash| about inserting backslashes to include a space + or backslash. + The default value is for C programs. For C++ this value would be + useful, to include const type declarations: > + ^\(#\s*define\|[a-z]*\s*const\s*[a-z]*\) +< When using the ":set" command, you need to double the backslashes! + + *'delcombine'* *'deco'* *'nodelcombine'* *'nodeco'* +'delcombine' 'deco' boolean (default off) + global + {not in Vi} + {only available when compiled with the |+multi_byte| + feature} + If editing Unicode and this option is set, backspace and Normal mode + "x" delete each combining character on its own. When it is off (the + default) the character along with its combining characters are + deleted. + Note: When 'delcombine' is set "xx" may work different from "2x"! + + This is useful for Arabic, Hebrew and many other languages where one + may have combining characters overtop of base characters, and want + to remove only the combining ones. + + *'dictionary'* *'dict'* +'dictionary' 'dict' string (default "") + global or local to buffer |global-local| + {not in Vi} + List of file names, separated by commas, that are used to lookup words + for keyword completion commands |i_CTRL-X_CTRL-K|. Each file should + contain a list of words. This can be one word per line, or several + words per line, separated by non-keyword characters (white space is + preferred). Maximum line length is 510 bytes. + When this option is empty, or an entry "spell" is present, spell + checking is enabled the currently active spelling is used. |spell| + To include a comma in a file name precede it with a backslash. Spaces + after a comma are ignored, otherwise spaces are included in the file + name. See |option-backslash| about using backslashes. + This has nothing to do with the |Dictionary| variable type. + Where to find a list of words? + - On FreeBSD, there is the file "/usr/share/dict/words". + - In the Simtel archive, look in the "msdos/linguist" directory. + - In "miscfiles" of the GNU collection. + The use of |:set+=| and |:set-=| is preferred when adding or removing + directories from the list. This avoids problems when a future version + uses another default. + Backticks cannot be used in this option for security reasons. + + *'diff'* *'nodiff'* +'diff' boolean (default off) + local to window + {not in Vi} + {not available when compiled without the |+diff| + feature} + Join the current window in the group of windows that shows differences + between files. See |vimdiff|. + + *'dex'* *'diffexpr'* +'diffexpr' 'dex' string (default "") + global + {not in Vi} + {not available when compiled without the |+diff| + feature} + Expression which is evaluated to obtain an ed-style diff file from two + versions of a file. See |diff-diffexpr|. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'dip'* *'diffopt'* +'diffopt' 'dip' string (default "filler") + global + {not in Vi} + {not available when compiled without the |+diff| + feature} + Option settings for diff mode. It can consist of the following items. + All are optional. Items must be separated by a comma. + + filler Show filler lines, to keep the text + synchronized with a window that has inserted + lines at the same position. Mostly useful + when windows are side-by-side and 'scrollbind' + is set. + + context:{n} Use a context of {n} lines between a change + and a fold that contains unchanged lines. + When omitted a context of six lines is used. + See |fold-diff|. + + icase Ignore changes in case of text. "a" and "A" + are considered the same. Adds the "-i" flag + to the "diff" command if 'diffexpr' is empty. + + iwhite Ignore changes in amount of white space. Adds + the "-b" flag to the "diff" command if + 'diffexpr' is empty. Check the documentation + of the "diff" command for what this does + exactly. It should ignore adding trailing + white space, but not leading white space. + + horizontal Start diff mode with horizontal splits (unless + explicitly specified otherwise). + + vertical Start diff mode with vertical splits (unless + explicitly specified otherwise). + + foldcolumn:{n} Set the 'foldcolumn' option to {n} when + starting diff mode. Without this 2 is used. + + Examples: > + + :set diffopt=filler,context:4 + :set diffopt= + :set diffopt=filler,foldcolumn:3 +< + *'digraph'* *'dg'* *'nodigraph'* *'nodg'* +'digraph' 'dg' boolean (default off) + global + {not in Vi} + {not available when compiled without the |+digraphs| + feature} + Enable the entering of digraphs in Insert mode with {char1} + {char2}. See |digraphs|. + NOTE: This option is reset when 'compatible' is set. + + *'directory'* *'dir'* +'directory' 'dir' string (default for Amiga: ".,t:", + for MS-DOS and Win32: ".,c:\tmp,c:\temp" + for Unix: ".,~/tmp,/var/tmp,/tmp") + global + List of directory names for the swap file, separated with commas. + - The swap file will be created in the first directory where this is + possible. + - Empty means that no swap file will be used (recovery is + impossible!). + - A directory "." means to put the swap file in the same directory as + the edited file. On Unix, a dot is prepended to the file name, so + it doesn't show in a directory listing. On MS-Windows the "hidden" + attribute is set and a dot prepended if possible. + - A directory starting with "./" (or ".\" for MS-DOS et al.) means to + put the swap file relative to where the edited file is. The leading + "." is replaced with the path name of the edited file. + - For Unix and Win32, if a directory ends in two path separators "//" + or "\\", the swap file name will be built from the complete path to + the file with all path separators substituted to percent '%' signs. + This will ensure file name uniqueness in the preserve directory. + On Win32, when a separating comma is following, you must use "//", + since "\\" will include the comma in the file name. + - Spaces after the comma are ignored, other spaces are considered part + of the directory name. To have a space at the start of a directory + name, precede it with a backslash. + - To include a comma in a directory name precede it with a backslash. + - A directory name may end in an ':' or '/'. + - Environment variables are expanded |:set_env|. + - Careful with '\' characters, type one before a space, type two to + get one in the option (see |option-backslash|), for example: > + :set dir=c:\\tmp,\ dir\\,with\\,commas,\\\ dir\ with\ spaces +< - For backwards compatibility with Vim version 3.0 a '>' at the start + of the option is removed. + Using "." first in the list is recommended. This means that editing + the same file twice will result in a warning. Using "/tmp" on Unix is + discouraged: When the system crashes you lose the swap file. + "/var/tmp" is often not cleared when rebooting, thus is a better + choice than "/tmp". But it can contain a lot of files, your swap + files get lost in the crowd. That is why a "tmp" directory in your + home directory is tried first. + The use of |:set+=| and |:set-=| is preferred when adding or removing + directories from the list. This avoids problems when a future version + uses another default. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + {Vi: directory to put temp file in, defaults to "/tmp"} + + *'display'* *'dy'* +'display' 'dy' string (default "") + global + {not in Vi} + Change the way text is displayed. This is comma separated list of + flags: + lastline When included, as much as possible of the last line + in a window will be displayed. When not included, a + last line that doesn't fit is replaced with "@" lines. + uhex Show unprintable characters hexadecimal as + instead of using ^C and ~C. + + *'eadirection'* *'ead'* +'eadirection' 'ead' string (default "both") + global + {not in Vi} + {not available when compiled without the |+vertsplit| + feature} + Tells when the 'equalalways' option applies: + ver vertically, width of windows is not affected + hor horizontally, height of windows is not affected + both width and height of windows is affected + + *'ed'* *'edcompatible'* *'noed'* *'noedcompatible'* +'edcompatible' 'ed' boolean (default off) + global + Makes the 'g' and 'c' flags of the ":substitute" command to be + toggled each time the flag is given. See |complex-change|. See + also 'gdefault' option. + Switching this option on is discouraged! + + *'encoding'* *'enc'* *E543* +'encoding' 'enc' string (default: "latin1" or value from $LANG) + global + {only available when compiled with the |+multi_byte| + feature} + {not in Vi} + Sets the character encoding used inside Vim. It applies to text in + the buffers, registers, Strings in expressions, text stored in the + viminfo file, etc. It sets the kind of characters which Vim can work + with. See |encoding-names| for the possible values. + + NOTE: Changing this option will not change the encoding of the + existing text in Vim. It may cause non-ASCII text to become invalid. + It should normally be kept at its default value, or set when Vim + starts up. See |multibyte|. To reload the menus see |:menutrans|. + + This option cannot be set from a |modeline|. It would most likely + corrupt the text. + + NOTE: For GTK+ 2 it is highly recommended to set 'encoding' to + "utf-8". Although care has been taken to allow different values of + 'encoding', "utf-8" is the natural choice for the environment and + avoids unnecessary conversion overhead. "utf-8" has not been made + the default to prevent different behavior of the GUI and terminal + versions, and to avoid changing the encoding of newly created files + without your knowledge (in case 'fileencodings' is empty). + + The character encoding of files can be different from 'encoding'. + This is specified with 'fileencoding'. The conversion is done with + iconv() or as specified with 'charconvert'. + + If you need to know whether 'encoding' is a multi-byte encoding, you + can use: > + if has("multi_byte_encoding") +< + Normally 'encoding' will be equal to your current locale. This will + be the default if Vim recognizes your environment settings. If + 'encoding' is not set to the current locale, 'termencoding' must be + set to convert typed and displayed text. See |encoding-table|. + + When you set this option, it fires the |EncodingChanged| autocommand + event so that you can set up fonts if necessary. + + When the option is set, the value is converted to lowercase. Thus + you can set it with uppercase values too. Underscores are translated + to '-' signs. + When the encoding is recognized, it is changed to the standard name. + For example "Latin-1" becomes "latin1", "ISO_88592" becomes + "iso-8859-2" and "utf8" becomes "utf-8". + + Note: "latin1" is also used when the encoding could not be detected. + This only works when editing files in the same encoding! When the + actual character set is not latin1, make sure 'fileencoding' and + 'fileencodings' are empty. When conversion is needed, switch to using + utf-8. + + When "unicode", "ucs-2" or "ucs-4" is used, Vim internally uses utf-8. + You don't notice this while editing, but it does matter for the + |viminfo-file|. And Vim expects the terminal to use utf-8 too. Thus + setting 'encoding' to one of these values instead of utf-8 only has + effect for encoding used for files when 'fileencoding' is empty. + + When 'encoding' is set to a Unicode encoding, and 'fileencodings' was + not set yet, the default for 'fileencodings' is changed. + + *'endofline'* *'eol'* *'noendofline'* *'noeol'* +'endofline' 'eol' boolean (default on) + local to buffer + {not in Vi} + When writing a file and this option is off and the 'binary' option + is on, no will be written for the last line in the file. This + option is automatically set when starting to edit a new file, unless + the file does not have an for the last line in the file, in + which case it is reset. Normally you don't have to set or reset this + option. When 'binary' is off the value is not used when writing the + file. When 'binary' is on it is used to remember the presence of a + for the last line in the file, so that when you write the file + the situation from the original file can be kept. But you can change + it if you want to. + + *'equalalways'* *'ea'* *'noequalalways'* *'noea'* +'equalalways' 'ea' boolean (default on) + global + {not in Vi} + When on, all the windows are automatically made the same size after + splitting or closing a window. This also happens the moment the + option is switched on. When off, splitting a window will reduce the + size of the current window and leave the other windows the same. When + closing a window the extra lines are given to the window next to it + (depending on 'splitbelow' and 'splitright'). + When mixing vertically and horizontally split windows, a minimal size + is computed and some windows may be larger if there is room. The + 'eadirection' option tells in which direction the size is affected. + Changing the height and width of a window can be avoided by setting + 'winfixheight' and 'winfixwidth', respectively. + If a window size is specified when creating a new window sizes are + currently not equalized (it's complicated, but may be implemented in + the future). + + *'equalprg'* *'ep'* +'equalprg' 'ep' string (default "") + global or local to buffer |global-local| + {not in Vi} + External program to use for "=" command. When this option is empty + the internal formatting functions are used; either 'lisp', 'cindent' + or 'indentexpr'. When Vim was compiled without internal formatting, + the "indent" program is used. + Environment variables are expanded |:set_env|. See |option-backslash| + about including spaces and backslashes. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'errorbells'* *'eb'* *'noerrorbells'* *'noeb'* +'errorbells' 'eb' boolean (default off) + global + Ring the bell (beep or screen flash) for error messages. This only + makes a difference for error messages, the bell will be used always + for a lot of errors without a message (e.g., hitting in Normal + mode). See 'visualbell' on how to make the bell behave like a beep, + screen flash or do nothing. + + *'errorfile'* *'ef'* +'errorfile' 'ef' string (Amiga default: "AztecC.Err", + others: "errors.err") + global + {not in Vi} + {not available when compiled without the |+quickfix| + feature} + Name of the errorfile for the QuickFix mode (see |:cf|). + When the "-q" command-line argument is used, 'errorfile' is set to the + following argument. See |-q|. + NOT used for the ":make" command. See 'makeef' for that. + Environment variables are expanded |:set_env|. + See |option-backslash| about including spaces and backslashes. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'errorformat'* *'efm'* +'errorformat' 'efm' string (default is very long) + global or local to buffer |global-local| + {not in Vi} + {not available when compiled without the |+quickfix| + feature} + Scanf-like description of the format for the lines in the error file + (see |errorformat|). + + *'esckeys'* *'ek'* *'noesckeys'* *'noek'* +'esckeys' 'ek' boolean (Vim default: on, Vi default: off) + global + {not in Vi} + Function keys that start with an are recognized in Insert + mode. When this option is off, the cursor and function keys cannot be + used in Insert mode if they start with an . The advantage of + this is that the single is recognized immediately, instead of + after one second. Instead of resetting this option, you might want to + try changing the values for 'timeoutlen' and 'ttimeoutlen'. Note that + when 'esckeys' is off, you can still map anything, but the cursor keys + won't work by default. + NOTE: This option is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + + *'eventignore'* *'ei'* +'eventignore' 'ei' string (default "") + global + {not in Vi} + {not available when compiled without the |+autocmd| + feature} + A list of autocommand event names, which are to be ignored. + When set to "all" or when "all" is one of the items, all autocommand + events are ignored, autocommands will not be executed. + Otherwise this is a comma separated list of event names. Example: > + :set ei=WinEnter,WinLeave +< + *'expandtab'* *'et'* *'noexpandtab'* *'noet'* +'expandtab' 'et' boolean (default off) + local to buffer + {not in Vi} + In Insert mode: Use the appropriate number of spaces to insert a + . Spaces are used in indents with the '>' and '<' commands and + when 'autoindent' is on. To insert a real tab when 'expandtab' is + on, use CTRL-V. See also |:retab| and |ins-expandtab|. + NOTE: This option is reset when 'compatible' is set. + + *'exrc'* *'ex'* *'noexrc'* *'noex'* +'exrc' 'ex' boolean (default off) + global + {not in Vi} + Enables the reading of .vimrc, .exrc and .gvimrc in the current + directory. If you switch this option on you should also consider + setting the 'secure' option (see |initialization|). Using a local + .exrc, .vimrc or .gvimrc is a potential security leak, use with care! + also see |.vimrc| and |gui-init|. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'fileencoding'* *'fenc'* *E213* +'fileencoding' 'fenc' string (default: "") + local to buffer + {only available when compiled with the |+multi_byte| + feature} + {not in Vi} + Sets the character encoding for the file of this buffer. + + When 'fileencoding' is different from 'encoding', conversion will be + done when writing the file. For reading see below. + When 'fileencoding' is empty, the same value as 'encoding' will be + used (no conversion when reading or writing a file). + Conversion will also be done when 'encoding' and 'fileencoding' are + both a Unicode encoding and 'fileencoding' is not utf-8. That's + because internally Unicode is always stored as utf-8. + WARNING: Conversion can cause loss of information! When + 'encoding' is "utf-8" or another Unicode encoding, conversion + is most likely done in a way that the reverse conversion + results in the same text. When 'encoding' is not "utf-8" some + characters may be lost! + + See 'encoding' for the possible values. Additionally, values may be + specified that can be handled by the converter, see + |mbyte-conversion|. + + When reading a file 'fileencoding' will be set from 'fileencodings'. + To read a file in a certain encoding it won't work by setting + 'fileencoding', use the |++enc| argument. One exception: when + 'fileencodings' is empty the value of 'fileencoding' is used. + For a new file the global value of 'fileencoding' is used. + + Prepending "8bit-" and "2byte-" has no meaning here, they are ignored. + When the option is set, the value is converted to lowercase. Thus + you can set it with uppercase values too. '_' characters are + replaced with '-'. If a name is recognized from the list for + 'encoding', it is replaced by the standard name. For example + "ISO8859-2" becomes "iso-8859-2". + + When this option is set, after starting to edit a file, the 'modified' + option is set, because the file would be different when written. + + Keep in mind that changing 'fenc' from a modeline happens + AFTER the text has been read, thus it applies to when the file will be + written. If you do set 'fenc' in a modeline, you might want to set + 'nomodified' to avoid not being able to ":q". + + This option can not be changed when 'modifiable' is off. + + *'fe'* + NOTE: Before version 6.0 this option specified the encoding for the + whole of Vim, this was a mistake. Now use 'encoding' instead. The + old short name was 'fe', which is no longer used. + + *'fileencodings'* *'fencs'* +'fileencodings' 'fencs' string (default: "ucs-bom", + "ucs-bom,utf-8,default,latin1" when + 'encoding' is set to a Unicode value) + global + {only available when compiled with the |+multi_byte| + feature} + {not in Vi} + This is a list of character encodings considered when starting to edit + an existing file. When a file is read, Vim tries to use the first + mentioned character encoding. If an error is detected, the next one + in the list is tried. When an encoding is found that works, + 'fileencoding' is set to it. If all fail, 'fileencoding' is set to + an empty string, which means the value of 'encoding' is used. + WARNING: Conversion can cause loss of information! When + 'encoding' is "utf-8" (or one of the other Unicode variants) + conversion is most likely done in a way that the reverse + conversion results in the same text. When 'encoding' is not + "utf-8" some non-ASCII characters may be lost! You can use + the |++bad| argument to specify what is done with characters + that can't be converted. + For an empty file or a file with only ASCII characters most encodings + will work and the first entry of 'fileencodings' will be used (except + "ucs-bom", which requires the BOM to be present). If you prefer + another encoding use an BufReadPost autocommand event to test if your + preferred encoding is to be used. Example: > + au BufReadPost * if search('\S', 'w') == 0 | + \ set fenc=iso-2022-jp | endif +< This sets 'fileencoding' to "iso-2022-jp" if the file does not contain + non-blank characters. + When the |++enc| argument is used then the value of 'fileencodings' is + not used. + Note that 'fileencodings' is not used for a new file, the global value + of 'fileencoding' is used instead. You can set it with: > + :setglobal fenc=iso-8859-2 +< This means that a non-existing file may get a different encoding than + an empty file. + The special value "ucs-bom" can be used to check for a Unicode BOM + (Byte Order Mark) at the start of the file. It must not be preceded + by "utf-8" or another Unicode encoding for this to work properly. + An entry for an 8-bit encoding (e.g., "latin1") should be the last, + because Vim cannot detect an error, thus the encoding is always + accepted. + The special value "default" can be used for the encoding from the + environment. This is the default value for 'encoding'. It is useful + when 'encoding' is set to "utf-8" and your environment uses a + non-latin1 encoding, such as Russian. + When 'encoding' is "utf-8" and a file contains an illegal byte + sequence it won't be recognized as UTF-8. You can use the |8g8| + command to find the illegal byte sequence. + WRONG VALUES: WHAT'S WRONG: + latin1,utf-8 "latin1" will always be used + utf-8,ucs-bom,latin1 BOM won't be recognized in an utf-8 + file + cp1250,latin1 "cp1250" will always be used + If 'fileencodings' is empty, 'fileencoding' is not modified. + See 'fileencoding' for the possible values. + Setting this option does not have an effect until the next time a file + is read. + + *'fileformat'* *'ff'* +'fileformat' 'ff' string (MS-DOS, MS-Windows, OS/2 default: "dos", + Unix default: "unix", + Macintosh default: "mac") + local to buffer + {not in Vi} + This gives the of the current buffer, which is used for + reading/writing the buffer from/to a file: + dos + unix + mac + When "dos" is used, CTRL-Z at the end of a file is ignored. + See |file-formats| and |file-read|. + For the character encoding of the file see 'fileencoding'. + When 'binary' is set, the value of 'fileformat' is ignored, file I/O + works like it was set to "unix'. + This option is set automatically when starting to edit a file and + 'fileformats' is not empty and 'binary' is off. + When this option is set, after starting to edit a file, the 'modified' + option is set, because the file would be different when written. + This option can not be changed when 'modifiable' is off. + For backwards compatibility: When this option is set to "dos", + 'textmode' is set, otherwise 'textmode' is reset. + + *'fileformats'* *'ffs'* +'fileformats' 'ffs' string (default: + Vim+Vi MS-DOS, MS-Windows OS/2: "dos,unix", + Vim Unix: "unix,dos", + Vim Mac: "mac,unix,dos", + Vi Cygwin: "unix,dos", + Vi others: "") + global + {not in Vi} + This gives the end-of-line () formats that will be tried when + starting to edit a new buffer and when reading a file into an existing + buffer: + - When empty, the format defined with 'fileformat' will be used + always. It is not set automatically. + - When set to one name, that format will be used whenever a new buffer + is opened. 'fileformat' is set accordingly for that buffer. The + 'fileformats' name will be used when a file is read into an existing + buffer, no matter what 'fileformat' for that buffer is set to. + - When more than one name is present, separated by commas, automatic + detection will be done when reading a file. When starting to + edit a file, a check is done for the : + 1. If all lines end in , and 'fileformats' includes "dos", + 'fileformat' is set to "dos". + 2. If a is found and 'fileformats' includes "unix", 'fileformat' + is set to "unix". Note that when a is found without a + preceding , "unix" is preferred over "dos". + 3. If 'fileformats' includes "mac", 'fileformat' is set to "mac". + This means that "mac" is only chosen when "unix" is not present, + or when no is found in the file, and when "dos" is not + present, or no is present in the file. + Also if "unix" was first chosen, but the first is before + the first and there appears to be more 's than 's in + the file, then 'fileformat' is set to "mac". + 4. If 'fileformat' is still not set, the first name from + 'fileformats' is used. + When reading a file into an existing buffer, the same is done, but + this happens like 'fileformat' has been set appropriately for that + file only, the option is not changed. + When 'binary' is set, the value of 'fileformats' is not used. + + For systems with a Dos-like (), when reading files that + are ":source"ed and for vimrc files, automatic detection may be + done: + - When 'fileformats' is empty, there is no automatic detection. Dos + format will be used. + - When 'fileformats' is set to one or more names, automatic detection + is done. This is based on the first in the file: If there is a + in front of it, Dos format is used, otherwise Unix format is + used. + Also see |file-formats|. + For backwards compatibility: When this option is set to an empty + string or one format (no comma is included), 'textauto' is reset, + otherwise 'textauto' is set. + NOTE: This option is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + + *'filetype'* *'ft'* +'filetype' 'ft' string (default: "") + local to buffer + {not in Vi} + {not available when compiled without the |+autocmd| + feature} + When this option is set, the FileType autocommand event is triggered. + All autocommands that match with the value of this option will be + executed. Thus the value of 'filetype' is used in place of the file + name. + Otherwise this option does not always reflect the current file type. + This option is normally set when the file type is detected. To enable + this use the ":filetype on" command. |:filetype| + Setting this option to a different value is most useful in a modeline, + for a file for which the file type is not automatically recognized. + Example, for in an IDL file: + /* vim: set filetype=idl : */ ~ + |FileType| |filetypes| + When a dot appears in the value then this separates two filetype + names. Example: + /* vim: set filetype=c.doxygen : */ ~ + This will use the "c" filetype first, then the "doxygen" filetype. + This works both for filetype plugins and for syntax files. More than + one dot may appear. + Do not confuse this option with 'osfiletype', which is for the file + type that is actually stored with the file. + This option is not copied to another buffer, independent of the 's' or + 'S' flag in 'cpoptions'. + Only normal file name characters can be used, "/\*?[|<>" are illegal. + + *'fillchars'* *'fcs'* +'fillchars' 'fcs' string (default "vert:|,fold:-") + global + {not in Vi} + {not available when compiled without the |+windows| + and |+folding| features} + Characters to fill the statuslines and vertical separators. + It is a comma separated list of items: + + item default Used for ~ + stl:c ' ' or '^' statusline of the current window + stlnc:c ' ' or '-' statusline of the non-current windows + vert:c '|' vertical separators |:vsplit| + fold:c '-' filling 'foldtext' + diff:c '-' deleted lines of the 'diff' option + + Any one that is omitted will fall back to the default. For "stl" and + "stlnc" the space will be used when there is highlighting, '^' or '-' + otherwise. + + Example: > + :set fillchars=stl:^,stlnc:-,vert:\|,fold:-,diff:- +< This is similar to the default, except that these characters will also + be used when there is highlighting. + + for "stl" and "stlnc" only single-byte values are supported. + + The highlighting used for these items: + item highlight group ~ + stl:c StatusLine |hl-StatusLine| + stlnc:c StatusLineNC |hl-StatusLineNC| + vert:c VertSplit |hl-VertSplit| + fold:c Folded |hl-Folded| + diff:c DiffDelete |hl-DiffDelete| + + *'fkmap'* *'fk'* *'nofkmap'* *'nofk'* +'fkmap' 'fk' boolean (default off) *E198* + global + {not in Vi} + {only available when compiled with the |+rightleft| + feature} + When on, the keyboard is mapped for the Farsi character set. + Normally you would set 'allowrevins' and use CTRL-_ in insert mode to + toggle this option |i_CTRL-_|. See |farsi.txt|. + + *'foldclose'* *'fcl'* +'foldclose' 'fcl' string (default "") + global + {not in Vi} + {not available when compiled without the |+folding| + feature} + When set to "all", a fold is closed when the cursor isn't in it and + its level is higher than 'foldlevel'. Useful if you want folds to + automatically close when moving out of them. + + *'foldcolumn'* *'fdc'* +'foldcolumn' 'fdc' number (default 0) + local to window + {not in Vi} + {not available when compiled without the |+folding| + feature} + When non-zero, a column with the specified width is shown at the side + of the window which indicates open and closed folds. The maximum + value is 12. + See |folding|. + + *'foldenable'* *'fen'* *'nofoldenable'* *'nofen'* +'foldenable' 'fen' boolean (default on) + local to window + {not in Vi} + {not available when compiled without the |+folding| + feature} + When off, all folds are open. This option can be used to quickly + switch between showing all text unfolded and viewing the text with + folds (including manually opened or closed folds). It can be toggled + with the |zi| command. The 'foldcolumn' will remain blank when + 'foldenable' is off. + This option is set by commands that create a new fold or close a fold. + See |folding|. + + *'foldexpr'* *'fde'* +'foldexpr' 'fde' string (default: "0") + local to window + {not in Vi} + {not available when compiled without the |+folding| + or |+eval| features} + The expression used for when 'foldmethod' is "expr". It is evaluated + for each line to obtain its fold level. See |fold-expr|. + + The expression may be evaluated in the |sandbox|, see + |sandbox-option|. + This option can't be set from a |modeline| when the 'diff' option is + on. + + It is not allowed to change text or jump to another window while + evaluating 'foldexpr' |textlock|. + + *'foldignore'* *'fdi'* +'foldignore' 'fdi' string (default: "#") + local to window + {not in Vi} + {not available when compiled without the |+folding| + feature} + Used only when 'foldmethod' is "indent". Lines starting with + characters in 'foldignore' will get their fold level from surrounding + lines. White space is skipped before checking for this character. + The default "#" works well for C programs. See |fold-indent|. + + *'foldlevel'* *'fdl'* +'foldlevel' 'fdl' number (default: 0) + local to window + {not in Vi} + {not available when compiled without the |+folding| + feature} + Sets the fold level: Folds with a higher level will be closed. + Setting this option to zero will close all folds. Higher numbers will + close fewer folds. + This option is set by commands like |zm|, |zM| and |zR|. + See |fold-foldlevel|. + + *'foldlevelstart'* *'fdls'* +'foldlevelstart' 'fdls' number (default: -1) + global + {not in Vi} + {not available when compiled without the |+folding| + feature} + Sets 'foldlevel' when starting to edit another buffer in a window. + Useful to always start editing with all folds closed (value zero), + some folds closed (one) or no folds closed (99). + This is done before reading any modeline, thus a setting in a modeline + overrules this option. Starting to edit a file for |diff-mode| also + ignores this option and closes all folds. + It is also done before BufReadPre autocommands, to allow an autocmd to + overrule the 'foldlevel' value for specific files. + When the value is negative, it is not used. + + *'foldmarker'* *'fmr'* *E536* +'foldmarker' 'fmr' string (default: "{{{,}}}") + local to window + {not in Vi} + {not available when compiled without the |+folding| + feature} + The start and end marker used when 'foldmethod' is "marker". There + must be one comma, which separates the start and end marker. The + marker is a literal string (a regular expression would be too slow). + See |fold-marker|. + + *'foldmethod'* *'fdm'* +'foldmethod' 'fdm' string (default: "manual") + local to window + {not in Vi} + {not available when compiled without the |+folding| + feature} + The kind of folding used for the current window. Possible values: + |fold-manual| manual Folds are created manually. + |fold-indent| indent Lines with equal indent form a fold. + |fold-expr| expr 'foldexpr' gives the fold level of a line. + |fold-marker| marker Markers are used to specify folds. + |fold-syntax| syntax Syntax highlighting items specify folds. + |fold-diff| diff Fold text that is not changed. + + *'foldminlines'* *'fml'* +'foldminlines' 'fml' number (default: 1) + local to window + {not in Vi} + {not available when compiled without the |+folding| + feature} + Sets the minimum number of screen lines for a fold to be displayed + closed. Also for manually closed folds. + Note that this only has an effect of what is displayed. After using + "zc" to close a fold, which is displayed open because it's smaller + than 'foldminlines', a following "zc" may close a containing fold. + + *'foldnestmax'* *'fdn'* +'foldnestmax' 'fdn' number (default: 20) + local to window + {not in Vi} + {not available when compiled without the |+folding| + feature} + Sets the maximum nesting of folds for the "indent" and "syntax" + methods. This avoids that too many folds will be created. Using more + than 20 doesn't work, because the internal limit is 20. + + *'foldopen'* *'fdo'* +'foldopen' 'fdo' string (default: "block,hor,mark,percent,quickfix, + search,tag,undo") + global + {not in Vi} + {not available when compiled without the |+folding| + feature} + Specifies for which type of commands folds will be opened, if the + command moves the cursor into a closed fold. It is a comma separated + list of items. + item commands ~ + all any + block "(", "{", "[[", "[{", etc. + hor horizontal movements: "l", "w", "fx", etc. + insert any command in Insert mode + jump far jumps: "G", "gg", etc. + mark jumping to a mark: "'m", CTRL-O, etc. + percent "%" + quickfix ":cn", ":crew", ":make", etc. + search search for a pattern: "/", "n", "*", "gd", etc. + (not for a search pattern in a ":" command) + Also for |[s| and |]s|. + tag jumping to a tag: ":ta", CTRL-T, etc. + undo undo or redo: "u" and CTRL-R + When the command is part of a mapping this option is not used. Add + the |zv| command to the mapping to get the same effect. + When a movement command is used for an operator (e.g., "dl" or "y%") + this option is not used. This means the operator will include the + whole closed fold. + Note that vertical movements are not here, because it would make it + very difficult to move onto a closed fold. + In insert mode the folds containing the cursor will always be open + when text is inserted. + To close folds you can re-apply 'foldlevel' with the |zx| command or + set the 'foldclose' option to "all". + + *'foldtext'* *'fdt'* +'foldtext' 'fdt' string (default: "foldtext()") + local to window + {not in Vi} + {not available when compiled without the |+folding| + feature} + An expression which is used to specify the text displayed for a closed + fold. See |fold-foldtext|. + + The expression may be evaluated in the |sandbox|, see + |sandbox-option|. + + It is not allowed to change text or jump to another window while + evaluating 'foldtext' |textlock|. + + *'formatoptions'* *'fo'* +'formatoptions' 'fo' string (Vim default: "tcq", Vi default: "vt") + local to buffer + {not in Vi} + This is a sequence of letters which describes how automatic + formatting is to be done. See |fo-table|. When the 'paste' option is + on, no formatting is done (like 'formatoptions' is empty). Commas can + be inserted for readability. + To avoid problems with flags that are added in the future, use the + "+=" and "-=" feature of ":set" |add-option-flags|. + NOTE: This option is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + + *'formatlistpat'* *'flp'* +'formatlistpat' 'flp' string (default: "^\s*\d\+[\]:.)}\t ]\s*") + local to buffer + {not in Vi} + A pattern that is used to recognize a list header. This is used for + the "n" flag in 'formatoptions'. + The pattern must match exactly the text that will be the indent for + the line below it. You can use |/\ze| to mark the end of the match + while still checking more characters. There must be a character + following the pattern, when it matches the whole line it is handled + like there is no match. + The default recognizes a number, followed by an optional punctuation + character and white space. + + *'formatprg'* *'fp'* +'formatprg' 'fp' string (default "") + global + {not in Vi} + The name of an external program that will be used to format the lines + selected with the |gq| operator. The program must take the input on + stdin and produce the output on stdout. The Unix program "fmt" is + such a program. + If the 'formatexpr' option is not empty it will be used instead. + Otherwise, if 'formatprg' option is an empty string, the internal + format function will be used |C-indenting|. + Environment variables are expanded |:set_env|. See |option-backslash| + about including spaces and backslashes. + The expression may be evaluated in the |sandbox|, see + |sandbox-option|. + + *'formatexpr'* *'fex'* +'formatexpr' 'fex' string (default "") + local to buffer + {not in Vi} + {not available when compiled without the |+eval| + feature} + Expression which is evaluated to format a range of lines for the |gq| + operator or automatic formatting (see 'formatoptions'). When this + option is empty 'formatprg' is used. + + The |v:lnum| variable holds the first line to be formatted. + The |v:count| variable holds the number of lines to be formatted. + The |v:char| variable holds the character that is going to be + inserted if the expression is being evaluated due to + automatic formatting. This can be empty. Don't insert + it yet! + + Example: > + :set formatexpr=mylang#Format() +< This will invoke the mylang#Format() function in the + autoload/mylang.vim file in 'runtimepath'. |autoload| + + The expression is also evaluated when 'textwidth' is set and adding + text beyond that limit. This happens under the same conditions as + when internal formatting is used. Make sure the cursor is kept in the + same spot relative to the text then! The |mode()| function will + return "i" or "R" in this situation. + + When the expression evaluates to non-zero Vim will fall back to using + the internal format mechanism. + + The expression may be evaluated in the |sandbox|, see + |sandbox-option|. + + *'fsync'* *'fs'* +'fsync' 'fs' boolean (default on) + global + {not in Vi} + When on, the library function fsync() will be called after writing a + file. This will flush a file to disk, ensuring that it is safely + written even on filesystems which do metadata-only journaling. This + will force the harddrive to spin up on Linux systems running in laptop + mode, so it may be undesirable in some situations. Be warned that + turning this off increases the chances of data loss after a crash. On + systems without an fsync() implementation, this variable is always + off. + Also see 'swapsync' for controlling fsync() on swap files. + + *'gdefault'* *'gd'* *'nogdefault'* *'nogd'* +'gdefault' 'gd' boolean (default off) + global + {not in Vi} + When on, the ":substitute" flag 'g' is default on. This means that + all matches in a line are substituted instead of one. When a 'g' flag + is given to a ":substitute" command, this will toggle the substitution + of all or one match. See |complex-change|. + + command 'gdefault' on 'gdefault' off ~ + :s/// subst. all subst. one + :s///g subst. one subst. all + :s///gg subst. all subst. one + + NOTE: This option is reset when 'compatible' is set. + + *'grepformat'* *'gfm'* +'grepformat' 'gfm' string (default "%f:%l%m,%f %l%m") + global + {not in Vi} + Format to recognize for the ":grep" command output. + This is a scanf-like string that uses the same format as the + 'errorformat' option: see |errorformat|. + + *'grepprg'* *'gp'* +'grepprg' 'gp' string (default "grep -n ", + Unix: "grep -n $* /dev/null", + Win32: "findstr /n" or "grep -n", + VMS: "SEARCH/NUMBERS ") + global or local to buffer |global-local| + {not in Vi} + Program to use for the |:grep| command. This option may contain '%' + and '#' characters, which are expanded like when used in a command- + line. The placeholder "$*" is allowed to specify where the arguments + will be included. Environment variables are expanded |:set_env|. See + |option-backslash| about including spaces and backslashes. + When your "grep" accepts the "-H" argument, use this to make ":grep" + also work well with a single file: > + :set grepprg=grep\ -nH +< Special value: When 'grepprg' is set to "internal" the |:grep| command + works like |:vimgrep|, |:lgrep| like |:lvimgrep|, |:grepadd| like + |:vimgrepadd| and |:lgrepadd| like |:lvimgrepadd|. + See also the section |:make_makeprg|, since most of the comments there + apply equally to 'grepprg'. + For Win32, the default is "findstr /n" if "findstr.exe" can be found, + otherwise it's "grep -n". + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'guicursor'* *'gcr'* *E545* *E546* *E548* *E549* +'guicursor' 'gcr' string (default "n-v-c:block-Cursor/lCursor, + ve:ver35-Cursor, + o:hor50-Cursor, + i-ci:ver25-Cursor/lCursor, + r-cr:hor20-Cursor/lCursor, + sm:block-Cursor + -blinkwait175-blinkoff150-blinkon175", + for MS-DOS and Win32 console: + "n-v-c:block,o:hor50,i-ci:hor15, + r-cr:hor30,sm:block") + global + {not in Vi} + {only available when compiled with GUI enabled, and + for MS-DOS and Win32 console} + This option tells Vim what the cursor should look like in different + modes. It fully works in the GUI. In an MSDOS or Win32 console, only + the height of the cursor can be changed. This can be done by + specifying a block cursor, or a percentage for a vertical or + horizontal cursor. + For a console the 't_SI' and 't_EI' escape sequences are used. + + The option is a comma separated list of parts. Each part consist of a + mode-list and an argument-list: + mode-list:argument-list,mode-list:argument-list,.. + The mode-list is a dash separated list of these modes: + n Normal mode + v Visual mode + ve Visual mode with 'selection' "exclusive" (same as 'v', + if not specified) + o Operator-pending mode + i Insert mode + r Replace mode + c Command-line Normal (append) mode + ci Command-line Insert mode + cr Command-line Replace mode + sm showmatch in Insert mode + a all modes + The argument-list is a dash separated list of these arguments: + hor{N} horizontal bar, {N} percent of the character height + ver{N} vertical bar, {N} percent of the character width + block block cursor, fills the whole character + [only one of the above three should be present] + blinkwait{N} *cursor-blinking* + blinkon{N} + blinkoff{N} + blink times for cursor: blinkwait is the delay before + the cursor starts blinking, blinkon is the time that + the cursor is shown and blinkoff is the time that the + cursor is not shown. The times are in msec. When one + of the numbers is zero, there is no blinking. The + default is: "blinkwait700-blinkon400-blinkoff250". + These numbers are used for a missing entry. This + means that blinking is enabled by default. To switch + blinking off you can use "blinkon0". The cursor only + blinks when Vim is waiting for input, not while + executing a command. + To make the cursor blink in an xterm, see + |xterm-blink|. + {group-name} + a highlight group name, that sets the color and font + for the cursor + {group-name}/{group-name} + Two highlight group names, the first is used when + no language mappings are used, the other when they + are. |language-mapping| + + Examples of parts: + n-c-v:block-nCursor in Normal, Command-line and Visual mode, use a + block cursor with colors from the "nCursor" + highlight group + i-ci:ver30-iCursor-blinkwait300-blinkon200-blinkoff150 + In Insert and Command-line Insert mode, use a + 30% vertical bar cursor with colors from the + "iCursor" highlight group. Blink a bit + faster. + + The 'a' mode is different. It will set the given argument-list for + all modes. It does not reset anything to defaults. This can be used + to do a common setting for all modes. For example, to switch off + blinking: "a:blinkon0" + + Examples of cursor highlighting: > + :highlight Cursor gui=reverse guifg=NONE guibg=NONE + :highlight Cursor gui=NONE guifg=bg guibg=fg +< + *'guifont'* *'gfn'* + *E235* *E596* *E610* *E611* +'guifont' 'gfn' string (default "") + global + {not in Vi} + {only available when compiled with GUI enabled} + This is a list of fonts which will be used for the GUI version of Vim. + In its simplest form the value is just one font name. When + the font cannot be found you will get an error message. To try other + font names a list can be specified, font names separated with commas. + The first valid font is used. + + On systems where 'guifontset' is supported (X11) and 'guifontset' is + not empty, then 'guifont' is not used. + + Spaces after a comma are ignored. To include a comma in a font name + precede it with a backslash. Setting an option requires an extra + backslash before a space and a backslash. See also + |option-backslash|. For example: > + :set guifont=Screen15,\ 7x13,font\\,with\\,commas +< will make Vim try to use the font "Screen15" first, and if it fails it + will try to use "7x13" and then "font,with,commas" instead. + + If none of the fonts can be loaded, Vim will keep the current setting. + If an empty font list is given, Vim will try using other resource + settings (for X, it will use the Vim.font resource), and finally it + will try some builtin default which should always be there ("7x13" in + the case of X). The font names given should be "normal" fonts. Vim + will try to find the related bold and italic fonts. + + For Win32, GTK, Motif, Mac OS and Photon: > + :set guifont=* +< will bring up a font requester, where you can pick the font you want. + + The font name depends on the GUI used. See |setting-guifont| for a + way to set 'guifont' for various systems. + + For the GTK+ 2 GUI the font name looks like this: > + :set guifont=Andale\ Mono\ 11 +< That's all. XLFDs are not used. For Chinese this is reported to work + well: > + if has("gui_gtk2") + set guifont=Bitstream\ Vera\ Sans\ Mono\ 12,Fixed\ 12 + set guifontwide=Microsoft\ Yahei\ 12,WenQuanYi\ Zen\ Hei\ 12 + endif +< + For Mac OSX you can use something like this: > + :set guifont=Monaco:h10 +< Also see 'macatsui', it can help fix display problems. + *E236* + Note that the fonts must be mono-spaced (all characters have the same + width). An exception is GTK 2: all fonts are accepted, but + mono-spaced fonts look best. + + To preview a font on X11, you might be able to use the "xfontsel" + program. The "xlsfonts" program gives a list of all available fonts. + + For the Win32 GUI *E244* *E245* + - takes these options in the font name: + hXX - height is XX (points, can be floating-point) + wXX - width is XX (points, can be floating-point) + b - bold + i - italic + u - underline + s - strikeout + cXX - character set XX. Valid charsets are: ANSI, ARABIC, + BALTIC, CHINESEBIG5, DEFAULT, EASTEUROPE, GB2312, GREEK, + HANGEUL, HEBREW, JOHAB, MAC, OEM, RUSSIAN, SHIFTJIS, + SYMBOL, THAI, TURKISH, VIETNAMESE ANSI and BALTIC. + Normally you would use "cDEFAULT". + + Use a ':' to separate the options. + - A '_' can be used in the place of a space, so you don't need to use + backslashes to escape the spaces. + - Examples: > + :set guifont=courier_new:h12:w5:b:cRUSSIAN + :set guifont=Andale_Mono:h7.5:w4.5 +< See also |font-sizes|. + + *'guifontset'* *'gfs'* + *E250* *E252* *E234* *E597* *E598* +'guifontset' 'gfs' string (default "") + global + {not in Vi} + {only available when compiled with GUI enabled and + with the |+xfontset| feature} + {not available in the GTK+ 2 GUI} + When not empty, specifies two (or more) fonts to be used. The first + one for normal English, the second one for your special language. See + |xfontset|. + Setting this option also means that all font names will be handled as + a fontset name. Also the ones used for the "font" argument of the + |:highlight| command. + The fonts must match with the current locale. If fonts for the + character sets that the current locale uses are not included, setting + 'guifontset' will fail. + Note the difference between 'guifont' and 'guifontset': In 'guifont' + the comma-separated names are alternative names, one of which will be + used. In 'guifontset' the whole string is one fontset name, + including the commas. It is not possible to specify alternative + fontset names. + This example works on many X11 systems: > + :set guifontset=-*-*-medium-r-normal--16-*-*-*-c-*-*-* +< + *'guifontwide'* *'gfw'* *E231* *E533* *E534* +'guifontwide' 'gfw' string (default "") + global + {not in Vi} + {only available when compiled with GUI enabled} + When not empty, specifies a comma-separated list of fonts to be used + for double-width characters. The first font that can be loaded is + used. + Note: The size of these fonts must be exactly twice as wide as the one + specified with 'guifont' and the same height. + + All GUI versions but GTK+ 2: + + 'guifontwide' is only used when 'encoding' is set to "utf-8" and + 'guifontset' is empty or invalid. + When 'guifont' is set and a valid font is found in it and + 'guifontwide' is empty Vim will attempt to find a matching + double-width font and set 'guifontwide' to it. + + GTK+ 2 GUI only: *guifontwide_gtk2* + + If set and valid, 'guifontwide' is always used for double width + characters, even if 'encoding' is not set to "utf-8". + Vim does not attempt to find an appropriate value for 'guifontwide' + automatically. If 'guifontwide' is empty Pango/Xft will choose the + font for characters not available in 'guifont'. Thus you do not need + to set 'guifontwide' at all unless you want to override the choice + made by Pango/Xft. + + *'guiheadroom'* *'ghr'* +'guiheadroom' 'ghr' number (default 50) + global + {not in Vi} {only for GTK and X11 GUI} + The number of pixels subtracted from the screen height when fitting + the GUI window on the screen. Set this before the GUI is started, + e.g., in your |gvimrc| file. When zero, the whole screen height will + be used by the window. When positive, the specified number of pixel + lines will be left for window decorations and other items on the + screen. Set it to a negative value to allow windows taller than the + screen. + + *'guioptions'* *'go'* +'guioptions' 'go' string (default "gmrLtT" (MS-Windows), + "agimrLtT" (GTK, Motif and Athena)) + global + {not in Vi} + {only available when compiled with GUI enabled} + This option only has an effect in the GUI version of Vim. It is a + sequence of letters which describes what components and options of the + GUI should be used. + To avoid problems with flags that are added in the future, use the + "+=" and "-=" feature of ":set" |add-option-flags|. + + Valid letters are as follows: + *guioptions_a* *'go-a'* + 'a' Autoselect: If present, then whenever VISUAL mode is started, + or the Visual area extended, Vim tries to become the owner of + the windowing system's global selection. This means that the + Visually highlighted text is available for pasting into other + applications as well as into Vim itself. When the Visual mode + ends, possibly due to an operation on the text, or when an + application wants to paste the selection, the highlighted text + is automatically yanked into the "* selection register. + Thus the selection is still available for pasting into other + applications after the VISUAL mode has ended. + If not present, then Vim won't become the owner of the + windowing system's global selection unless explicitly told to + by a yank or delete operation for the "* register. + The same applies to the modeless selection. + *'go-A'* + 'A' Autoselect for the modeless selection. Like 'a', but only + applies to the modeless selection. + + 'guioptions' autoselect Visual autoselect modeless ~ + "" - - + "a" yes yes + "A" - yes + "aA" yes yes + + *'go-c'* + 'c' Use console dialogs instead of popup dialogs for simple + choices. + *'go-e'* + 'e' Add tab pages when indicated with 'showtabline'. + 'guitablabel' can be used to change the text in the labels. + When 'e' is missing a non-GUI tab pages line may be used. + The GUI tabs are only supported on some systems, currently + GTK, Motif, Mac OS/X and MS-Windows. + *'go-f'* + 'f' Foreground: Don't use fork() to detach the GUI from the shell + where it was started. Use this for programs that wait for the + editor to finish (e.g., an e-mail program). Alternatively you + can use "gvim -f" or ":gui -f" to start the GUI in the + foreground. |gui-fork| + Note: Set this option in the vimrc file. The forking may have + happened already when the |gvimrc| file is read. + *'go-i'* + 'i' Use a Vim icon. For GTK with KDE it is used in the left-upper + corner of the window. It's black&white on non-GTK, because of + limitations of X11. For a color icon, see |X11-icon|. + *'go-m'* + 'm' Menu bar is present. + *'go-M'* + 'M' The system menu "$VIMRUNTIME/menu.vim" is not sourced. Note + that this flag must be added in the .vimrc file, before + switching on syntax or filetype recognition (when the |gvimrc| + file is sourced the system menu has already been loaded; the + ":syntax on" and ":filetype on" commands load the menu too). + *'go-g'* + 'g' Grey menu items: Make menu items that are not active grey. If + 'g' is not included inactive menu items are not shown at all. + Exception: Athena will always use grey menu items. + *'go-t'* + 't' Include tearoff menu items. Currently only works for Win32, + GTK+, and Motif 1.2 GUI. + *'go-T'* + 'T' Include Toolbar. Currently only in Win32, GTK+, Motif, Photon + and Athena GUIs. + *'go-r'* + 'r' Right-hand scrollbar is always present. + *'go-R'* + 'R' Right-hand scrollbar is present when there is a vertically + split window. + *'go-l'* + 'l' Left-hand scrollbar is always present. + *'go-L'* + 'L' Left-hand scrollbar is present when there is a vertically + split window. + *'go-b'* + 'b' Bottom (horizontal) scrollbar is present. Its size depends on + the longest visible line, or on the cursor line if the 'h' + flag is included. |gui-horiz-scroll| + *'go-h'* + 'h' Limit horizontal scrollbar size to the length of the cursor + line. Reduces computations. |gui-horiz-scroll| + + And yes, you may even have scrollbars on the left AND the right if + you really want to :-). See |gui-scrollbars| for more information. + + *'go-v'* + 'v' Use a vertical button layout for dialogs. When not included, + a horizontal layout is preferred, but when it doesn't fit a + vertical layout is used anyway. + *'go-p'* + 'p' Use Pointer callbacks for X11 GUI. This is required for some + window managers. If the cursor is not blinking or hollow at + the right moment, try adding this flag. This must be done + before starting the GUI. Set it in your |gvimrc|. Adding or + removing it after the GUI has started has no effect. + *'go-F'* + 'F' Add a footer. Only for Motif. See |gui-footer|. + + + *'guipty'* *'noguipty'* +'guipty' boolean (default on) + global + {not in Vi} + {only available when compiled with GUI enabled} + Only in the GUI: If on, an attempt is made to open a pseudo-tty for + I/O to/from shell commands. See |gui-pty|. + + *'guitablabel'* *'gtl'* +'guitablabel' 'gtl' string (default empty) + global + {not in Vi} + {only available when compiled with GUI enabled and + with the |+windows| feature} + When nonempty describes the text to use in a label of the GUI tab + pages line. When empty and when the result is empty Vim will use a + default label. See |setting-guitablabel| for more info. + + The format of this option is like that of 'statusline'. + 'guitabtooltip' is used for the tooltip, see below. + + Only used when the GUI tab pages line is displayed. 'e' must be + present in 'guioptions'. For the non-GUI tab pages line 'tabline' is + used. + + *'guitabtooltip'* *'gtt'* +'guitabtooltip' 'gtt' string (default empty) + global + {not in Vi} + {only available when compiled with GUI enabled and + with the |+windows| feature} + When nonempty describes the text to use in a tooltip for the GUI tab + pages line. When empty Vim will use a default tooltip. + This option is otherwise just like 'guitablabel' above. + You can include a line break. Simplest method is to use |:let|: > + :let &guitabtooltip = "line one\nline two" +< + + *'helpfile'* *'hf'* +'helpfile' 'hf' string (default (MSDOS) "$VIMRUNTIME\doc\help.txt" + (others) "$VIMRUNTIME/doc/help.txt") + global + {not in Vi} + Name of the main help file. All distributed help files should be + placed together in one directory. Additionally, all "doc" directories + in 'runtimepath' will be used. + Environment variables are expanded |:set_env|. For example: + "$VIMRUNTIME/doc/help.txt". If $VIMRUNTIME is not set, $VIM is also + tried. Also see |$VIMRUNTIME| and |option-backslash| about including + spaces and backslashes. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'helpheight'* *'hh'* +'helpheight' 'hh' number (default 20) + global + {not in Vi} + {not available when compiled without the |+windows| + feature} + Minimal initial height of the help window when it is opened with the + ":help" command. The initial height of the help window is half of the + current window, or (when the 'ea' option is on) the same as other + windows. When the height is less than 'helpheight', the height is + set to 'helpheight'. Set to zero to disable. + + *'helplang'* *'hlg'* +'helplang' 'hlg' string (default: messages language or empty) + global + {only available when compiled with the |+multi_lang| + feature} + {not in Vi} + Comma separated list of languages. Vim will use the first language + for which the desired help can be found. The English help will always + be used as a last resort. You can add "en" to prefer English over + another language, but that will only find tags that exist in that + language and not in the English help. + Example: > + :set helplang=de,it +< This will first search German, then Italian and finally English help + files. + When using |CTRL-]| and ":help!" in a non-English help file Vim will + try to find the tag in the current language before using this option. + See |help-translated|. + + *'hidden'* *'hid'* *'nohidden'* *'nohid'* +'hidden' 'hid' boolean (default off) + global + {not in Vi} + When off a buffer is unloaded when it is |abandon|ed. When on a + buffer becomes hidden when it is |abandon|ed. If the buffer is still + displayed in another window, it does not become hidden, of course. + The commands that move through the buffer list sometimes make a buffer + hidden although the 'hidden' option is off: When the buffer is + modified, 'autowrite' is off or writing is not possible, and the '!' + flag was used. See also |windows.txt|. + To only make one buffer hidden use the 'bufhidden' option. + This option is set for one command with ":hide {command}" |:hide|. + WARNING: It's easy to forget that you have changes in hidden buffers. + Think twice when using ":q!" or ":qa!". + + *'highlight'* *'hl'* +'highlight' 'hl' string (default (as a single string): + "8:SpecialKey,@:NonText,d:Directory, + e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg, + M:ModeMsg,n:LineNr,r:Question, + s:StatusLine,S:StatusLineNC,c:VertSplit, + t:Title,v:Visual,w:WarningMsg,W:WildMenu, + f:Folded,F:FoldColumn,A:DiffAdd, + C:DiffChange,D:DiffDelete,T:DiffText, + >:SignColumn,B:SpellBad,P:SpellCap, + R:SpellRare,L:SpellLocal,-:Conceal, + +:Pmenu,=:PmenuSel, + x:PmenuSbar,X:PmenuThumb") + global + {not in Vi} + This option can be used to set highlighting mode for various + occasions. It is a comma separated list of character pairs. The + first character in a pair gives the occasion, the second the mode to + use for that occasion. The occasions are: + |hl-SpecialKey| 8 Meta and special keys listed with ":map" + |hl-NonText| @ '~' and '@' at the end of the window and + characters from 'showbreak' + |hl-Directory| d directories in CTRL-D listing and other special + things in listings + |hl-ErrorMsg| e error messages + h (obsolete, ignored) + |hl-IncSearch| i 'incsearch' highlighting + |hl-Search| l last search pattern highlighting (see 'hlsearch') + |hl-MoreMsg| m |more-prompt| + |hl-ModeMsg| M Mode (e.g., "-- INSERT --") + |hl-LineNr| n line number for ":number" and ":#" commands, and + when 'number' or 'relativenumber' option is set. + |hl-Question| r |hit-enter| prompt and yes/no questions + |hl-StatusLine| s status line of current window |status-line| + |hl-StatusLineNC| S status lines of not-current windows + |hl-Title| t Titles for output from ":set all", ":autocmd" etc. + |hl-VertSplit| c column used to separate vertically split windows + |hl-Visual| v Visual mode + |hl-VisualNOS| V Visual mode when Vim does is "Not Owning the + Selection" Only X11 Gui's |gui-x11| and + |xterm-clipboard|. + |hl-WarningMsg| w warning messages + |hl-WildMenu| W wildcard matches displayed for 'wildmenu' + |hl-Folded| f line used for closed folds + |hl-FoldColumn| F 'foldcolumn' + |hl-DiffAdd| A added line in diff mode + |hl-DiffChange| C changed line in diff mode + |hl-DiffDelete| D deleted line in diff mode + |hl-DiffText| T inserted text in diff mode + |hl-SignColumn| > column used for |signs| + |hl-SpellBad| B misspelled word |spell| + |hl-SpellCap| P word that should start with capital |spell| + |hl-SpellRare| R rare word |spell| + |hl-SpellLocal| L word from other region |spell| + |hl-Conceal| - the placeholders used for concealed characters + (see 'conceallevel') + |hl-Pmenu| + popup menu normal line + |hl-PmenuSel| = popup menu normal line + |hl-PmenuSbar| x popup menu scrollbar + |hl-PmenuThumb| X popup menu scrollbar thumb + + The display modes are: + r reverse (termcap entry "mr" and "me") + i italic (termcap entry "ZH" and "ZR") + b bold (termcap entry "md" and "me") + s standout (termcap entry "so" and "se") + u underline (termcap entry "us" and "ue") + c undercurl (termcap entry "Cs" and "Ce") + n no highlighting + - no highlighting + : use a highlight group + The default is used for occasions that are not included. + If you want to change what the display modes do, see |dos-colors| + for an example. + When using the ':' display mode, this must be followed by the name of + a highlight group. A highlight group can be used to define any type + of highlighting, including using color. See |:highlight| on how to + define one. The default uses a different group for each occasion. + See |highlight-default| for the default highlight groups. + + *'hlsearch'* *'hls'* *'nohlsearch'* *'nohls'* +'hlsearch' 'hls' boolean (default off) + global + {not in Vi} + {not available when compiled without the + |+extra_search| feature} + When there is a previous search pattern, highlight all its matches. + The type of highlighting used can be set with the 'l' occasion in the + 'highlight' option. This uses the "Search" highlight group by + default. Note that only the matching text is highlighted, any offsets + are not applied. + See also: 'incsearch' and |:match|. + When you get bored looking at the highlighted matches, you can turn it + off with |:nohlsearch|. As soon as you use a search command, the + highlighting comes back. + 'redrawtime' specifies the maximum time spent on finding matches. + When the search pattern can match an end-of-line, Vim will try to + highlight all of the matched text. However, this depends on where the + search starts. This will be the first line in the window or the first + line below a closed fold. A match in a previous line which is not + drawn may not continue in a newly drawn line. + NOTE: This option is reset when 'compatible' is set. + + *'history'* *'hi'* +'history' 'hi' number (Vim default: 20, Vi default: 0) + global + {not in Vi} + A history of ":" commands, and a history of previous search patterns + are remembered. This option decides how many entries may be stored in + each of these histories (see |cmdline-editing|). + NOTE: This option is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + + *'hkmap'* *'hk'* *'nohkmap'* *'nohk'* +'hkmap' 'hk' boolean (default off) + global + {not in Vi} + {only available when compiled with the |+rightleft| + feature} + When on, the keyboard is mapped for the Hebrew character set. + Normally you would set 'allowrevins' and use CTRL-_ in insert mode to + toggle this option. See |rileft.txt|. + NOTE: This option is reset when 'compatible' is set. + + *'hkmapp'* *'hkp'* *'nohkmapp'* *'nohkp'* +'hkmapp' 'hkp' boolean (default off) + global + {not in Vi} + {only available when compiled with the |+rightleft| + feature} + When on, phonetic keyboard mapping is used. 'hkmap' must also be on. + This is useful if you have a non-Hebrew keyboard. + See |rileft.txt|. + NOTE: This option is reset when 'compatible' is set. + + *'icon'* *'noicon'* +'icon' boolean (default off, on when title can be restored) + global + {not in Vi} + {not available when compiled without the |+title| + feature} + When on, the icon text of the window will be set to the value of + 'iconstring' (if it is not empty), or to the name of the file + currently being edited. Only the last part of the name is used. + Overridden by the 'iconstring' option. + Only works if the terminal supports setting window icons (currently + only X11 GUI and terminals with a non-empty 't_IS' option - these are + Unix xterm and iris-ansi by default, where 't_IS' is taken from the + builtin termcap). + When Vim was compiled with HAVE_X11 defined, the original icon will be + restored if possible |X11|. See |X11-icon| for changing the icon on + X11. + + *'iconstring'* +'iconstring' string (default "") + global + {not in Vi} + {not available when compiled without the |+title| + feature} + When this option is not empty, it will be used for the icon text of + the window. This happens only when the 'icon' option is on. + Only works if the terminal supports setting window icon text + (currently only X11 GUI and terminals with a non-empty 't_IS' option). + Does not work for MS Windows. + When Vim was compiled with HAVE_X11 defined, the original icon will be + restored if possible |X11|. + When this option contains printf-style '%' items, they will be + expanded according to the rules used for 'statusline'. See + 'titlestring' for example settings. + {not available when compiled without the |+statusline| feature} + + *'ignorecase'* *'ic'* *'noignorecase'* *'noic'* +'ignorecase' 'ic' boolean (default off) + global + Ignore case in search patterns. Also used when searching in the tags + file. + Also see 'smartcase'. + Can be overruled by using "\c" or "\C" in the pattern, see + |/ignorecase|. + + *'imactivatekey'* *'imak'* +'imactivatekey' 'imak' string (default "") + global + {not in Vi} + {only available when compiled with |+xim| and + |+GUI_GTK|} *E599* + Specifies the key that your Input Method in X-Windows uses for + activation. When this is specified correctly, vim can fully control + IM with 'imcmdline', 'iminsert' and 'imsearch'. + You can't use this option to change the activation key, the option + tells Vim what the key is. + Format: + [MODIFIER_FLAG-]KEY_STRING + + These characters can be used for MODIFIER_FLAG (case is ignored): + S Shift key + L Lock key + C Control key + 1 Mod1 key + 2 Mod2 key + 3 Mod3 key + 4 Mod4 key + 5 Mod5 key + Combinations are allowed, for example "S-C-space" or "SC-space" are + both shift+ctrl+space. + See and XStringToKeysym for KEY_STRING. + + Example: > + :set imactivatekey=S-space +< "S-space" means shift+space. This is the activation key for kinput2 + + canna (Japanese), and ami (Korean). + + *'imcmdline'* *'imc'* *'noimcmdline'* *'noimc'* +'imcmdline' 'imc' boolean (default off) + global + {not in Vi} + {only available when compiled with the |+xim|, + |+multi_byte_ime| or |global-ime| features} + When set the Input Method is always on when starting to edit a command + line, unless entering a search pattern (see 'imsearch' for that). + Setting this option is useful when your input method allows entering + English characters directly, e.g., when it's used to type accented + characters with dead keys. + + *'imdisable'* *'imd'* *'noimdisable'* *'noimd'* +'imdisable' 'imd' boolean (default off, on for some systems (SGI)) + global + {not in Vi} + {only available when compiled with the |+xim|, + |+multi_byte_ime| or |global-ime| features} + When set the Input Method is never used. This is useful to disable + the IM when it doesn't work properly. + Currently this option is on by default for SGI/IRIX machines. This + may change in later releases. + + *'iminsert'* *'imi'* +'iminsert' 'imi' number (default 0, 2 when an input method is supported) + local to buffer + {not in Vi} + Specifies whether :lmap or an Input Method (IM) is to be used in + Insert mode. Valid values: + 0 :lmap is off and IM is off + 1 :lmap is ON and IM is off + 2 :lmap is off and IM is ON + 2 is available only when compiled with the |+multi_byte_ime|, |+xim| + or |global-ime|. + To always reset the option to zero when leaving Insert mode with + this can be used: > + :inoremap :set iminsert=0 +< This makes :lmap and IM turn off automatically when leaving Insert + mode. + Note that this option changes when using CTRL-^ in Insert mode + |i_CTRL-^|. + The value is set to 1 when setting 'keymap' to a valid keymap name. + It is also used for the argument of commands like "r" and "f". + The value 0 may not work correctly with Athena and Motif with some XIM + methods. Use 'imdisable' to disable XIM then. + + *'imsearch'* *'ims'* +'imsearch' 'ims' number (default 0, 2 when an input method is supported) + local to buffer + {not in Vi} + Specifies whether :lmap or an Input Method (IM) is to be used when + entering a search pattern. Valid values: + -1 the value of 'iminsert' is used, makes it look like + 'iminsert' is also used when typing a search pattern + 0 :lmap is off and IM is off + 1 :lmap is ON and IM is off + 2 :lmap is off and IM is ON + Note that this option changes when using CTRL-^ in Command-line mode + |c_CTRL-^|. + The value is set to 1 when it is not -1 and setting the 'keymap' + option to a valid keymap name. + The value 0 may not work correctly with Athena and Motif with some XIM + methods. Use 'imdisable' to disable XIM then. + + *'include'* *'inc'* +'include' 'inc' string (default "^\s*#\s*include") + global or local to buffer |global-local| + {not in Vi} + {not available when compiled without the + |+find_in_path| feature} + Pattern to be used to find an include command. It is a search + pattern, just like for the "/" command (See |pattern|). The default + value is for C programs. This option is used for the commands "[i", + "]I", "[d", etc. + Normally the 'isfname' option is used to recognize the file name that + comes after the matched pattern. But if "\zs" appears in the pattern + then the text matched from "\zs" to the end, or until "\ze" if it + appears, is used as the file name. Use this to include characters + that are not in 'isfname', such as a space. You can then use + 'includeexpr' to process the matched text. + See |option-backslash| about including spaces and backslashes. + + *'includeexpr'* *'inex'* +'includeexpr' 'inex' string (default "") + local to buffer + {not in Vi} + {not available when compiled without the + |+find_in_path| or |+eval| features} + Expression to be used to transform the string found with the 'include' + option to a file name. Mostly useful to change "." to "/" for Java: > + :set includeexpr=substitute(v:fname,'\\.','/','g') +< The "v:fname" variable will be set to the file name that was detected. + + Also used for the |gf| command if an unmodified file name can't be + found. Allows doing "gf" on the name after an 'include' statement. + Also used for ||. + + The expression may be evaluated in the |sandbox|, see + |sandbox-option|. + + It is not allowed to change text or jump to another window while + evaluating 'includeexpr' |textlock|. + + *'incsearch'* *'is'* *'noincsearch'* *'nois'* +'incsearch' 'is' boolean (default off) + global + {not in Vi} + {not available when compiled without the + |+extra_search| features} + While typing a search command, show where the pattern, as it was typed + so far, matches. The matched string is highlighted. If the pattern + is invalid or not found, nothing is shown. The screen will be updated + often, this is only useful on fast terminals. + Note that the match will be shown, but the cursor will return to its + original position when no match is found and when pressing . You + still need to finish the search command with to move the + cursor to the match. + When compiled with the |+reltime| feature Vim only searches for about + half a second. With a complicated pattern and/or a lot of text the + match may not be found. This is to avoid that Vim hangs while you + are typing the pattern. + The highlighting can be set with the 'i' flag in 'highlight'. + See also: 'hlsearch'. + CTRL-L can be used to add one character from after the current match + to the command line. If 'ignorecase' and 'smartcase' are set and the + command line has no uppercase characters, the added character is + converted to lowercase. + CTRL-R CTRL-W can be used to add the word at the end of the current + match, excluding the characters that were already typed. + NOTE: This option is reset when 'compatible' is set. + + *'indentexpr'* *'inde'* +'indentexpr' 'inde' string (default "") + local to buffer + {not in Vi} + {not available when compiled without the |+cindent| + or |+eval| features} + Expression which is evaluated to obtain the proper indent for a line. + It is used when a new line is created, for the |=| operator and + in Insert mode as specified with the 'indentkeys' option. + When this option is not empty, it overrules the 'cindent' and + 'smartindent' indenting. + When 'paste' is set this option is not used for indenting. + The expression is evaluated with |v:lnum| set to the line number for + which the indent is to be computed. The cursor is also in this line + when the expression is evaluated (but it may be moved around). + The expression must return the number of spaces worth of indent. It + can return "-1" to keep the current indent (this means 'autoindent' is + used for the indent). + Functions useful for computing the indent are |indent()|, |cindent()| + and |lispindent()|. + The evaluation of the expression must not have side effects! It must + not change the text, jump to another window, etc. Afterwards the + cursor position is always restored, thus the cursor may be moved. + Normally this option would be set to call a function: > + :set indentexpr=GetMyIndent() +< Error messages will be suppressed, unless the 'debug' option contains + "msg". + See |indent-expression|. + NOTE: This option is made empty when 'compatible' is set. + + The expression may be evaluated in the |sandbox|, see + |sandbox-option|. + + It is not allowed to change text or jump to another window while + evaluating 'indentexpr' |textlock|. + + + *'indentkeys'* *'indk'* +'indentkeys' 'indk' string (default "0{,0},:,0#,!^F,o,O,e") + local to buffer + {not in Vi} + {not available when compiled without the |+cindent| + feature} + A list of keys that, when typed in Insert mode, cause reindenting of + the current line. Only happens if 'indentexpr' isn't empty. + The format is identical to 'cinkeys', see |indentkeys-format|. + See |C-indenting| and |indent-expression|. + + *'infercase'* *'inf'* *'noinfercase'* *'noinf'* +'infercase' 'inf' boolean (default off) + local to buffer + {not in Vi} + When doing keyword completion in insert mode |ins-completion|, and + 'ignorecase' is also on, the case of the match is adjusted depending + on the typed text. If the typed text contains a lowercase letter + where the match has an upper case letter, the completed part is made + lowercase. If the typed text has no lowercase letters and the match + has a lowercase letter where the typed text has an uppercase letter, + and there is a letter before it, the completed part is made uppercase. + With 'noinfercase' the match is used as-is. + + *'insertmode'* *'im'* *'noinsertmode'* *'noim'* +'insertmode' 'im' boolean (default off) + global + {not in Vi} + Makes Vim work in a way that Insert mode is the default mode. Useful + if you want to use Vim as a modeless editor. Used for |evim|. + These Insert mode commands will be useful: + - Use the cursor keys to move around. + - Use CTRL-O to execute one Normal mode command |i_CTRL-O|). When + this is a mapping, it is executed as if 'insertmode' was off. + Normal mode remains active until the mapping is finished. + - Use CTRL-L to execute a number of Normal mode commands, then use + to get back to Insert mode. Note that CTRL-L moves the cursor + left, like does when 'insertmode' isn't set. |i_CTRL-L| + + These items change when 'insertmode' is set: + - when starting to edit of a file, Vim goes to Insert mode. + - in Insert mode is a no-op and beeps. + - in Normal mode makes Vim go to Insert mode. + - CTRL-L in Insert mode is a command, it is not inserted. + - CTRL-Z in Insert mode suspends Vim, see |CTRL-Z|. *i_CTRL-Z* + However, when is used inside a mapping, it behaves like + 'insertmode' was not set. This was done to be able to use the same + mappings with 'insertmode' set or not set. + When executing commands with |:normal| 'insertmode' is not used. + + NOTE: This option is reset when 'compatible' is set. + + *'isfname'* *'isf'* +'isfname' 'isf' string (default for MS-DOS, Win32 and OS/2: + "@,48-57,/,\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=" + for AMIGA: "@,48-57,/,.,-,_,+,,,$,:" + for VMS: "@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~" + for OS/390: "@,240-249,/,.,-,_,+,,,#,$,%,~,=" + otherwise: "@,48-57,/,.,-,_,+,,,#,$,%,~,=") + global + {not in Vi} + The characters specified by this option are included in file names and + path names. Filenames are used for commands like "gf", "[i" and in + the tags file. It is also used for "\f" in a |pattern|. + Multi-byte characters 256 and above are always included, only the + characters up to 255 are specified with this option. + For UTF-8 the characters 0xa0 to 0xff are included as well. + Think twice before adding white space to this option. Although a + space may appear inside a file name, the effect will be that Vim + doesn't know where a file name starts or ends when doing completion. + It most likely works better without a space in 'isfname'. + + Note that on systems using a backslash as path separator, Vim tries to + do its best to make it work as you would expect. That is a bit + tricky, since Vi originally used the backslash to escape special + characters. Vim will not remove a backslash in front of a normal file + name character on these systems, but it will on Unix and alikes. The + '&' and '^' are not included by default, because these are special for + cmd.exe. + + The format of this option is a list of parts, separated with commas. + Each part can be a single character number or a range. A range is two + character numbers with '-' in between. A character number can be a + decimal number between 0 and 255 or the ASCII character itself (does + not work for digits). Example: + "_,-,128-140,#-43" (include '_' and '-' and the range + 128 to 140 and '#' to 43) + If a part starts with '^', the following character number or range + will be excluded from the option. The option is interpreted from left + to right. Put the excluded character after the range where it is + included. To include '^' itself use it as the last character of the + option or the end of a range. Example: + "^a-z,#,^" (exclude 'a' to 'z', include '#' and '^') + If the character is '@', all characters where isalpha() returns TRUE + are included. Normally these are the characters a to z and A to Z, + plus accented characters. To include '@' itself use "@-@". Examples: + "@,^a-z" All alphabetic characters, excluding lower + case ASCII letters. + "a-z,A-Z,@-@" All letters plus the '@' character. + A comma can be included by using it where a character number is + expected. Example: + "48-57,,,_" Digits, comma and underscore. + A comma can be excluded by prepending a '^'. Example: + " -~,^,,9" All characters from space to '~', excluding + comma, plus . + See |option-backslash| about including spaces and backslashes. + + *'isident'* *'isi'* +'isident' 'isi' string (default for MS-DOS, Win32 and OS/2: + "@,48-57,_,128-167,224-235" + otherwise: "@,48-57,_,192-255") + global + {not in Vi} + The characters given by this option are included in identifiers. + Identifiers are used in recognizing environment variables and after a + match of the 'define' option. It is also used for "\i" in a + |pattern|. See 'isfname' for a description of the format of this + option. + Careful: If you change this option, it might break expanding + environment variables. E.g., when '/' is included and Vim tries to + expand "$HOME/.viminfo". Maybe you should change 'iskeyword' instead. + + *'iskeyword'* *'isk'* +'iskeyword' 'isk' string (Vim default for MS-DOS and Win32: + "@,48-57,_,128-167,224-235" + otherwise: "@,48-57,_,192-255" + Vi default: "@,48-57,_") + local to buffer + {not in Vi} + Keywords are used in searching and recognizing with many commands: + "w", "*", "[i", etc. It is also used for "\k" in a |pattern|. See + 'isfname' for a description of the format of this option. For C + programs you could use "a-z,A-Z,48-57,_,.,-,>". + For a help file it is set to all non-blank printable characters except + '*', '"' and '|' (so that CTRL-] on a command finds the help for that + command). + When the 'lisp' option is on the '-' character is always included. + NOTE: This option is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + + *'isprint'* *'isp'* +'isprint' 'isp' string (default for MS-DOS, Win32, OS/2 and Macintosh: + "@,~-255"; otherwise: "@,161-255") + global + {not in Vi} + The characters given by this option are displayed directly on the + screen. It is also used for "\p" in a |pattern|. The characters from + space (ASCII 32) to '~' (ASCII 126) are always displayed directly, + even when they are not included in 'isprint' or excluded. See + 'isfname' for a description of the format of this option. + + Non-printable characters are displayed with two characters: + 0 - 31 "^@" - "^_" + 32 - 126 always single characters + 127 "^?" + 128 - 159 "~@" - "~_" + 160 - 254 "| " - "|~" + 255 "~?" + When 'encoding' is a Unicode one, illegal bytes from 128 to 255 are + displayed as , with the hexadecimal value of the byte. + When 'display' contains "uhex" all unprintable characters are + displayed as . + The SpecialKey highlighting will be used for unprintable characters. + |hl-SpecialKey| + + Multi-byte characters 256 and above are always included, only the + characters up to 255 are specified with this option. When a character + is printable but it is not available in the current font, a + replacement character will be shown. + Unprintable and zero-width Unicode characters are displayed as . + There is no option to specify these characters. + + *'joinspaces'* *'js'* *'nojoinspaces'* *'nojs'* +'joinspaces' 'js' boolean (default on) + global + {not in Vi} + Insert two spaces after a '.', '?' and '!' with a join command. + When 'cpoptions' includes the 'j' flag, only do this after a '.'. + Otherwise only one space is inserted. + NOTE: This option is set when 'compatible' is set. + + *'key'* +'key' string (default "") + local to buffer + {not in Vi} + {only available when compiled with the |+cryptv| + feature} + The key that is used for encrypting and decrypting the current buffer. + See |encryption| and 'cryptmethod'. + Careful: Do not set the key value by hand, someone might see the typed + key. Use the |:X| command. But you can make 'key' empty: > + :set key= +< It is not possible to get the value of this option with ":set key" or + "echo &key". This is to avoid showing it to someone who shouldn't + know. It also means you cannot see it yourself once you have set it, + be careful not to make a typing error! + + *'keymap'* *'kmp'* *E544* +'keymap' 'kmp' string (default "") + local to buffer + {not in Vi} + {only available when compiled with the |+keymap| + feature} + Name of a keyboard mapping. See |mbyte-keymap|. + Setting this option to a valid keymap name has the side effect of + setting 'iminsert' to one, so that the keymap becomes effective. + 'imsearch' is also set to one, unless it was -1 + Only normal file name characters can be used, "/\*?[|<>" are illegal. + + *'keymodel'* *'km'* +'keymodel' 'km' string (default "") + global + {not in Vi} + List of comma separated words, which enable special things that keys + can do. These values can be used: + startsel Using a shifted special key starts selection (either + Select mode or Visual mode, depending on "key" being + present in 'selectmode'). + stopsel Using a not-shifted special key stops selection. + Special keys in this context are the cursor keys, , , + and . + The 'keymodel' option is set by the |:behave| command. + + *'keywordprg'* *'kp'* +'keywordprg' 'kp' string (default "man" or "man -s", DOS: ":help", + OS/2: "view /", VMS: "help") + global or local to buffer |global-local| + {not in Vi} + Program to use for the |K| command. Environment variables are + expanded |:set_env|. ":help" may be used to access the Vim internal + help. (Note that previously setting the global option to the empty + value did this, which is now deprecated.) + When "man" is used, Vim will automatically translate a count for the + "K" command to a section number. Also for "man -s", in which case the + "-s" is removed when there is no count. + See |option-backslash| about including spaces and backslashes. + Example: > + :set keywordprg=man\ -s +< This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'langmap'* *'lmap'* *E357* *E358* +'langmap' 'lmap' string (default "") + global + {not in Vi} + {only available when compiled with the |+langmap| + feature} + This option allows switching your keyboard into a special language + mode. When you are typing text in Insert mode the characters are + inserted directly. When in command mode the 'langmap' option takes + care of translating these special characters to the original meaning + of the key. This means you don't have to change the keyboard mode to + be able to execute Normal mode commands. + This is the opposite of the 'keymap' option, where characters are + mapped in Insert mode. + + Example (for Greek, in UTF-8): *greek* > + :set langmap=ΑA,Î’B,ΨC,ΔD,ΕE,ΦF,ΓG,ΗH,ΙI,ΞJ,ΚK,ΛL,ΜM,ÎN,ΟO,ΠP,QQ,ΡR,ΣS,ΤT,ΘU,ΩV,WW,ΧX,Î¥Y,ΖZ,αa,βb,ψc,δd,εe,φf,γg,ηh,ιi,ξj,κk,λl,μm,νn,οo,Ï€p,qq,Ïr,σs,Ï„t,θu,ωv,Ï‚w,χx,Ï…y,ζz +< Example (exchanges meaning of z and y for commands): > + :set langmap=zy,yz,ZY,YZ +< + The 'langmap' option is a list of parts, separated with commas. Each + part can be in one of two forms: + 1. A list of pairs. Each pair is a "from" character immediately + followed by the "to" character. Examples: "aA", "aAbBcC". + 2. A list of "from" characters, a semi-colon and a list of "to" + characters. Example: "abc;ABC" + Example: "aA,fgh;FGH,cCdDeE" + Special characters need to be preceded with a backslash. These are + ";", ',' and backslash itself. + + This will allow you to activate vim actions without having to switch + back and forth between the languages. Your language characters will + be understood as normal vim English characters (according to the + langmap mappings) in the following cases: + o Normal/Visual mode (commands, buffer/register names, user mappings) + o Insert/Replace Mode: Register names after CTRL-R + o Insert/Replace Mode: Mappings + Characters entered in Command-line mode will NOT be affected by + this option. Note that this option can be changed at any time + allowing to switch between mappings for different languages/encodings. + Use a mapping to avoid having to type it each time! + + *'langmenu'* *'lm'* +'langmenu' 'lm' string (default "") + global + {not in Vi} + {only available when compiled with the |+menu| and + |+multi_lang| features} + Language to use for menu translation. Tells which file is loaded + from the "lang" directory in 'runtimepath': > + "lang/menu_" . &langmenu . ".vim" +< (without the spaces). For example, to always use the Dutch menus, no + matter what $LANG is set to: > + :set langmenu=nl_NL.ISO_8859-1 +< When 'langmenu' is empty, |v:lang| is used. + Only normal file name characters can be used, "/\*?[|<>" are illegal. + If your $LANG is set to a non-English language but you do want to use + the English menus: > + :set langmenu=none +< This option must be set before loading menus, switching on filetype + detection or syntax highlighting. Once the menus are defined setting + this option has no effect. But you could do this: > + :source $VIMRUNTIME/delmenu.vim + :set langmenu=de_DE.ISO_8859-1 + :source $VIMRUNTIME/menu.vim +< Warning: This deletes all menus that you defined yourself! + + *'laststatus'* *'ls'* +'laststatus' 'ls' number (default 1) + global + {not in Vi} + The value of this option influences when the last window will have a + status line: + 0: never + 1: only if there are at least two windows + 2: always + The screen looks nicer with a status line if you have several + windows, but it takes another screen line. |status-line| + + *'lazyredraw'* *'lz'* *'nolazyredraw'* *'nolz'* +'lazyredraw' 'lz' boolean (default off) + global + {not in Vi} + When this option is set, the screen will not be redrawn while + executing macros, registers and other commands that have not been + typed. Also, updating the window title is postponed. To force an + update use |:redraw|. + + *'linebreak'* *'lbr'* *'nolinebreak'* *'nolbr'* +'linebreak' 'lbr' boolean (default off) + local to window + {not in Vi} + {not available when compiled without the |+linebreak| + feature} + If on Vim will wrap long lines at a character in 'breakat' rather + than at the last character that fits on the screen. Unlike + 'wrapmargin' and 'textwidth', this does not insert s in the file, + it only affects the way the file is displayed, not its contents. The + value of 'showbreak' is used to put in front of wrapped lines. + This option is not used when the 'wrap' option is off or 'list' is on. + Note that characters after an are mostly not displayed + with the right amount of white space. + + *'lines'* *E593* +'lines' number (default 24 or terminal height) + global + Number of lines of the Vim window. + Normally you don't need to set this. It is done automatically by the + terminal initialization code. Also see |posix-screen-size|. + When Vim is running in the GUI or in a resizable window, setting this + option will cause the window size to be changed. When you only want + to use the size for the GUI, put the command in your |gvimrc| file. + Vim limits the number of lines to what fits on the screen. You can + use this command to get the tallest window possible: > + :set lines=999 +< Minimum value is 2, maximum value is 1000. + If you get less lines than expected, check the 'guiheadroom' option. + When you set this option and Vim is unable to change the physical + number of lines of the display, the display may be messed up. + + *'linespace'* *'lsp'* +'linespace' 'lsp' number (default 0, 1 for Win32 GUI) + global + {not in Vi} + {only in the GUI} + Number of pixel lines inserted between characters. Useful if the font + uses the full character cell height, making lines touch each other. + When non-zero there is room for underlining. + With some fonts there can be too much room between lines (to have + space for ascents and descents). Then it makes sense to set + 'linespace' to a negative value. This may cause display problems + though! + + *'lisp'* *'nolisp'* +'lisp' boolean (default off) + local to buffer + {not available when compiled without the |+lispindent| + feature} + Lisp mode: When is typed in insert mode set the indent for + the next line to Lisp standards (well, sort of). Also happens with + "cc" or "S". 'autoindent' must also be on for this to work. The 'p' + flag in 'cpoptions' changes the method of indenting: Vi compatible or + better. Also see 'lispwords'. + The '-' character is included in keyword characters. Redefines the + "=" operator to use this same indentation algorithm rather than + calling an external program if 'equalprg' is empty. + This option is not used when 'paste' is set. + {Vi: Does it a little bit differently} + + *'lispwords'* *'lw'* +'lispwords' 'lw' string (default is very long) + global + {not in Vi} + {not available when compiled without the |+lispindent| + feature} + Comma separated list of words that influence the Lisp indenting. + |'lisp'| + + *'list'* *'nolist'* +'list' boolean (default off) + local to window + List mode: Show tabs as CTRL-I is displayed, display $ after end of + line. Useful to see the difference between tabs and spaces and for + trailing blanks. Further changed by the 'listchars' option. + + The cursor is displayed at the start of the space a Tab character + occupies, not at the end as usual in Normal mode. To get this cursor + position while displaying Tabs with spaces, use: > + :set list lcs=tab\ \ +< + Note that list mode will also affect formatting (set with 'textwidth' + or 'wrapmargin') when 'cpoptions' includes 'L'. See 'listchars' for + changing the way tabs are displayed. + + *'listchars'* *'lcs'* +'listchars' 'lcs' string (default "eol:$") + global + {not in Vi} + Strings to use in 'list' mode and for the |:list| command. It is a + comma separated list of string settings. + eol:c Character to show at the end of each line. When + omitted, there is no extra character at the end of the + line. + tab:xy Two characters to be used to show a tab. The first + char is used once. The second char is repeated to + fill the space that the tab normally occupies. + "tab:>-" will show a tab that takes four spaces as + ">---". When omitted, a tab is show as ^I. + trail:c Character to show for trailing spaces. When omitted, + trailing spaces are blank. + extends:c Character to show in the last column, when 'wrap' is + off and the line continues beyond the right of the + screen. + precedes:c Character to show in the first column, when 'wrap' + is off and there is text preceding the character + visible in the first column. + conceal:c Character to show in place of concealed text, when + 'conceallevel' is set to 1. + nbsp:c Character to show for a non-breakable space (character + 0xA0, 160). Left blank when omitted. + + The characters ':' and ',' should not be used. UTF-8 characters can + be used when 'encoding' is "utf-8", otherwise only printable + characters are allowed. All characters must be single width. + + Examples: > + :set lcs=tab:>-,trail:- + :set lcs=tab:>-,eol:<,nbsp:% + :set lcs=extends:>,precedes:< +< The "NonText" highlighting will be used for "eol", "extends" and + "precedes". "SpecialKey" for "nbsp", "tab" and "trail". + |hl-NonText| |hl-SpecialKey| + + *'lpl'* *'nolpl'* *'loadplugins'* *'noloadplugins'* +'loadplugins' 'lpl' boolean (default on) + global + {not in Vi} + When on the plugin scripts are loaded when starting up |load-plugins|. + This option can be reset in your |vimrc| file to disable the loading + of plugins. + Note that using the "-u NONE" and "--noplugin" command line arguments + reset this option. |-u| |--noplugin| + + *'macatsui'* *'nomacatsui'* +'macatsui' boolean (default on) + global + {only available in Mac GUI version} + This is a workaround for when drawing doesn't work properly. When set + and compiled with multi-byte support ATSUI text drawing is used. When + not set ATSUI text drawing is not used. Switch this option off when + you experience drawing problems. In a future version the problems may + be solved and this option becomes obsolete. Therefore use this method + to unset it: > + if exists('&macatsui') + set nomacatsui + endif +< Another option to check if you have drawing problems is + 'termencoding'. + + *'magic'* *'nomagic'* +'magic' boolean (default on) + global + Changes the special characters that can be used in search patterns. + See |pattern|. + NOTE: To avoid portability problems with using patterns, always keep + this option at the default "on". Only switch it off when working with + old Vi scripts. In any other situation write patterns that work when + 'magic' is on. Include "\M" when you want to |/\M|. + + *'makeef'* *'mef'* +'makeef' 'mef' string (default: "") + global + {not in Vi} + {not available when compiled without the |+quickfix| + feature} + Name of the errorfile for the |:make| command (see |:make_makeprg|) + and the |:grep| command. + When it is empty, an internally generated temp file will be used. + When "##" is included, it is replaced by a number to make the name + unique. This makes sure that the ":make" command doesn't overwrite an + existing file. + NOT used for the ":cf" command. See 'errorfile' for that. + Environment variables are expanded |:set_env|. + See |option-backslash| about including spaces and backslashes. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'makeprg'* *'mp'* +'makeprg' 'mp' string (default "make", VMS: "MMS") + global or local to buffer |global-local| + {not in Vi} + Program to use for the ":make" command. See |:make_makeprg|. + This option may contain '%' and '#' characters, which are expanded to + the current and alternate file name. |:_%| |:_#| + Environment variables are expanded |:set_env|. See |option-backslash| + about including spaces and backslashes. + Note that a '|' must be escaped twice: once for ":set" and once for + the interpretation of a command. When you use a filter called + "myfilter" do it like this: > + :set makeprg=gmake\ \\\|\ myfilter +< The placeholder "$*" can be given (even multiple times) to specify + where the arguments will be included, for example: > + :set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*} +< This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'colorcolumn'* *'cc'* +'colorcolumn' 'cc' string (default "") + local to window + {not in Vi} + {not available when compiled without the |+syntax| + feature} + 'colorcolumn' is a comma separated list of screen columns that are + highlighted with ColorColumn |hl-ColorColumn|. Useful to align + text. Will make screen redrawing slower. + The screen column can be an absolute number, or a number preceded with + '+' or '-', which is added to or subtracted from 'textwidth'. > + + :set cc=+1 " highlight column after 'textwidth' + :set cc=+1,+2,+3 " highlight three columns after 'textwidth' + :hi ColorColumn ctermbg=lightgrey guibg=lightgrey +< + When 'textwidth' is zero then the items with '-' and '+' are not used. + A maximum of 256 columns are highlighted. + + *'matchpairs'* *'mps'* +'matchpairs' 'mps' string (default "(:),{:},[:]") + local to buffer + {not in Vi} + Characters that form pairs. The |%| command jumps from one to the + other. Currently only single byte character pairs are allowed, and + they must be different. The characters must be separated by a colon. + The pairs must be separated by a comma. Example for including '<' and + '>' (HTML): > + :set mps+=<:> + +< A more exotic example, to jump between the '=' and ';' in an + assignment, useful for languages like C and Java: > + :au FileType c,cpp,java set mps+==:; + +< For a more advanced way of using "%", see the matchit.vim plugin in + the $VIMRUNTIME/macros directory. |add-local-help| + + *'matchtime'* *'mat'* +'matchtime' 'mat' number (default 5) + global + {not in Vi}{in Nvi} + Tenths of a second to show the matching paren, when 'showmatch' is + set. Note that this is not in milliseconds, like other options that + set a time. This is to be compatible with Nvi. + + *'maxcombine'* *'mco'* +'maxcombine' 'mco' number (default 2) + global + {not in Vi} + {only available when compiled with the |+multi_byte| + feature} + The maximum number of combining characters supported for displaying. + Only used when 'encoding' is "utf-8". + The default is OK for most languages. Hebrew may require 4. + Maximum value is 6. + Even when this option is set to 2 you can still edit text with more + combining characters, you just can't see them. Use |g8| or |ga|. + See |mbyte-combining|. + + *'maxfuncdepth'* *'mfd'* +'maxfuncdepth' 'mfd' number (default 100) + global + {not in Vi} + {not available when compiled without the |+eval| + feature} + Maximum depth of function calls for user functions. This normally + catches endless recursion. When using a recursive function with + more depth, set 'maxfuncdepth' to a bigger number. But this will use + more memory, there is the danger of failing when memory is exhausted. + See also |:function|. + + *'maxmapdepth'* *'mmd'* *E223* +'maxmapdepth' 'mmd' number (default 1000) + global + {not in Vi} + Maximum number of times a mapping is done without resulting in a + character to be used. This normally catches endless mappings, like + ":map x y" with ":map y x". It still does not catch ":map g wg", + because the 'w' is used before the next mapping is done. See also + |key-mapping|. + + *'maxmem'* *'mm'* +'maxmem' 'mm' number (default between 256 to 5120 (system + dependent) or half the amount of memory + available) + global + {not in Vi} + Maximum amount of memory (in Kbyte) to use for one buffer. When this + limit is reached allocating extra memory for a buffer will cause + other memory to be freed. The maximum usable value is about 2000000. + Use this to work without a limit. Also see 'maxmemtot'. + + *'maxmempattern'* *'mmp'* +'maxmempattern' 'mmp' number (default 1000) + global + {not in Vi} + Maximum amount of memory (in Kbyte) to use for pattern matching. + The maximum value is about 2000000. Use this to work without a limit. + *E363* + When Vim runs into the limit it gives an error message and mostly + behaves like CTRL-C was typed. + Running into the limit often means that the pattern is very + inefficient or too complex. This may already happen with the pattern + "\(.\)*" on a very long line. ".*" works much better. + Vim may run out of memory before hitting the 'maxmempattern' limit. + + *'maxmemtot'* *'mmt'* +'maxmemtot' 'mmt' number (default between 2048 and 10240 (system + dependent) or half the amount of memory + available) + global + {not in Vi} + Maximum amount of memory in Kbyte to use for all buffers together. + The maximum usable value is about 2000000 (2 Gbyte). Use this to work + without a limit. On 64 bit machines higher values might work. But + hey, do you really need more than 2 Gbyte for text editing? + Also see 'maxmem'. + + *'menuitems'* *'mis'* +'menuitems' 'mis' number (default 25) + global + {not in Vi} + {not available when compiled without the |+menu| + feature} + Maximum number of items to use in a menu. Used for menus that are + generated from a list of items, e.g., the Buffers menu. Changing this + option has no direct effect, the menu must be refreshed first. + + *'mkspellmem'* *'msm'* +'mkspellmem' 'msm' string (default "460000,2000,500") + global + {not in Vi} + {not available when compiled without the |+syntax| + feature} + Parameters for |:mkspell|. This tunes when to start compressing the + word tree. Compression can be slow when there are many words, but + it's needed to avoid running out of memory. The amount of memory used + per word depends very much on how similar the words are, that's why + this tuning is complicated. + + There are three numbers, separated by commas: + {start},{inc},{added} + + For most languages the uncompressed word tree fits in memory. {start} + gives the amount of memory in Kbyte that can be used before any + compression is done. It should be a bit smaller than the amount of + memory that is available to Vim. + + When going over the {start} limit the {inc} number specifies the + amount of memory in Kbyte that can be allocated before another + compression is done. A low number means compression is done after + less words are added, which is slow. A high number means more memory + will be allocated. + + After doing compression, {added} times 1024 words can be added before + the {inc} limit is ignored and compression is done when any extra + amount of memory is needed. A low number means there is a smaller + chance of hitting the {inc} limit, less memory is used but it's + slower. + + The languages for which these numbers are important are Italian and + Hungarian. The default works for when you have about 512 Mbyte. If + you have 1 Gbyte you could use: > + :set mkspellmem=900000,3000,800 +< If you have less than 512 Mbyte |:mkspell| may fail for some + languages, no matter what you set 'mkspellmem' to. + + *'modeline'* *'ml'* *'nomodeline'* *'noml'* +'modeline' 'ml' boolean (Vim default: on (off for root), + Vi default: off) + local to buffer + *'modelines'* *'mls'* +'modelines' 'mls' number (default 5) + global + {not in Vi} + If 'modeline' is on 'modelines' gives the number of lines that is + checked for set commands. If 'modeline' is off or 'modelines' is zero + no lines are checked. See |modeline|. + NOTE: 'modeline' is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + + *'modifiable'* *'ma'* *'nomodifiable'* *'noma'* +'modifiable' 'ma' boolean (default on) + local to buffer + {not in Vi} *E21* + When off the buffer contents cannot be changed. The 'fileformat' and + 'fileencoding' options also can't be changed. + Can be reset with the |-M| command line argument. + + *'modified'* *'mod'* *'nomodified'* *'nomod'* +'modified' 'mod' boolean (default off) + local to buffer + {not in Vi} + When on, the buffer is considered to be modified. This option is set + when: + 1. A change was made to the text since it was last written. Using the + |undo| command to go back to the original text will reset the + option. But undoing changes that were made before writing the + buffer will set the option again, since the text is different from + when it was written. + 2. 'fileformat' or 'fileencoding' is different from its original + value. The original value is set when the buffer is read or + written. A ":set nomodified" command also resets the original + values to the current values and the 'modified' option will be + reset. + When 'buftype' is "nowrite" or "nofile" this option may be set, but + will be ignored. + + *'more'* *'nomore'* +'more' boolean (Vim default: on, Vi default: off) + global + {not in Vi} + When on, listings pause when the whole screen is filled. You will get + the |more-prompt|. When this option is off there are no pauses, the + listing continues until finished. + NOTE: This option is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + + *'mouse'* *E538* +'mouse' string (default "", "a" for GUI, MS-DOS and Win32) + global + {not in Vi} + Enable the use of the mouse. Only works for certain terminals + (xterm, MS-DOS, Win32 |win32-mouse|, QNX pterm, *BSD console with + sysmouse and Linux console with gpm). For using the mouse in the + GUI, see |gui-mouse|. + The mouse can be enabled for different modes: + n Normal mode + v Visual mode + i Insert mode + c Command-line mode + h all previous modes when editing a help file + a all previous modes + r for |hit-enter| and |more-prompt| prompt + Normally you would enable the mouse in all four modes with: > + :set mouse=a +< When the mouse is not enabled, the GUI will still use the mouse for + modeless selection. This doesn't move the text cursor. + + See |mouse-using|. Also see |'clipboard'|. + + Note: When enabling the mouse in a terminal, copy/paste will use the + "* register if there is access to an X-server. The xterm handling of + the mouse buttons can still be used by keeping the shift key pressed. + Also see the 'clipboard' option. + + *'mousefocus'* *'mousef'* *'nomousefocus'* *'nomousef'* +'mousefocus' 'mousef' boolean (default off) + global + {not in Vi} + {only works in the GUI} + The window that the mouse pointer is on is automatically activated. + When changing the window layout or window focus in another way, the + mouse pointer is moved to the window with keyboard focus. Off is the + default because it makes using the pull down menus a little goofy, as + a pointer transit may activate a window unintentionally. + + *'mousehide'* *'mh'* *'nomousehide'* *'nomh'* +'mousehide' 'mh' boolean (default on) + global + {not in Vi} + {only works in the GUI} + When on, the mouse pointer is hidden when characters are typed. + The mouse pointer is restored when the mouse is moved. + + *'mousemodel'* *'mousem'* +'mousemodel' 'mousem' string (default "extend", "popup" for MS-DOS and Win32) + global + {not in Vi} + Sets the model to use for the mouse. The name mostly specifies what + the right mouse button is used for: + extend Right mouse button extends a selection. This works + like in an xterm. + popup Right mouse button pops up a menu. The shifted left + mouse button extends a selection. This works like + with Microsoft Windows. + popup_setpos Like "popup", but the cursor will be moved to the + position where the mouse was clicked, and thus the + selected operation will act upon the clicked object. + If clicking inside a selection, that selection will + be acted upon, i.e. no cursor move. This implies of + course, that right clicking outside a selection will + end Visual mode. + Overview of what button does what for each model: + mouse extend popup(_setpos) ~ + left click place cursor place cursor + left drag start selection start selection + shift-left search word extend selection + right click extend selection popup menu (place cursor) + right drag extend selection - + middle click paste paste + + In the "popup" model the right mouse button produces a pop-up menu. + You need to define this first, see |popup-menu|. + + Note that you can further refine the meaning of buttons with mappings. + See |gui-mouse-mapping|. But mappings are NOT used for modeless + selection (because that's handled in the GUI code directly). + + The 'mousemodel' option is set by the |:behave| command. + + *'mouseshape'* *'mouses'* *E547* +'mouseshape' 'mouses' string (default "i:beam,r:beam,s:updown,sd:cross, + m:no,ml:up-arrow,v:rightup-arrow") + global + {not in Vi} + {only available when compiled with the |+mouseshape| + feature} + This option tells Vim what the mouse pointer should look like in + different modes. The option is a comma separated list of parts, much + like used for 'guicursor'. Each part consist of a mode/location-list + and an argument-list: + mode-list:shape,mode-list:shape,.. + The mode-list is a dash separated list of these modes/locations: + In a normal window: ~ + n Normal mode + v Visual mode + ve Visual mode with 'selection' "exclusive" (same as 'v', + if not specified) + o Operator-pending mode + i Insert mode + r Replace mode + + Others: ~ + c appending to the command-line + ci inserting in the command-line + cr replacing in the command-line + m at the 'Hit ENTER' or 'More' prompts + ml idem, but cursor in the last line + e any mode, pointer below last window + s any mode, pointer on a status line + sd any mode, while dragging a status line + vs any mode, pointer on a vertical separator line + vd any mode, while dragging a vertical separator line + a everywhere + + The shape is one of the following: + avail name looks like ~ + w x arrow Normal mouse pointer + w x blank no pointer at all (use with care!) + w x beam I-beam + w x updown up-down sizing arrows + w x leftright left-right sizing arrows + w x busy The system's usual busy pointer + w x no The system's usual 'no input' pointer + x udsizing indicates up-down resizing + x lrsizing indicates left-right resizing + x crosshair like a big thin + + x hand1 black hand + x hand2 white hand + x pencil what you write with + x question big ? + x rightup-arrow arrow pointing right-up + w x up-arrow arrow pointing up + x any X11 pointer number (see X11/cursorfont.h) + + The "avail" column contains a 'w' if the shape is available for Win32, + x for X11. + Any modes not specified or shapes not available use the normal mouse + pointer. + + Example: > + :set mouseshape=s:udsizing,m:no +< will make the mouse turn to a sizing arrow over the status lines and + indicate no input when the hit-enter prompt is displayed (since + clicking the mouse has no effect in this state.) + + *'mousetime'* *'mouset'* +'mousetime' 'mouset' number (default 500) + global + {not in Vi} + Only for GUI, MS-DOS, Win32 and Unix with xterm. Defines the maximum + time in msec between two mouse clicks for the second click to be + recognized as a multi click. + + *'mzquantum'* *'mzq'* +'mzquantum' 'mzq' number (default 100) + global + {not in Vi} + {not available when compiled without the |+mzscheme| + feature} + The number of milliseconds between polls for MzScheme threads. + Negative or zero value means no thread scheduling. + + *'nrformats'* *'nf'* +'nrformats' 'nf' string (default "octal,hex") + local to buffer + {not in Vi} + This defines what bases Vim will consider for numbers when using the + CTRL-A and CTRL-X commands for adding to and subtracting from a number + respectively; see |CTRL-A| for more info on these commands. + alpha If included, single alphabetical characters will be + incremented or decremented. This is useful for a list with a + letter index a), b), etc. *octal-number* + octal If included, numbers that start with a zero will be considered + to be octal. Example: Using CTRL-A on "007" results in "010". + hex If included, numbers starting with "0x" or "0X" will be + considered to be hexadecimal. Example: Using CTRL-X on + "0x100" results in "0x0ff". + Numbers which simply begin with a digit in the range 1-9 are always + considered decimal. This also happens for numbers that are not + recognized as octal or hex. + + *'number'* *'nu'* *'nonumber'* *'nonu'* +'number' 'nu' boolean (default off) + local to window + Print the line number in front of each line. When the 'n' option is + excluded from 'cpoptions' a wrapped line will not use the column of + line numbers (this is the default when 'compatible' isn't set). + The 'numberwidth' option can be used to set the room used for the line + number. + When a long, wrapped line doesn't start with the first character, '-' + characters are put before the number. + See |hl-LineNr| for the highlighting used for the number. + When setting this option, 'relativenumber' is reset. + + *'numberwidth'* *'nuw'* +'numberwidth' 'nuw' number (Vim default: 4 Vi default: 8) + local to window + {not in Vi} + {only available when compiled with the |+linebreak| + feature} + Minimal number of columns to use for the line number. Only relevant + when the 'number' or 'relativenumber' option is set or printing lines + with a line number. Since one space is always between the number and + the text, there is one less character for the number itself. + The value is the minimum width. A bigger width is used when needed to + fit the highest line number in the buffer respectively the number of + rows in the window, depending on whether 'number' or 'relativenumber' + is set. Thus with the Vim default of 4 there is room for a line number + up to 999. When the buffer has 1000 lines five columns will be used. + The minimum value is 1, the maximum value is 10. + NOTE: 'numberwidth' is reset to 8 when 'compatible' is set. + + *'omnifunc'* *'ofu'* +'omnifunc' 'ofu' string (default: empty) + local to buffer + {not in Vi} + {not available when compiled without the |+eval| + or |+insert_expand| features} + This option specifies a function to be used for Insert mode omni + completion with CTRL-X CTRL-O. |i_CTRL-X_CTRL-O| + See |complete-functions| for an explanation of how the function is + invoked and what it should return. + This option is usually set by a filetype plugin: + |:filetype-plugin-on| + + + *'opendevice'* *'odev'* *'noopendevice'* *'noodev'* +'opendevice' 'odev' boolean (default off) + global + {not in Vi} + {only for MS-DOS, MS-Windows and OS/2} + Enable reading and writing from devices. This may get Vim stuck on a + device that can be opened but doesn't actually do the I/O. Therefore + it is off by default. + Note that on MS-Windows editing "aux.h", "lpt1.txt" and the like also + result in editing a device. + + + *'operatorfunc'* *'opfunc'* +'operatorfunc' 'opfunc' string (default: empty) + global + {not in Vi} + This option specifies a function to be called by the |g@| operator. + See |:map-operator| for more info and an example. + + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + + *'osfiletype'* *'oft'* *E366* +'osfiletype' 'oft' string (RISC-OS default: "Text", + others default: "") + local to buffer + {not in Vi} + {only available when compiled with the |+osfiletype| + feature} + Some operating systems store extra information about files besides + name, datestamp and permissions. This option contains the extra + information, the nature of which will vary between systems. + The value of this option is usually set when the file is loaded, and + is used to set the operating system file type when file is written. + It can affect the pattern matching of the automatic commands. + |autocmd-osfiletypes| + + *'paragraphs'* *'para'* +'paragraphs' 'para' string (default "IPLPPPQPP TPHPLIPpLpItpplpipbp") + global + Specifies the nroff macros that separate paragraphs. These are pairs + of two letters (see |object-motions|). + + *'paste'* *'nopaste'* +'paste' boolean (default off) + global + {not in Vi} + Put Vim in Paste mode. This is useful if you want to cut or copy + some text from one window and paste it in Vim. This will avoid + unexpected effects. + Setting this option is useful when using Vim in a terminal, where Vim + cannot distinguish between typed text and pasted text. In the GUI, Vim + knows about pasting and will mostly do the right thing without 'paste' + being set. The same is true for a terminal where Vim handles the + mouse clicks itself. + This option is reset when starting the GUI. Thus if you set it in + your .vimrc it will work in a terminal, but not in the GUI. Setting + 'paste' in the GUI has side effects: e.g., the Paste toolbar button + will no longer work in Insert mode, because it uses a mapping. + When the 'paste' option is switched on (also when it was already on): + - mapping in Insert mode and Command-line mode is disabled + - abbreviations are disabled + - 'textwidth' is set to 0 + - 'wrapmargin' is set to 0 + - 'autoindent' is reset + - 'smartindent' is reset + - 'softtabstop' is set to 0 + - 'revins' is reset + - 'ruler' is reset + - 'showmatch' is reset + - 'formatoptions' is used like it is empty + These options keep their value, but their effect is disabled: + - 'lisp' + - 'indentexpr' + - 'cindent' + NOTE: When you start editing another file while the 'paste' option is + on, settings from the modelines or autocommands may change the + settings again, causing trouble when pasting text. You might want to + set the 'paste' option again. + When the 'paste' option is reset the mentioned options are restored to + the value before the moment 'paste' was switched from off to on. + Resetting 'paste' before ever setting it does not have any effect. + Since mapping doesn't work while 'paste' is active, you need to use + the 'pastetoggle' option to toggle the 'paste' option with some key. + + *'pastetoggle'* *'pt'* +'pastetoggle' 'pt' string (default "") + global + {not in Vi} + When non-empty, specifies the key sequence that toggles the 'paste' + option. This is like specifying a mapping: > + :map {keys} :set invpaste +< Where {keys} is the value of 'pastetoggle'. + The difference is that it will work even when 'paste' is set. + 'pastetoggle' works in Insert mode and Normal mode, but not in + Command-line mode. + Mappings are checked first, thus overrule 'pastetoggle'. However, + when 'paste' is on mappings are ignored in Insert mode, thus you can do + this: > + :map :set paste + :map :set nopaste + :imap :set paste + :imap + :set pastetoggle= +< This will make start paste mode and stop paste mode. + Note that typing in paste mode inserts "", since in paste + mode everything is inserted literally, except the 'pastetoggle' key + sequence. + When the value has several bytes 'ttimeoutlen' applies. + + *'pex'* *'patchexpr'* +'patchexpr' 'pex' string (default "") + global + {not in Vi} + {not available when compiled without the |+diff| + feature} + Expression which is evaluated to apply a patch to a file and generate + the resulting new version of the file. See |diff-patchexpr|. + + *'patchmode'* *'pm'* *E206* +'patchmode' 'pm' string (default "") + global + {not in Vi} + When non-empty the oldest version of a file is kept. This can be used + to keep the original version of a file if you are changing files in a + source distribution. Only the first time that a file is written a + copy of the original file will be kept. The name of the copy is the + name of the original file with the string in the 'patchmode' option + appended. This option should start with a dot. Use a string like + ".org". 'backupdir' must not be empty for this to work (Detail: The + backup file is renamed to the patchmode file after the new file has + been successfully written, that's why it must be possible to write a + backup file). If there was no file to be backed up, an empty file is + created. + When the 'backupskip' pattern matches, a patchmode file is not made. + Using 'patchmode' for compressed files appends the extension at the + end (e.g., "file.gz.orig"), thus the resulting name isn't always + recognized as a compressed file. + Only normal file name characters can be used, "/\*?[|<>" are illegal. + + *'path'* *'pa'* *E343* *E345* *E347* +'path' 'pa' string (default on Unix: ".,/usr/include,," + on OS/2: ".,/emx/include,," + other systems: ".,,") + global or local to buffer |global-local| + {not in Vi} + This is a list of directories which will be searched when using the + |gf|, [f, ]f, ^Wf, |:find|, |:sfind|, |:tabfind| and other commands, + provided that the file being searched for has a relative path (not + starting with "/", "./" or "../"). The directories in the 'path' + option may be relative or absolute. + - Use commas to separate directory names: > + :set path=.,/usr/local/include,/usr/include +< - Spaces can also be used to separate directory names (for backwards + compatibility with version 3.0). To have a space in a directory + name, precede it with an extra backslash, and escape the space: > + :set path=.,/dir/with\\\ space +< - To include a comma in a directory name precede it with an extra + backslash: > + :set path=.,/dir/with\\,comma +< - To search relative to the directory of the current file, use: > + :set path=. +< - To search in the current directory use an empty string between two + commas: > + :set path=,, +< - A directory name may end in a ':' or '/'. + - Environment variables are expanded |:set_env|. + - When using |netrw.vim| URLs can be used. For example, adding + "http://www.vim.org" will make ":find index.html" work. + - Search upwards and downwards in a directory tree using "*", "**" and + ";". See |file-searching| for info and syntax. + {not available when compiled without the |+path_extra| feature} + - Careful with '\' characters, type two to get one in the option: > + :set path=.,c:\\include +< Or just use '/' instead: > + :set path=.,c:/include +< Don't forget "." or files won't even be found in the same directory as + the file! + The maximum length is limited. How much depends on the system, mostly + it is something like 256 or 1024 characters. + You can check if all the include files are found, using the value of + 'path', see |:checkpath|. + The use of |:set+=| and |:set-=| is preferred when adding or removing + directories from the list. This avoids problems when a future version + uses another default. To remove the current directory use: > + :set path-= +< To add the current directory use: > + :set path+= +< To use an environment variable, you probably need to replace the + separator. Here is an example to append $INCL, in which directory + names are separated with a semi-colon: > + :let &path = &path . "," . substitute($INCL, ';', ',', 'g') +< Replace the ';' with a ':' or whatever separator is used. Note that + this doesn't work when $INCL contains a comma or white space. + + *'preserveindent'* *'pi'* *'nopreserveindent'* *'nopi'* +'preserveindent' 'pi' boolean (default off) + local to buffer + {not in Vi} + When changing the indent of the current line, preserve as much of the + indent structure as possible. Normally the indent is replaced by a + series of tabs followed by spaces as required (unless |'expandtab'| is + enabled, in which case only spaces are used). Enabling this option + means the indent will preserve as many existing characters as possible + for indenting, and only add additional tabs or spaces as required. + 'expandtab' does not apply to the preserved white space, a Tab remains + a Tab. + NOTE: When using ">>" multiple times the resulting indent is a mix of + tabs and spaces. You might not like this. + NOTE: 'preserveindent' is reset when 'compatible' is set. + Also see 'copyindent'. + Use |:retab| to clean up white space. + + *'previewheight'* *'pvh'* +'previewheight' 'pvh' number (default 12) + global + {not in Vi} + {not available when compiled without the |+windows| or + |+quickfix| features} + Default height for a preview window. Used for |:ptag| and associated + commands. Used for |CTRL-W_}| when no count is given. + + *'previewwindow'* *'nopreviewwindow'* + *'pvw'* *'nopvw'* *E590* +'previewwindow' 'pvw' boolean (default off) + local to window + {not in Vi} + {not available when compiled without the |+windows| or + |+quickfix| features} + Identifies the preview window. Only one window can have this option + set. It's normally not set directly, but by using one of the commands + |:ptag|, |:pedit|, etc. + + *'printdevice'* *'pdev'* +'printdevice' 'pdev' string (default empty) + global + {not in Vi} + {only available when compiled with the |+printer| + feature} + The name of the printer to be used for |:hardcopy|. + See |pdev-option|. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'printencoding'* *'penc'* +'printencoding' 'penc' String (default empty, except for some systems) + global + {not in Vi} + {only available when compiled with the |+printer| + and |+postscript| features} + Sets the character encoding used when printing. + See |penc-option|. + + *'printexpr'* *'pexpr'* +'printexpr' 'pexpr' String (default: see below) + global + {not in Vi} + {only available when compiled with the |+printer| + and |+postscript| features} + Expression used to print the PostScript produced with |:hardcopy|. + See |pexpr-option|. + + *'printfont'* *'pfn'* +'printfont' 'pfn' string (default "courier") + global + {not in Vi} + {only available when compiled with the |+printer| + feature} + The name of the font that will be used for |:hardcopy|. + See |pfn-option|. + + *'printheader'* *'pheader'* +'printheader' 'pheader' string (default "%<%f%h%m%=Page %N") + global + {not in Vi} + {only available when compiled with the |+printer| + feature} + The format of the header produced in |:hardcopy| output. + See |pheader-option|. + + *'printmbcharset'* *'pmbcs'* +'printmbcharset' 'pmbcs' string (default "") + global + {not in Vi} + {only available when compiled with the |+printer|, + |+postscript| and |+multi_byte| features} + The CJK character set to be used for CJK output from |:hardcopy|. + See |pmbcs-option|. + + *'printmbfont'* *'pmbfn'* +'printmbfont' 'pmbfn' string (default "") + global + {not in Vi} + {only available when compiled with the |+printer|, + |+postscript| and |+multi_byte| features} + List of font names to be used for CJK output from |:hardcopy|. + See |pmbfn-option|. + + *'printoptions'* *'popt'* +'printoptions' 'popt' string (default "") + global + {not in Vi} + {only available when compiled with |+printer| feature} + List of items that control the format of the output of |:hardcopy|. + See |popt-option|. + + *'prompt'* *'noprompt'* +'prompt' boolean (default on) + global + When on a ":" prompt is used in Ex mode. + + *'pumheight'* *'ph'* +'pumheight' 'ph' number (default 0) + global + {not available when compiled without the + |+insert_expand| feature} + {not in Vi} + Determines the maximum number of items to show in the popup menu for + Insert mode completion. When zero as much space as available is used. + |ins-completion-menu|. + + + *'quoteescape'* *'qe'* +'quoteescape' 'qe' string (default "\") + local to buffer + {not in Vi} + The characters that are used to escape quotes in a string. Used for + objects like a', a" and a` |a'|. + When one of the characters in this option is found inside a string, + the following character will be skipped. The default value makes the + text "foo\"bar\\" considered to be one string. + + *'readonly'* *'ro'* *'noreadonly'* *'noro'* +'readonly' 'ro' boolean (default off) + local to buffer + If on, writes fail unless you use a '!'. Protects you from + accidentally overwriting a file. Default on when Vim is started + in read-only mode ("vim -R") or when the executable is called "view". + When using ":w!" the 'readonly' option is reset for the current + buffer, unless the 'Z' flag is in 'cpoptions'. + {not in Vi:} When using the ":view" command the 'readonly' option is + set for the newly edited buffer. + + *'redrawtime'* *'rdt'* +'redrawtime' 'rdt' number (default 2000) + global + {not in Vi} + {only available when compiled with the |+reltime| + feature} + The time in milliseconds for redrawing the display. This applies to + searching for patterns for 'hlsearch' and |:match| highlighting. + When redrawing takes more than this many milliseconds no further + matches will be highlighted. This is used to avoid that Vim hangs + when using a very complicated pattern. + + *'relativenumber'* *'rnu'* *'norelativenumber'* *'nornu'* +'relativenumber' 'rnu' boolean (default off) + local to window + {not in Vi} + Show the line number relative to the line with the cursor in front of + each line. Relative line numbers help you use the |count| you can + precede some vertical motion commands (e.g. j k + -) with, without + having to calculate it yourself. Especially useful in combination with + other commands (e.g. y d c < > gq gw =). + When the 'n' option is excluded from 'cpoptions' a wrapped + line will not use the column of line numbers (this is the default when + 'compatible' isn't set). + The 'numberwidth' option can be used to set the room used for the line + number. + When a long, wrapped line doesn't start with the first character, '-' + characters are put before the number. + See |hl-LineNr| for the highlighting used for the number. + When setting this option, 'number' is reset. + + *'remap'* *'noremap'* +'remap' boolean (default on) + global + Allows for mappings to work recursively. If you do not want this for + a single entry, use the :noremap[!] command. + NOTE: To avoid portability problems with Vim scripts, always keep + this option at the default "on". Only switch it off when working with + old Vi scripts. + + *'report'* +'report' number (default 2) + global + Threshold for reporting number of lines changed. When the number of + changed lines is more than 'report' a message will be given for most + ":" commands. If you want it always, set 'report' to 0. + For the ":substitute" command the number of substitutions is used + instead of the number of lines. + + *'restorescreen'* *'rs'* *'norestorescreen'* *'nors'* +'restorescreen' 'rs' boolean (default on) + global + {not in Vi} {only in Windows 95/NT console version} + When set, the screen contents is restored when exiting Vim. This also + happens when executing external commands. + + For non-Windows Vim: You can set or reset the 't_ti' and 't_te' + options in your .vimrc. To disable restoring: + set t_ti= t_te= + To enable restoring (for an xterm): + set t_ti=^[7^[[r^[[?47h t_te=^[[?47l^[8 + (Where ^[ is an , type CTRL-V to insert it) + + *'revins'* *'ri'* *'norevins'* *'nori'* +'revins' 'ri' boolean (default off) + global + {not in Vi} + {only available when compiled with the |+rightleft| + feature} + Inserting characters in Insert mode will work backwards. See "typing + backwards" |ins-reverse|. This option can be toggled with the CTRL-_ + command in Insert mode, when 'allowrevins' is set. + NOTE: This option is reset when 'compatible' or 'paste' is set. + + *'rightleft'* *'rl'* *'norightleft'* *'norl'* +'rightleft' 'rl' boolean (default off) + local to window + {not in Vi} + {only available when compiled with the |+rightleft| + feature} + When on, display orientation becomes right-to-left, i.e., characters + that are stored in the file appear from the right to the left. + Using this option, it is possible to edit files for languages that + are written from the right to the left such as Hebrew and Arabic. + This option is per window, so it is possible to edit mixed files + simultaneously, or to view the same file in both ways (this is + useful whenever you have a mixed text file with both right-to-left + and left-to-right strings so that both sets are displayed properly + in different windows). Also see |rileft.txt|. + + *'rightleftcmd'* *'rlc'* +'rightleftcmd' 'rlc' string (default "search") + local to window + {not in Vi} + {only available when compiled with the |+rightleft| + feature} + Each word in this option enables the command line editing to work in + right-to-left mode for a group of commands: + + search "/" and "?" commands + + This is useful for languages such as Hebrew, Arabic and Farsi. + The 'rightleft' option must be set for 'rightleftcmd' to take effect. + + *'ruler'* *'ru'* *'noruler'* *'noru'* +'ruler' 'ru' boolean (default off) + global + {not in Vi} + {not available when compiled without the + |+cmdline_info| feature} + Show the line and column number of the cursor position, separated by a + comma. When there is room, the relative position of the displayed + text in the file is shown on the far right: + Top first line is visible + Bot last line is visible + All first and last line are visible + 45% relative position in the file + If 'rulerformat' is set, it will determine the contents of the ruler. + Each window has its own ruler. If a window has a status line, the + ruler is shown there. Otherwise it is shown in the last line of the + screen. If the statusline is given by 'statusline' (i.e. not empty), + this option takes precedence over 'ruler' and 'rulerformat' + If the number of characters displayed is different from the number of + bytes in the text (e.g., for a TAB or a multi-byte character), both + the text column (byte number) and the screen column are shown, + separated with a dash. + For an empty line "0-1" is shown. + For an empty buffer the line number will also be zero: "0,0-1". + This option is reset when the 'paste' option is set. + If you don't want to see the ruler all the time but want to know where + you are, use "g CTRL-G" |g_CTRL-G|. + NOTE: This option is reset when 'compatible' is set. + + *'rulerformat'* *'ruf'* +'rulerformat' 'ruf' string (default empty) + global + {not in Vi} + {not available when compiled without the |+statusline| + feature} + When this option is not empty, it determines the content of the ruler + string, as displayed for the 'ruler' option. + The format of this option is like that of 'statusline'. + The default ruler width is 17 characters. To make the ruler 15 + characters wide, put "%15(" at the start and "%)" at the end. + Example: > + :set rulerformat=%15(%c%V\ %p%%%) +< + *'runtimepath'* *'rtp'* *vimfiles* +'runtimepath' 'rtp' string (default: + Unix: "$HOME/.vim, + $VIM/vimfiles, + $VIMRUNTIME, + $VIM/vimfiles/after, + $HOME/.vim/after" + Amiga: "home:vimfiles, + $VIM/vimfiles, + $VIMRUNTIME, + $VIM/vimfiles/after, + home:vimfiles/after" + PC, OS/2: "$HOME/vimfiles, + $VIM/vimfiles, + $VIMRUNTIME, + $VIM/vimfiles/after, + $HOME/vimfiles/after" + Macintosh: "$VIM:vimfiles, + $VIMRUNTIME, + $VIM:vimfiles:after" + RISC-OS: "Choices:vimfiles, + $VIMRUNTIME, + Choices:vimfiles/after" + VMS: "sys$login:vimfiles, + $VIM/vimfiles, + $VIMRUNTIME, + $VIM/vimfiles/after, + sys$login:vimfiles/after") + global + {not in Vi} + This is a list of directories which will be searched for runtime + files: + filetype.vim filetypes by file name |new-filetype| + scripts.vim filetypes by file contents |new-filetype-scripts| + autoload/ automatically loaded scripts |autoload-functions| + colors/ color scheme files |:colorscheme| + compiler/ compiler files |:compiler| + doc/ documentation |write-local-help| + ftplugin/ filetype plugins |write-filetype-plugin| + indent/ indent scripts |indent-expression| + keymap/ key mapping files |mbyte-keymap| + lang/ menu translations |:menutrans| + menu.vim GUI menus |menu.vim| + plugin/ plugin scripts |write-plugin| + print/ files for printing |postscript-print-encoding| + spell/ spell checking files |spell| + syntax/ syntax files |mysyntaxfile| + tutor/ files for vimtutor |tutor| + + And any other file searched for with the |:runtime| command. + + The defaults for most systems are setup to search five locations: + 1. In your home directory, for your personal preferences. + 2. In a system-wide Vim directory, for preferences from the system + administrator. + 3. In $VIMRUNTIME, for files distributed with Vim. + *after-directory* + 4. In the "after" directory in the system-wide Vim directory. This is + for the system administrator to overrule or add to the distributed + defaults (rarely needed) + 5. In the "after" directory in your home directory. This is for + personal preferences to overrule or add to the distributed defaults + or system-wide settings (rarely needed). + + Note that, unlike 'path', no wildcards like "**" are allowed. Normal + wildcards are allowed, but can significantly slow down searching for + runtime files. For speed, use as few items as possible and avoid + wildcards. + See |:runtime|. + Example: > + :set runtimepath=~/vimruntime,/mygroup/vim,$VIMRUNTIME +< This will use the directory "~/vimruntime" first (containing your + personal Vim runtime files), then "/mygroup/vim" (shared between a + group of people) and finally "$VIMRUNTIME" (the distributed runtime + files). + You probably should always include $VIMRUNTIME somewhere, to use the + distributed runtime files. You can put a directory before $VIMRUNTIME + to find files which replace a distributed runtime files. You can put + a directory after $VIMRUNTIME to find files which add to distributed + runtime files. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'scroll'* *'scr'* +'scroll' 'scr' number (default: half the window height) + local to window + Number of lines to scroll with CTRL-U and CTRL-D commands. Will be + set to half the number of lines in the window when the window size + changes. If you give a count to the CTRL-U or CTRL-D command it will + be used as the new value for 'scroll'. Reset to half the window + height with ":set scroll=0". {Vi is a bit different: 'scroll' gives + the number of screen lines instead of file lines, makes a difference + when lines wrap} + + *'scrollbind'* *'scb'* *'noscrollbind'* *'noscb'* +'scrollbind' 'scb' boolean (default off) + local to window + {not in Vi} + {not available when compiled without the |+scrollbind| + feature} + See also |scroll-binding|. When this option is set, the current + window scrolls as other scrollbind windows (windows that also have + this option set) scroll. This option is useful for viewing the + differences between two versions of a file, see 'diff'. + See |'scrollopt'| for options that determine how this option should be + interpreted. + This option is mostly reset when splitting a window to edit another + file. This means that ":split | edit file" results in two windows + with scroll-binding, but ":split file" does not. + + *'scrolljump'* *'sj'* +'scrolljump' 'sj' number (default 1) + global + {not in Vi} + Minimal number of lines to scroll when the cursor gets off the + screen (e.g., with "j"). Not used for scroll commands (e.g., CTRL-E, + CTRL-D). Useful if your terminal scrolls very slowly. + When set to a negative number from -1 to -100 this is used as the + percentage of the window height. Thus -50 scrolls half the window + height. + NOTE: This option is set to 1 when 'compatible' is set. + + *'scrolloff'* *'so'* +'scrolloff' 'so' number (default 0) + global + {not in Vi} + Minimal number of screen lines to keep above and below the cursor. + This will make some context visible around where you are working. If + you set it to a very large value (999) the cursor line will always be + in the middle of the window (except at the start or end of the file or + when long lines wrap). + For scrolling horizontally see 'sidescrolloff'. + NOTE: This option is set to 0 when 'compatible' is set. + + *'scrollopt'* *'sbo'* +'scrollopt' 'sbo' string (default "ver,jump") + global + {not available when compiled without the |+scrollbind| + feature} + {not in Vi} + This is a comma-separated list of words that specifies how + 'scrollbind' windows should behave. 'sbo' stands for ScrollBind + Options. + The following words are available: + ver Bind vertical scrolling for 'scrollbind' windows + hor Bind horizontal scrolling for 'scrollbind' windows + jump Applies to the offset between two windows for vertical + scrolling. This offset is the difference in the first + displayed line of the bound windows. When moving + around in a window, another 'scrollbind' window may + reach a position before the start or after the end of + the buffer. The offset is not changed though, when + moving back the 'scrollbind' window will try to scroll + to the desired position when possible. + When now making that window the current one, two + things can be done with the relative offset: + 1. When "jump" is not included, the relative offset is + adjusted for the scroll position in the new current + window. When going back to the other window, the + new relative offset will be used. + 2. When "jump" is included, the other windows are + scrolled to keep the same relative offset. When + going back to the other window, it still uses the + same relative offset. + Also see |scroll-binding|. + When 'diff' mode is active there always is vertical scroll binding, + even when "ver" isn't there. + + *'sections'* *'sect'* +'sections' 'sect' string (default "SHNHH HUnhsh") + global + Specifies the nroff macros that separate sections. These are pairs of + two letters (See |object-motions|). The default makes a section start + at the nroff macros ".SH", ".NH", ".H", ".HU", ".nh" and ".sh". + + *'secure'* *'nosecure'* *E523* +'secure' boolean (default off) + global + {not in Vi} + When on, ":autocmd", shell and write commands are not allowed in + ".vimrc" and ".exrc" in the current directory and map commands are + displayed. Switch it off only if you know that you will not run into + problems, or when the 'exrc' option is off. On Unix this option is + only used if the ".vimrc" or ".exrc" is not owned by you. This can be + dangerous if the systems allows users to do a "chown". You better set + 'secure' at the end of your ~/.vimrc then. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'selection'* *'sel'* +'selection' 'sel' string (default "inclusive") + global + {not in Vi} + This option defines the behavior of the selection. It is only used + in Visual and Select mode. + Possible values: + value past line inclusive ~ + old no yes + inclusive yes yes + exclusive yes no + "past line" means that the cursor is allowed to be positioned one + character past the line. + "inclusive" means that the last character of the selection is included + in an operation. For example, when "x" is used to delete the + selection. + Note that when "exclusive" is used and selecting from the end + backwards, you cannot include the last character of a line, when + starting in Normal mode and 'virtualedit' empty. + + The 'selection' option is set by the |:behave| command. + + *'selectmode'* *'slm'* +'selectmode' 'slm' string (default "") + global + {not in Vi} + This is a comma separated list of words, which specifies when to start + Select mode instead of Visual mode, when a selection is started. + Possible values: + mouse when using the mouse + key when using shifted special keys + cmd when using "v", "V" or CTRL-V + See |Select-mode|. + The 'selectmode' option is set by the |:behave| command. + + *'sessionoptions'* *'ssop'* +'sessionoptions' 'ssop' string (default: "blank,buffers,curdir,folds, + help,options,tabpages,winsize") + global + {not in Vi} + {not available when compiled without the |+mksession| + feature} + Changes the effect of the |:mksession| command. It is a comma + separated list of words. Each word enables saving and restoring + something: + word save and restore ~ + blank empty windows + buffers hidden and unloaded buffers, not just those in windows + curdir the current directory + folds manually created folds, opened/closed folds and local + fold options + globals global variables that start with an uppercase letter + and contain at least one lowercase letter. Only + String and Number types are stored. + help the help window + localoptions options and mappings local to a window or buffer (not + global values for local options) + options all options and mappings (also global values for local + options) + resize size of the Vim window: 'lines' and 'columns' + sesdir the directory in which the session file is located + will become the current directory (useful with + projects accessed over a network from different + systems) + slash backslashes in file names replaced with forward + slashes + tabpages all tab pages; without this only the current tab page + is restored, so that you can make a session for each + tab page separately + unix with Unix end-of-line format (single ), even when + on Windows or DOS + winpos position of the whole Vim window + winsize window sizes + + Don't include both "curdir" and "sesdir". + When neither "curdir" nor "sesdir" is included, file names are stored + with absolute paths. + "slash" and "unix" are useful on Windows when sharing session files + with Unix. The Unix version of Vim cannot source dos format scripts, + but the Windows version of Vim can source unix format scripts. + + *'shell'* *'sh'* *E91* +'shell' 'sh' string (default $SHELL or "sh", + MS-DOS and Win32: "command.com" or + "cmd.exe", OS/2: "cmd") + global + Name of the shell to use for ! and :! commands. When changing the + value also check these options: 'shelltype', 'shellpipe', 'shellslash' + 'shellredir', 'shellquote', 'shellxquote' and 'shellcmdflag'. + It is allowed to give an argument to the command, e.g. "csh -f". + See |option-backslash| about including spaces and backslashes. + Environment variables are expanded |:set_env|. + If the name of the shell contains a space, you might need to enclose + it in quotes. Example: > + :set shell=\"c:\program\ files\unix\sh.exe\"\ -f +< Note the backslash before each quote (to avoid starting a comment) and + each space (to avoid ending the option value). Also note that the + "-f" is not inside the quotes, because it is not part of the command + name. And Vim automagically recognizes the backslashes that are path + separators. + For Dos 32 bits (DJGPP), you can set the $DJSYSFLAGS environment + variable to change the way external commands are executed. See the + libc.inf file of DJGPP. + Under MS-Windows, when the executable ends in ".com" it must be + included. Thus setting the shell to "command.com" or "4dos.com" + works, but "command" and "4dos" do not work for all commands (e.g., + filtering). + For unknown reasons, when using "4dos.com" the current directory is + changed to "C:\". To avoid this set 'shell' like this: > + :set shell=command.com\ /c\ 4dos +< This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'shellcmdflag'* *'shcf'* +'shellcmdflag' 'shcf' string (default: "-c", MS-DOS and Win32, when 'shell' + does not contain "sh" somewhere: "/c") + global + {not in Vi} + Flag passed to the shell to execute "!" and ":!" commands; e.g., + "bash.exe -c ls" or "command.com /c dir". For the MS-DOS-like + systems, the default is set according to the value of 'shell', to + reduce the need to set this option by the user. It's not used for + OS/2 (EMX figures this out itself). See |option-backslash| about + including spaces and backslashes. See |dos-shell|. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'shellpipe'* *'sp'* +'shellpipe' 'sp' string (default ">", "| tee", "|& tee" or "2>&1| tee") + global + {not in Vi} + {not available when compiled without the |+quickfix| + feature} + String to be used to put the output of the ":make" command in the + error file. See also |:make_makeprg|. See |option-backslash| about + including spaces and backslashes. + The name of the temporary file can be represented by "%s" if necessary + (the file name is appended automatically if no %s appears in the value + of this option). + For the Amiga and MS-DOS the default is ">". The output is directly + saved in a file and not echoed to the screen. + For Unix the default it "| tee". The stdout of the compiler is saved + in a file and echoed to the screen. If the 'shell' option is "csh" or + "tcsh" after initializations, the default becomes "|& tee". If the + 'shell' option is "sh", "ksh", "zsh" or "bash" the default becomes + "2>&1| tee". This means that stderr is also included. Before using + the 'shell' option a path is removed, thus "/bin/sh" uses "sh". + The initialization of this option is done after reading the ".vimrc" + and the other initializations, so that when the 'shell' option is set + there, the 'shellpipe' option changes automatically, unless it was + explicitly set before. + When 'shellpipe' is set to an empty string, no redirection of the + ":make" output will be done. This is useful if you use a 'makeprg' + that writes to 'makeef' by itself. If you want no piping, but do + want to include the 'makeef', set 'shellpipe' to a single space. + Don't forget to precede the space with a backslash: ":set sp=\ ". + In the future pipes may be used for filtering and this option will + become obsolete (at least for Unix). + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'shellquote'* *'shq'* +'shellquote' 'shq' string (default: ""; MS-DOS and Win32, when 'shell' + contains "sh" somewhere: "\"") + global + {not in Vi} + Quoting character(s), put around the command passed to the shell, for + the "!" and ":!" commands. The redirection is kept outside of the + quoting. See 'shellxquote' to include the redirection. It's + probably not useful to set both options. + This is an empty string by default. Only known to be useful for + third-party shells on MS-DOS-like systems, such as the MKS Korn Shell + or bash, where it should be "\"". The default is adjusted according + the value of 'shell', to reduce the need to set this option by the + user. See |dos-shell|. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'shellredir'* *'srr'* +'shellredir' 'srr' string (default ">", ">&" or ">%s 2>&1") + global + {not in Vi} + String to be used to put the output of a filter command in a temporary + file. See also |:!|. See |option-backslash| about including spaces + and backslashes. + The name of the temporary file can be represented by "%s" if necessary + (the file name is appended automatically if no %s appears in the value + of this option). + The default is ">". For Unix, if the 'shell' option is "csh", "tcsh" + or "zsh" during initializations, the default becomes ">&". If the + 'shell' option is "sh", "ksh" or "bash" the default becomes + ">%s 2>&1". This means that stderr is also included. + For Win32, the Unix checks are done and additionally "cmd" is checked + for, which makes the default ">%s 2>&1". Also, the same names with + ".exe" appended are checked for. + The initialization of this option is done after reading the ".vimrc" + and the other initializations, so that when the 'shell' option is set + there, the 'shellredir' option changes automatically unless it was + explicitly set before. + In the future pipes may be used for filtering and this option will + become obsolete (at least for Unix). + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'shellslash'* *'ssl'* *'noshellslash'* *'nossl'* +'shellslash' 'ssl' boolean (default off) + global + {not in Vi} {only for MSDOS, MS-Windows and OS/2} + When set, a forward slash is used when expanding file names. This is + useful when a Unix-like shell is used instead of command.com or + cmd.exe. Backward slashes can still be typed, but they are changed to + forward slashes by Vim. + Note that setting or resetting this option has no effect for some + existing file names, thus this option needs to be set before opening + any file for best results. This might change in the future. + 'shellslash' only works when a backslash can be used as a path + separator. To test if this is so use: > + if exists('+shellslash') +< + *'shelltemp'* *'stmp'* *'noshelltemp'* *'nostmp'* +'shelltemp' 'stmp' boolean (Vi default off, Vim default on) + global + {not in Vi} + When on, use temp files for shell commands. When off use a pipe. + When using a pipe is not possible temp files are used anyway. + Currently a pipe is only supported on Unix. You can check it with: > + :if has("filterpipe") +< The advantage of using a pipe is that nobody can read the temp file + and the 'shell' command does not need to support redirection. + The advantage of using a temp file is that the file type and encoding + can be detected. + The |FilterReadPre|, |FilterReadPost| and |FilterWritePre|, + |FilterWritePost| autocommands event are not triggered when + 'shelltemp' is off. + + *'shelltype'* *'st'* +'shelltype' 'st' number (default 0) + global + {not in Vi} {only for the Amiga} + On the Amiga this option influences the way how the commands work + which use a shell. + 0 and 1: always use the shell + 2 and 3: use the shell only to filter lines + 4 and 5: use shell only for ':sh' command + When not using the shell, the command is executed directly. + + 0 and 2: use "shell 'shellcmdflag' cmd" to start external commands + 1 and 3: use "shell cmd" to start external commands + + *'shellxquote'* *'sxq'* +'shellxquote' 'sxq' string (default: ""; + for Win32, when 'shell' contains "sh" + somewhere: "\"" + for Unix, when using system(): "\"") + global + {not in Vi} + Quoting character(s), put around the command passed to the shell, for + the "!" and ":!" commands. Includes the redirection. See + 'shellquote' to exclude the redirection. It's probably not useful + to set both options. + This is an empty string by default. Known to be useful for + third-party shells when using the Win32 version, such as the MKS Korn + Shell or bash, where it should be "\"". The default is adjusted + according the value of 'shell', to reduce the need to set this option + by the user. See |dos-shell|. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'shiftround'* *'sr'* *'noshiftround'* *'nosr'* +'shiftround' 'sr' boolean (default off) + global + {not in Vi} + Round indent to multiple of 'shiftwidth'. Applies to > and < + commands. CTRL-T and CTRL-D in Insert mode always round the indent to + a multiple of 'shiftwidth' (this is Vi compatible). + NOTE: This option is reset when 'compatible' is set. + + *'shiftwidth'* *'sw'* +'shiftwidth' 'sw' number (default 8) + local to buffer + Number of spaces to use for each step of (auto)indent. Used for + |'cindent'|, |>>|, |<<|, etc. + + *'shortmess'* *'shm'* +'shortmess' 'shm' string (Vim default "filnxtToO", Vi default: "", + POSIX default: "A") + global + {not in Vi} + This option helps to avoid all the |hit-enter| prompts caused by file + messages, for example with CTRL-G, and to avoid some other messages. + It is a list of flags: + flag meaning when present ~ + f use "(3 of 5)" instead of "(file 3 of 5)" + i use "[noeol]" instead of "[Incomplete last line]" + l use "999L, 888C" instead of "999 lines, 888 characters" + m use "[+]" instead of "[Modified]" + n use "[New]" instead of "[New File]" + r use "[RO]" instead of "[readonly]" + w use "[w]" instead of "written" for file write message + and "[a]" instead of "appended" for ':w >> file' command + x use "[dos]" instead of "[dos format]", "[unix]" instead of + "[unix format]" and "[mac]" instead of "[mac format]". + a all of the above abbreviations + + o overwrite message for writing a file with subsequent message + for reading a file (useful for ":wn" or when 'autowrite' on) + O message for reading a file overwrites any previous message. + Also for quickfix message (e.g., ":cn"). + s don't give "search hit BOTTOM, continuing at TOP" or "search + hit TOP, continuing at BOTTOM" messages + t truncate file message at the start if it is too long to fit + on the command-line, "<" will appear in the left most column. + Ignored in Ex mode. + T truncate other messages in the middle if they are too long to + fit on the command line. "..." will appear in the middle. + Ignored in Ex mode. + W don't give "written" or "[w]" when writing a file + A don't give the "ATTENTION" message when an existing swap file + is found. + I don't give the intro message when starting Vim |:intro|. + + This gives you the opportunity to avoid that a change between buffers + requires you to hit , but still gives as useful a message as + possible for the space available. To get the whole message that you + would have got with 'shm' empty, use ":file!" + Useful values: + shm= No abbreviation of message. + shm=a Abbreviation, but no loss of information. + shm=at Abbreviation, and truncate message when necessary. + + NOTE: This option is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + + *'shortname'* *'sn'* *'noshortname'* *'nosn'* +'shortname' 'sn' boolean (default off) + local to buffer + {not in Vi, not in MS-DOS versions} + Filenames are assumed to be 8 characters plus one extension of 3 + characters. Multiple dots in file names are not allowed. When this + option is on, dots in file names are replaced with underscores when + adding an extension (".~" or ".swp"). This option is not available + for MS-DOS, because then it would always be on. This option is useful + when editing files on an MS-DOS compatible filesystem, e.g., messydos + or crossdos. When running the Win32 GUI version under Win32s, this + option is always on by default. + + *'showbreak'* *'sbr'* *E595* +'showbreak' 'sbr' string (default "") + global + {not in Vi} + {not available when compiled without the |+linebreak| + feature} + String to put at the start of lines that have been wrapped. Useful + values are "> " or "+++ ": > + :set showbreak=>\ +< Note the backslash to escape the trailing space. It's easier like + this: > + :let &showbreak = '+++ ' +< Only printable single-cell characters are allowed, excluding and + comma (in a future version the comma might be used to separate the + part that is shown at the end and at the start of a line). + The characters are highlighted according to the '@' flag in + 'highlight'. + Note that tabs after the showbreak will be displayed differently. + If you want the 'showbreak' to appear in between line numbers, add the + "n" flag to 'cpoptions'. + + *'showcmd'* *'sc'* *'noshowcmd'* *'nosc'* +'showcmd' 'sc' boolean (Vim default: on, off for Unix, Vi default: + off) + global + {not in Vi} + {not available when compiled without the + |+cmdline_info| feature} + Show (partial) command in the last line of the screen. Set this + option off if your terminal is slow. + In Visual mode the size of the selected area is shown: + - When selecting characters within a line, the number of characters. + If the number of bytes is different it is also displayed: "2-6" + means two characters and six bytes. + - When selecting more than one line, the number of lines. + - When selecting a block, the size in screen characters: + {lines}x{columns}. + NOTE: This option is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + + *'showfulltag'* *'sft'* *'noshowfulltag'* *'nosft'* +'showfulltag' 'sft' boolean (default off) + global + {not in Vi} + When completing a word in insert mode (see |ins-completion|) from the + tags file, show both the tag name and a tidied-up form of the search + pattern (if there is one) as possible matches. Thus, if you have + matched a C function, you can see a template for what arguments are + required (coding style permitting). + Note that this doesn't work well together with having "longest" in + 'completeopt', because the completion from the search pattern may not + match the typed text. + + *'showmatch'* *'sm'* *'noshowmatch'* *'nosm'* +'showmatch' 'sm' boolean (default off) + global + When a bracket is inserted, briefly jump to the matching one. The + jump is only done if the match can be seen on the screen. The time to + show the match can be set with 'matchtime'. + A Beep is given if there is no match (no matter if the match can be + seen or not). This option is reset when the 'paste' option is set. + When the 'm' flag is not included in 'cpoptions', typing a character + will immediately move the cursor back to where it belongs. + See the "sm" field in 'guicursor' for setting the cursor shape and + blinking when showing the match. + The 'matchpairs' option can be used to specify the characters to show + matches for. 'rightleft' and 'revins' are used to look for opposite + matches. + Also see the matchparen plugin for highlighting the match when moving + around |pi_paren.txt|. + Note: Use of the short form is rated PG. + + *'showmode'* *'smd'* *'noshowmode'* *'nosmd'* +'showmode' 'smd' boolean (Vim default: on, Vi default: off) + global + If in Insert, Replace or Visual mode put a message on the last line. + Use the 'M' flag in 'highlight' to set the type of highlighting for + this message. + When |XIM| may be used the message will include "XIM". But this + doesn't mean XIM is really active, especially when 'imactivatekey' is + not set. + NOTE: This option is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + + *'showtabline'* *'stal'* +'showtabline' 'stal' number (default 1) + global + {not in Vi} + {not available when compiled without the |+windows| + feature} + The value of this option specifies when the line with tab page labels + will be displayed: + 0: never + 1: only if there are at least two tab pages + 2: always + This is both for the GUI and non-GUI implementation of the tab pages + line. + See |tab-page| for more information about tab pages. + + *'sidescroll'* *'ss'* +'sidescroll' 'ss' number (default 0) + global + {not in Vi} + The minimal number of columns to scroll horizontally. Used only when + the 'wrap' option is off and the cursor is moved off of the screen. + When it is zero the cursor will be put in the middle of the screen. + When using a slow terminal set it to a large number or 0. When using + a fast terminal use a small number or 1. Not used for "zh" and "zl" + commands. + + *'sidescrolloff'* *'siso'* +'sidescrolloff' 'siso' number (default 0) + global + {not in Vi} + The minimal number of screen columns to keep to the left and to the + right of the cursor if 'nowrap' is set. Setting this option to a + value greater than 0 while having |'sidescroll'| also at a non-zero + value makes some context visible in the line you are scrolling in + horizontally (except at beginning of the line). Setting this option + to a large value (like 999) has the effect of keeping the cursor + horizontally centered in the window, as long as one does not come too + close to the beginning of the line. + NOTE: This option is set to 0 when 'compatible' is set. + + Example: Try this together with 'sidescroll' and 'listchars' as + in the following example to never allow the cursor to move + onto the "extends" character: + + :set nowrap sidescroll=1 listchars=extends:>,precedes:< + :set sidescrolloff=1 + + + *'smartcase'* *'scs'* *'nosmartcase'* *'noscs'* +'smartcase' 'scs' boolean (default off) + global + {not in Vi} + Override the 'ignorecase' option if the search pattern contains upper + case characters. Only used when the search pattern is typed and + 'ignorecase' option is on. Used for the commands "/", "?", "n", "N", + ":g" and ":s". Not used for "*", "#", "gd", tag search, etc.. After + "*" and "#" you can make 'smartcase' used by doing a "/" command, + recalling the search pattern from history and hitting . + NOTE: This option is reset when 'compatible' is set. + + *'smartindent'* *'si'* *'nosmartindent'* *'nosi'* +'smartindent' 'si' boolean (default off) + local to buffer + {not in Vi} + {not available when compiled without the + |+smartindent| feature} + Do smart autoindenting when starting a new line. Works for C-like + programs, but can also be used for other languages. 'cindent' does + something like this, works better in most cases, but is more strict, + see |C-indenting|. When 'cindent' is on, setting 'si' has no effect. + 'indentexpr' is a more advanced alternative. + Normally 'autoindent' should also be on when using 'smartindent'. + An indent is automatically inserted: + - After a line ending in '{'. + - After a line starting with a keyword from 'cinwords'. + - Before a line starting with '}' (only with the "O" command). + When typing '}' as the first character in a new line, that line is + given the same indent as the matching '{'. + When typing '#' as the first character in a new line, the indent for + that line is removed, the '#' is put in the first column. The indent + is restored for the next line. If you don't want this, use this + mapping: ":inoremap # X^H#", where ^H is entered with CTRL-V CTRL-H. + When using the ">>" command, lines starting with '#' are not shifted + right. + NOTE: 'smartindent' is reset when 'compatible' is set. When 'paste' + is set smart indenting is disabled. + + *'smarttab'* *'sta'* *'nosmarttab'* *'nosta'* +'smarttab' 'sta' boolean (default off) + global + {not in Vi} + When on, a in front of a line inserts blanks according to + 'shiftwidth'. 'tabstop' or 'softtabstop' is used in other places. A + will delete a 'shiftwidth' worth of space at the start of the + line. + When off, a always inserts blanks according to 'tabstop' or + 'softtabstop'. 'shiftwidth' is only used for shifting text left or + right |shift-left-right|. + What gets inserted (a or spaces) depends on the 'expandtab' + option. Also see |ins-expandtab|. When 'expandtab' is not set, the + number of spaces is minimized by using s. + NOTE: This option is reset when 'compatible' is set. + + *'softtabstop'* *'sts'* +'softtabstop' 'sts' number (default 0) + local to buffer + {not in Vi} + Number of spaces that a counts for while performing editing + operations, like inserting a or using . It "feels" like + s are being inserted, while in fact a mix of spaces and s is + used. This is useful to keep the 'ts' setting at its standard value + of 8, while being able to edit like it is set to 'sts'. However, + commands like "x" still work on the actual characters. + When 'sts' is zero, this feature is off. + 'softtabstop' is set to 0 when the 'paste' option is set. + See also |ins-expandtab|. When 'expandtab' is not set, the number of + spaces is minimized by using s. + The 'L' flag in 'cpoptions' changes how tabs are used when 'list' is + set. + NOTE: This option is set to 0 when 'compatible' is set. + + *'spell'* *'nospell'* +'spell' boolean (default off) + local to window + {not in Vi} + {not available when compiled without the |+syntax| + feature} + When on spell checking will be done. See |spell|. + The languages are specified with 'spelllang'. + + *'spellcapcheck'* *'spc'* +'spellcapcheck' 'spc' string (default "[.?!]\_[\])'" \t]\+") + local to buffer + {not in Vi} + {not available when compiled without the |+syntax| + feature} + Pattern to locate the end of a sentence. The following word will be + checked to start with a capital letter. If not then it is highlighted + with SpellCap |hl-SpellCap| (unless the word is also badly spelled). + When this check is not wanted make this option empty. + Only used when 'spell' is set. + Be careful with special characters, see |option-backslash| about + including spaces and backslashes. + To set this option automatically depending on the language, see + |set-spc-auto|. + + *'spellfile'* *'spf'* +'spellfile' 'spf' string (default empty) + local to buffer + {not in Vi} + {not available when compiled without the |+syntax| + feature} + Name of the word list file where words are added for the |zg| and |zw| + commands. It must end in ".{encoding}.add". You need to include the + path, otherwise the file is placed in the current directory. + *E765* + It may also be a comma separated list of names. A count before the + |zg| and |zw| commands can be used to access each. This allows using + a personal word list file and a project word list file. + When a word is added while this option is empty Vim will set it for + you: Using the first directory in 'runtimepath' that is writable. If + there is no "spell" directory yet it will be created. For the file + name the first language name that appears in 'spelllang' is used, + ignoring the region. + The resulting ".spl" file will be used for spell checking, it does not + have to appear in 'spelllang'. + Normally one file is used for all regions, but you can add the region + name if you want to. However, it will then only be used when + 'spellfile' is set to it, for entries in 'spelllang' only files + without region name will be found. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'spelllang'* *'spl'* +'spelllang' 'spl' string (default "en") + local to buffer + {not in Vi} + {not available when compiled without the |+syntax| + feature} + A comma separated list of word list names. When the 'spell' option is + on spellchecking will be done for these languages. Example: > + set spelllang=en_us,nl,medical +< This means US English, Dutch and medical words are recognized. Words + that are not recognized will be highlighted. + The word list name must not include a comma or dot. Using a dash is + recommended to separate the two letter language name from a + specification. Thus "en-rare" is used for rare English words. + A region name must come last and have the form "_xx", where "xx" is + the two-letter, lower case region name. You can use more than one + region by listing them: "en_us,en_ca" supports both US and Canadian + English, but not words specific for Australia, New Zealand or Great + Britain. + *E757* + As a special case the name of a .spl file can be given as-is. The + first "_xx" in the name is removed and used as the region name + (_xx is an underscore, two letters and followed by a non-letter). + This is mainly for testing purposes. You must make sure the correct + encoding is used, Vim doesn't check it. + When 'encoding' is set the word lists are reloaded. Thus it's a good + idea to set 'spelllang' after setting 'encoding' to avoid loading the + files twice. + How the related spell files are found is explained here: |spell-load|. + + If the |spellfile.vim| plugin is active and you use a language name + for which Vim cannot find the .spl file in 'runtimepath' the plugin + will ask you if you want to download the file. + + After this option has been set successfully, Vim will source the files + "spell/LANG.vim" in 'runtimepath'. "LANG" is the value of 'spelllang' + up to the first comma, dot or underscore. + Also see |set-spc-auto|. + + + *'spellsuggest'* *'sps'* +'spellsuggest' 'sps' string (default "best") + global + {not in Vi} + {not available when compiled without the |+syntax| + feature} + Methods used for spelling suggestions. Both for the |z=| command and + the |spellsuggest()| function. This is a comma-separated list of + items: + + best Internal method that works best for English. Finds + changes like "fast" and uses a bit of sound-a-like + scoring to improve the ordering. + + double Internal method that uses two methods and mixes the + results. The first method is "fast", the other method + computes how much the suggestion sounds like the bad + word. That only works when the language specifies + sound folding. Can be slow and doesn't always give + better results. + + fast Internal method that only checks for simple changes: + character inserts/deletes/swaps. Works well for + simple typing mistakes. + + {number} The maximum number of suggestions listed for |z=|. + Not used for |spellsuggest()|. The number of + suggestions is never more than the value of 'lines' + minus two. + + file:{filename} Read file {filename}, which must have two columns, + separated by a slash. The first column contains the + bad word, the second column the suggested good word. + Example: + theribal/terrible ~ + Use this for common mistakes that do not appear at the + top of the suggestion list with the internal methods. + Lines without a slash are ignored, use this for + comments. + The file is used for all languages. + + expr:{expr} Evaluate expression {expr}. Use a function to avoid + trouble with spaces. |v:val| holds the badly spelled + word. The expression must evaluate to a List of + Lists, each with a suggestion and a score. + Example: + [['the', 33], ['that', 44]] + Set 'verbose' and use |z=| to see the scores that the + internal methods use. A lower score is better. + This may invoke |spellsuggest()| if you temporarily + set 'spellsuggest' to exclude the "expr:" part. + Errors are silently ignored, unless you set the + 'verbose' option to a non-zero value. + + Only one of "best", "double" or "fast" may be used. The others may + appear several times in any order. Example: > + :set sps=file:~/.vim/sugg,best,expr:MySuggest() +< + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + + *'splitbelow'* *'sb'* *'nosplitbelow'* *'nosb'* +'splitbelow' 'sb' boolean (default off) + global + {not in Vi} + {not available when compiled without the |+windows| + feature} + When on, splitting a window will put the new window below the current + one. |:split| + + *'splitright'* *'spr'* *'nosplitright'* *'nospr'* +'splitright' 'spr' boolean (default off) + global + {not in Vi} + {not available when compiled without the |+vertsplit| + feature} + When on, splitting a window will put the new window right of the + current one. |:vsplit| + + *'startofline'* *'sol'* *'nostartofline'* *'nosol'* +'startofline' 'sol' boolean (default on) + global + {not in Vi} + When "on" the commands listed below move the cursor to the first + non-blank of the line. When off the cursor is kept in the same column + (if possible). This applies to the commands: CTRL-D, CTRL-U, CTRL-B, + CTRL-F, "G", "H", "M", "L", gg, and to the commands "d", "<<" and ">>" + with a linewise operator, with "%" with a count and to buffer changing + commands (CTRL-^, :bnext, :bNext, etc.). Also for an Ex command that + only has a line number, e.g., ":25" or ":+". + In case of buffer changing commands the cursor is placed at the column + where it was the last time the buffer was edited. + NOTE: This option is set when 'compatible' is set. + + *'statusline'* *'stl'* *E540* *E541* *E542* +'statusline' 'stl' string (default empty) + global or local to window |global-local| + {not in Vi} + {not available when compiled without the |+statusline| + feature} + When nonempty, this option determines the content of the status line. + Also see |status-line|. + + The option consists of printf style '%' items interspersed with + normal text. Each status line item is of the form: + %-0{minwid}.{maxwid}{item} + All fields except the {item} is optional. A single percent sign can + be given as "%%". Up to 80 items can be specified. + + When the option starts with "%!" then it is used as an expression, + evaluated and the result is used as the option value. Example: > + :set statusline=%!MyStatusLine() +< The result can contain %{} items that will be evaluated too. + + When there is error while evaluating the option then it will be made + empty to avoid further errors. Otherwise screen updating would loop. + + Note that the only effect of 'ruler' when this option is set (and + 'laststatus' is 2) is controlling the output of |CTRL-G|. + + field meaning ~ + - Left justify the item. The default is right justified + when minwid is larger than the length of the item. + 0 Leading zeroes in numeric items. Overridden by '-'. + minwid Minimum width of the item, padding as set by '-' & '0'. + Value must be 50 or less. + maxwid Maximum width of the item. Truncation occurs with a '<' + on the left for text items. Numeric items will be + shifted down to maxwid-2 digits followed by '>'number + where number is the amount of missing digits, much like + an exponential notation. + item A one letter code as described below. + + Following is a description of the possible statusline items. The + second character in "item" is the type: + N for number + S for string + F for flags as described below + - not applicable + + item meaning ~ + f S Path to the file in the buffer, as typed or relative to current + directory. + F S Full path to the file in the buffer. + t S File name (tail) of file in the buffer. + m F Modified flag, text is "[+]"; "[-]" if 'modifiable' is off. + M F Modified flag, text is ",+" or ",-". + r F Readonly flag, text is "[RO]". + R F Readonly flag, text is ",RO". + h F Help buffer flag, text is "[help]". + H F Help buffer flag, text is ",HLP". + w F Preview window flag, text is "[Preview]". + W F Preview window flag, text is ",PRV". + y F Type of file in the buffer, e.g., "[vim]". See 'filetype'. + Y F Type of file in the buffer, e.g., ",VIM". See 'filetype'. + {not available when compiled without |+autocmd| feature} + q S "[Quickfix List]", "[Location List]" or empty. + k S Value of "b:keymap_name" or 'keymap' when |:lmap| mappings are + being used: "" + n N Buffer number. + b N Value of byte under cursor. + B N As above, in hexadecimal. + o N Byte number in file of byte under cursor, first byte is 1. + Mnemonic: Offset from start of file (with one added) + {not available when compiled without |+byte_offset| feature} + O N As above, in hexadecimal. + N N Printer page number. (Only works in the 'printheader' option.) + l N Line number. + L N Number of lines in buffer. + c N Column number. + v N Virtual column number. + V N Virtual column number as -{num}. Not displayed if equal to 'c'. + p N Percentage through file in lines as in |CTRL-G|. + P S Percentage through file of displayed window. This is like the + percentage described for 'ruler'. Always 3 in length. + a S Argument list status as in default title. ({current} of {max}) + Empty if the argument file count is zero or one. + { NF Evaluate expression between '%{' and '}' and substitute result. + Note that there is no '%' before the closing '}'. + ( - Start of item group. Can be used for setting the width and + alignment of a section. Must be followed by %) somewhere. + ) - End of item group. No width fields allowed. + T N For 'tabline': start of tab page N label. Use %T after the last + label. This information is used for mouse clicks. + X N For 'tabline': start of close tab N label. Use %X after the + label, e.g.: %3Xclose%X. Use %999X for a "close current tab" + mark. This information is used for mouse clicks. + < - Where to truncate line if too long. Default is at the start. + No width fields allowed. + = - Separation point between left and right aligned items. + No width fields allowed. + # - Set highlight group. The name must follow and then a # again. + Thus use %#HLname# for highlight group HLname. The same + highlighting is used, also for the statusline of non-current + windows. + * - Set highlight group to User{N}, where {N} is taken from the + minwid field, e.g. %1*. Restore normal highlight with %* or %0*. + The difference between User{N} and StatusLine will be applied + to StatusLineNC for the statusline of non-current windows. + The number N must be between 1 and 9. See |hl-User1..9| + + When displaying a flag, Vim removes the leading comma, if any, when + that flag comes right after plaintext. This will make a nice display + when flags are used like in the examples below. + + When all items in a group becomes an empty string (i.e. flags that are + not set) and a minwid is not set for the group, the whole group will + become empty. This will make a group like the following disappear + completely from the statusline when none of the flags are set. > + :set statusline=...%(\ [%M%R%H]%)... +< + Beware that an expression is evaluated each and every time the status + line is displayed. The current buffer and current window will be set + temporarily to that of the window (and buffer) whose statusline is + currently being drawn. The expression will evaluate in this context. + The variable "actual_curbuf" is set to the 'bufnr()' number of the + real current buffer. + + The 'statusline' option may be evaluated in the |sandbox|, see + |sandbox-option|. + + It is not allowed to change text or jump to another window while + evaluating 'statusline' |textlock|. + + If the statusline is not updated when you want it (e.g., after setting + a variable that's used in an expression), you can force an update by + setting an option without changing its value. Example: > + :let &ro = &ro + +< A result of all digits is regarded a number for display purposes. + Otherwise the result is taken as flag text and applied to the rules + described above. + + Watch out for errors in expressions. They may render Vim unusable! + If you are stuck, hold down ':' or 'Q' to get a prompt, then quit and + edit your .vimrc or whatever with "vim -u NONE" to get it right. + + Examples: + Emulate standard status line with 'ruler' set > + :set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P +< Similar, but add ASCII value of char under the cursor (like "ga") > + :set statusline=%<%f%h%m%r%=%b\ 0x%B\ \ %l,%c%V\ %P +< Display byte count and byte value, modified flag in red. > + :set statusline=%<%f%=\ [%1*%M%*%n%R%H]\ %-19(%3l,%02c%03V%)%O'%02b' + :hi User1 term=inverse,bold cterm=inverse,bold ctermfg=red +< Display a ,GZ flag if a compressed file is loaded > + :set statusline=...%r%{VarExists('b:gzflag','\ [GZ]')}%h... +< In the |:autocmd|'s: > + :let b:gzflag = 1 +< And: > + :unlet b:gzflag +< And define this function: > + :function VarExists(var, val) + : if exists(a:var) | return a:val | else | return '' | endif + :endfunction +< + *'suffixes'* *'su'* +'suffixes' 'su' string (default ".bak,~,.o,.h,.info,.swp,.obj") + global + {not in Vi} + Files with these suffixes get a lower priority when multiple files + match a wildcard. See |suffixes|. Commas can be used to separate the + suffixes. Spaces after the comma are ignored. A dot is also seen as + the start of a suffix. To avoid a dot or comma being recognized as a + separator, precede it with a backslash (see |option-backslash| about + including spaces and backslashes). + See 'wildignore' for completely ignoring files. + The use of |:set+=| and |:set-=| is preferred when adding or removing + suffixes from the list. This avoids problems when a future version + uses another default. + + *'suffixesadd'* *'sua'* +'suffixesadd' 'sua' string (default "") + local to buffer + {not in Vi} + {not available when compiled without the + |+file_in_path| feature} + Comma separated list of suffixes, which are used when searching for a + file for the "gf", "[I", etc. commands. Example: > + :set suffixesadd=.java +< + *'swapfile'* *'swf'* *'noswapfile'* *'noswf'* +'swapfile' 'swf' boolean (default on) + local to buffer + {not in Vi} + Use a swapfile for the buffer. This option can be reset when a + swapfile is not wanted for a specific buffer. For example, with + confidential information that even root must not be able to access. + Careful: All text will be in memory: + - Don't use this for big files. + - Recovery will be impossible! + A swapfile will only be present when |'updatecount'| is non-zero and + 'swapfile' is set. + When 'swapfile' is reset, the swap file for the current buffer is + immediately deleted. When 'swapfile' is set, and 'updatecount' is + non-zero, a swap file is immediately created. + Also see |swap-file| and |'swapsync'|. + + This option is used together with 'bufhidden' and 'buftype' to + specify special kinds of buffers. See |special-buffers|. + + *'swapsync'* *'sws'* +'swapsync' 'sws' string (default "fsync") + global + {not in Vi} + When this option is not empty a swap file is synced to disk after + writing to it. This takes some time, especially on busy unix systems. + When this option is empty parts of the swap file may be in memory and + not written to disk. When the system crashes you may lose more work. + On Unix the system does a sync now and then without Vim asking for it, + so the disadvantage of setting this option off is small. On some + systems the swap file will not be written at all. For a unix system + setting it to "sync" will use the sync() call instead of the default + fsync(), which may work better on some systems. + The 'fsync' option is used for the actual file. + + *'switchbuf'* *'swb'* +'switchbuf' 'swb' string (default "") + global + {not in Vi} + This option controls the behavior when switching between buffers. + Possible values (comma separated list): + useopen If included, jump to the first open window that + contains the specified buffer (if there is one). + Otherwise: Do not examine other windows. + This setting is checked with |quickfix| commands, when + jumping to errors (":cc", ":cn", "cp", etc.). It is + also used in all buffer related split commands, for + example ":sbuffer", ":sbnext", or ":sbrewind". + usetab Like "useopen", but also consider windows in other tab + pages. + split If included, split the current window before loading + a buffer. Otherwise: do not split, use current window. + Supported in |quickfix| commands that display errors. + newtab Like "split", but open a new tab page. Overrules + "split" when both are present. + + *'synmaxcol'* *'smc'* +'synmaxcol' 'smc' number (default 3000) + local to buffer + {not in Vi} + {not available when compiled without the |+syntax| + feature} + Maximum column in which to search for syntax items. In long lines the + text after this column is not highlighted and following lines may not + be highlighted correctly, because the syntax state is cleared. + This helps to avoid very slow redrawing for an XML file that is one + long line. + Set to zero to remove the limit. + + *'syntax'* *'syn'* +'syntax' 'syn' string (default empty) + local to buffer + {not in Vi} + {not available when compiled without the |+syntax| + feature} + When this option is set, the syntax with this name is loaded, unless + syntax highlighting has been switched off with ":syntax off". + Otherwise this option does not always reflect the current syntax (the + b:current_syntax variable does). + This option is most useful in a modeline, for a file which syntax is + not automatically recognized. Example, in an IDL file: + /* vim: set syntax=idl : */ ~ + When a dot appears in the value then this separates two filetype + names. Example: + /* vim: set syntax=c.doxygen : */ ~ + This will use the "c" syntax first, then the "doxygen" syntax. + Note that the second one must be prepared to be loaded as an addition, + otherwise it will be skipped. More than one dot may appear. + To switch off syntax highlighting for the current file, use: > + :set syntax=OFF +< To switch syntax highlighting on according to the current value of the + 'filetype' option: > + :set syntax=ON +< What actually happens when setting the 'syntax' option is that the + Syntax autocommand event is triggered with the value as argument. + This option is not copied to another buffer, independent of the 's' or + 'S' flag in 'cpoptions'. + Only normal file name characters can be used, "/\*?[|<>" are illegal. + + *'tabline'* *'tal'* +'tabline' 'tal' string (default empty) + global + {not in Vi} + {not available when compiled without the |+windows| + feature} + When nonempty, this option determines the content of the tab pages + line at the top of the Vim window. When empty Vim will use a default + tab pages line. See |setting-tabline| for more info. + + The tab pages line only appears as specified with the 'showtabline' + option and only when there is no GUI tab line. When 'e' is in + 'guioptions' and the GUI supports a tab line 'guitablabel' is used + instead. Note that the two tab pages lines are very different. + + The value is evaluated like with 'statusline'. You can use + |tabpagenr()|, |tabpagewinnr()| and |tabpagebuflist()| to figure out + the text to be displayed. Use "%1T" for the first label, "%2T" for + the second one, etc. Use "%X" items for closing labels. + + Keep in mind that only one of the tab pages is the current one, others + are invisible and you can't jump to their windows. + + + *'tabpagemax'* *'tpm'* +'tabpagemax' 'tpm' number (default 10) + global + {not in Vi} + {not available when compiled without the |+windows| + feature} + Maximum number of tab pages to be opened by the |-p| command line + argument or the ":tab all" command. |tabpage| + + + *'tabstop'* *'ts'* +'tabstop' 'ts' number (default 8) + local to buffer + Number of spaces that a in the file counts for. Also see + |:retab| command, and 'softtabstop' option. + + Note: Setting 'tabstop' to any other value than 8 can make your file + appear wrong in many places (e.g., when printing it). + + There are four main ways to use tabs in Vim: + 1. Always keep 'tabstop' at 8, set 'softtabstop' and 'shiftwidth' to 4 + (or 3 or whatever you prefer) and use 'noexpandtab'. Then Vim + will use a mix of tabs and spaces, but typing and will + behave like a tab appears every 4 (or 3) characters. + 2. Set 'tabstop' and 'shiftwidth' to whatever you prefer and use + 'expandtab'. This way you will always insert spaces. The + formatting will never be messed up when 'tabstop' is changed. + 3. Set 'tabstop' and 'shiftwidth' to whatever you prefer and use a + |modeline| to set these values when editing the file again. Only + works when using Vim to edit the file. + 4. Always set 'tabstop' and 'shiftwidth' to the same value, and + 'noexpandtab'. This should then work (for initial indents only) + for any tabstop setting that people use. It might be nice to have + tabs after the first non-blank inserted as spaces if you do this + though. Otherwise aligned comments will be wrong when 'tabstop' is + changed. + + *'tagbsearch'* *'tbs'* *'notagbsearch'* *'notbs'* +'tagbsearch' 'tbs' boolean (default on) + global + {not in Vi} + When searching for a tag (e.g., for the |:ta| command), Vim can either + use a binary search or a linear search in a tags file. Binary + searching makes searching for a tag a LOT faster, but a linear search + will find more tags if the tags file wasn't properly sorted. + Vim normally assumes that your tags files are sorted, or indicate that + they are not sorted. Only when this is not the case does the + 'tagbsearch' option need to be switched off. + + When 'tagbsearch' is on, binary searching is first used in the tags + files. In certain situations, Vim will do a linear search instead for + certain files, or retry all files with a linear search. When + 'tagbsearch' is off, only a linear search is done. + + Linear searching is done anyway, for one file, when Vim finds a line + at the start of the file indicating that it's not sorted: > + !_TAG_FILE_SORTED 0 /some comment/ +< [The whitespace before and after the '0' must be a single ] + + When a binary search was done and no match was found in any of the + files listed in 'tags', and 'ignorecase' is set or a pattern is used + instead of a normal tag name, a retry is done with a linear search. + Tags in unsorted tags files, and matches with different case will only + be found in the retry. + + If a tag file indicates that it is case-fold sorted, the second, + linear search can be avoided for the 'ignorecase' case. Use a value + of '2' in the "!_TAG_FILE_SORTED" line for this. A tag file can be + case-fold sorted with the -f switch to "sort" in most unices, as in + the command: "sort -f -o tags tags". For "Exuberant ctags" version + 5.x or higher (at least 5.5) the --sort=foldcase switch can be used + for this as well. Note that case must be folded to uppercase for this + to work. + + When 'tagbsearch' is off, tags searching is slower when a full match + exists, but faster when no full match exists. Tags in unsorted tags + files may only be found with 'tagbsearch' off. + When the tags file is not sorted, or sorted in a wrong way (not on + ASCII byte value), 'tagbsearch' should be off, or the line given above + must be included in the tags file. + This option doesn't affect commands that find all matching tags (e.g., + command-line completion and ":help"). + {Vi: always uses binary search in some versions} + + *'taglength'* *'tl'* +'taglength' 'tl' number (default 0) + global + If non-zero, tags are significant up to this number of characters. + + *'tagrelative'* *'tr'* *'notagrelative'* *'notr'* +'tagrelative' 'tr' boolean (Vim default: on, Vi default: off) + global + {not in Vi} + If on and using a tags file in another directory, file names in that + tags file are relative to the directory where the tags file is. + NOTE: This option is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + + *'tags'* *'tag'* *E433* +'tags' 'tag' string (default "./tags,tags", when compiled with + |+emacs_tags|: "./tags,./TAGS,tags,TAGS") + global or local to buffer |global-local| + Filenames for the tag command, separated by spaces or commas. To + include a space or comma in a file name, precede it with a backslash + (see |option-backslash| about including spaces and backslashes). + When a file name starts with "./", the '.' is replaced with the path + of the current file. But only when the 'd' flag is not included in + 'cpoptions'. Environment variables are expanded |:set_env|. Also see + |tags-option|. + "*", "**" and other wildcards can be used to search for tags files in + a directory tree. See |file-searching|. E.g., "/lib/**/tags" will + find all files named "tags" below "/lib". The filename itself cannot + contain wildcards, it is used as-is. E.g., "/lib/**/tags?" will find + files called "tags?". {not available when compiled without the + |+path_extra| feature} + The |tagfiles()| function can be used to get a list of the file names + actually used. + If Vim was compiled with the |+emacs_tags| feature, Emacs-style tag + files are also supported. They are automatically recognized. The + default value becomes "./tags,./TAGS,tags,TAGS", unless case + differences are ignored (MS-Windows). |emacs-tags| + The use of |:set+=| and |:set-=| is preferred when adding or removing + file names from the list. This avoids problems when a future version + uses another default. + {Vi: default is "tags /usr/lib/tags"} + + *'tagstack'* *'tgst'* *'notagstack'* *'notgst'* +'tagstack' 'tgst' boolean (default on) + global + {not in all versions of Vi} + When on, the |tagstack| is used normally. When off, a ":tag" or + ":tselect" command with an argument will not push the tag onto the + tagstack. A following ":tag" without an argument, a ":pop" command or + any other command that uses the tagstack will use the unmodified + tagstack, but does change the pointer to the active entry. + Resetting this option is useful when using a ":tag" command in a + mapping which should not change the tagstack. + + *'term'* *E529* *E530* *E531* +'term' string (default is $TERM, if that fails: + in the GUI: "builtin_gui" + on Amiga: "amiga" + on BeOS: "beos-ansi" + on Mac: "mac-ansi" + on MiNT: "vt52" + on MS-DOS: "pcterm" + on OS/2: "os2ansi" + on Unix: "ansi" + on VMS: "ansi" + on Win 32: "win32") + global + Name of the terminal. Used for choosing the terminal control + characters. Environment variables are expanded |:set_env|. + For example: > + :set term=$TERM +< See |termcap|. + + *'termbidi'* *'tbidi'* + *'notermbidi'* *'notbidi'* +'termbidi' 'tbidi' boolean (default off, on for "mlterm") + global + {not in Vi} + {only available when compiled with the |+arabic| + feature} + The terminal is in charge of Bi-directionality of text (as specified + by Unicode). The terminal is also expected to do the required shaping + that some languages (such as Arabic) require. + Setting this option implies that 'rightleft' will not be set when + 'arabic' is set and the value of 'arabicshape' will be ignored. + Note that setting 'termbidi' has the immediate effect that + 'arabicshape' is ignored, but 'rightleft' isn't changed automatically. + This option is reset when the GUI is started. + For further details see |arabic.txt|. + + *'termencoding'* *'tenc'* +'termencoding' 'tenc' string (default ""; with GTK+ 2 GUI: "utf-8"; with + Macintosh GUI: "macroman") + global + {only available when compiled with the |+multi_byte| + feature} + {not in Vi} + Encoding used for the terminal. This specifies what character + encoding the keyboard produces and the display will understand. For + the GUI it only applies to the keyboard ('encoding' is used for the + display). Except for the Mac when 'macatsui' is off, then + 'termencoding' should be "macroman". + In the Win32 console version the default value is the console codepage + when it differs from the ANSI codepage. + *E617* + Note: This does not apply to the GTK+ 2 GUI. After the GUI has been + successfully initialized, 'termencoding' is forcibly set to "utf-8". + Any attempts to set a different value will be rejected, and an error + message is shown. + For the Win32 GUI 'termencoding' is not used for typed characters, + because the Win32 system always passes Unicode characters. + When empty, the same encoding is used as for the 'encoding' option. + This is the normal value. + Not all combinations for 'termencoding' and 'encoding' are valid. See + |encoding-table|. + The value for this option must be supported by internal conversions or + iconv(). When this is not possible no conversion will be done and you + will probably experience problems with non-ASCII characters. + Example: You are working with the locale set to euc-jp (Japanese) and + want to edit a UTF-8 file: > + :let &termencoding = &encoding + :set encoding=utf-8 +< You need to do this when your system has no locale support for UTF-8. + + *'terse'* *'noterse'* +'terse' boolean (default off) + global + When set: Add 's' flag to 'shortmess' option (this makes the message + for a search that hits the start or end of the file not being + displayed). When reset: Remove 's' flag from 'shortmess' option. {Vi + shortens a lot of messages} + + *'textauto'* *'ta'* *'notextauto'* *'nota'* +'textauto' 'ta' boolean (Vim default: on, Vi default: off) + global + {not in Vi} + This option is obsolete. Use 'fileformats'. + For backwards compatibility, when 'textauto' is set, 'fileformats' is + set to the default value for the current system. When 'textauto' is + reset, 'fileformats' is made empty. + NOTE: This option is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + + *'textmode'* *'tx'* *'notextmode'* *'notx'* +'textmode' 'tx' boolean (MS-DOS, Win32 and OS/2: default on, + others: default off) + local to buffer + {not in Vi} + This option is obsolete. Use 'fileformat'. + For backwards compatibility, when 'textmode' is set, 'fileformat' is + set to "dos". When 'textmode' is reset, 'fileformat' is set to + "unix". + + *'textwidth'* *'tw'* +'textwidth' 'tw' number (default 0) + local to buffer + {not in Vi} + Maximum width of text that is being inserted. A longer line will be + broken after white space to get this width. A zero value disables + this. 'textwidth' is set to 0 when the 'paste' option is set. When + 'textwidth' is zero, 'wrapmargin' may be used. See also + 'formatoptions' and |ins-textwidth|. + When 'formatexpr' is set it will be used to break the line. + NOTE: This option is set to 0 when 'compatible' is set. + + *'thesaurus'* *'tsr'* +'thesaurus' 'tsr' string (default "") + global or local to buffer |global-local| + {not in Vi} + List of file names, separated by commas, that are used to lookup words + for thesaurus completion commands |i_CTRL-X_CTRL-T|. Each line in + the file should contain words with similar meaning, separated by + non-keyword characters (white space is preferred). Maximum line + length is 510 bytes. + To obtain a file to be used here, check out the wordlist FAQ at + http://www.hyphenologist.co.uk . + To include a comma in a file name precede it with a backslash. Spaces + after a comma are ignored, otherwise spaces are included in the file + name. See |option-backslash| about using backslashes. + The use of |:set+=| and |:set-=| is preferred when adding or removing + directories from the list. This avoids problems when a future version + uses another default. + Backticks cannot be used in this option for security reasons. + + *'tildeop'* *'top'* *'notildeop'* *'notop'* +'tildeop' 'top' boolean (default off) + global + {not in Vi} + When on: The tilde command "~" behaves like an operator. + NOTE: This option is reset when 'compatible' is set. + + *'timeout'* *'to'* *'notimeout'* *'noto'* +'timeout' 'to' boolean (default on) + global + *'ttimeout'* *'nottimeout'* +'ttimeout' boolean (default off) + global + {not in Vi} + These two options together determine the behavior when part of a + mapped key sequence or keyboard code has been received: + + 'timeout' 'ttimeout' action ~ + off off do not time out + on on or off time out on :mappings and key codes + off on time out on key codes + + If both options are off, Vim will wait until either the complete + mapping or key sequence has been received, or it is clear that there + is no mapping or key sequence for the received characters. For + example: if you have mapped "vl" and Vim has received 'v', the next + character is needed to see if the 'v' is followed by an 'l'. + When one of the options is on, Vim will wait for about 1 second for + the next character to arrive. After that the already received + characters are interpreted as single characters. The waiting time can + be changed with the 'timeoutlen' option. + On slow terminals or very busy systems timing out may cause + malfunctioning cursor keys. If both options are off, Vim waits + forever after an entered if there are key codes that start + with . You will have to type twice. If you do not have + problems with key codes, but would like to have :mapped key + sequences not timing out in 1 second, set the 'ttimeout' option and + reset the 'timeout' option. + + NOTE: 'ttimeout' is reset when 'compatible' is set. + + *'timeoutlen'* *'tm'* +'timeoutlen' 'tm' number (default 1000) + global + {not in all versions of Vi} + *'ttimeoutlen'* *'ttm'* +'ttimeoutlen' 'ttm' number (default -1) + global + {not in Vi} + The time in milliseconds that is waited for a key code or mapped key + sequence to complete. Also used for CTRL-\ CTRL-N and CTRL-\ CTRL-G + when part of a command has been typed. + Normally only 'timeoutlen' is used and 'ttimeoutlen' is -1. When a + different timeout value for key codes is desired set 'ttimeoutlen' to + a non-negative number. + + ttimeoutlen mapping delay key code delay ~ + < 0 'timeoutlen' 'timeoutlen' + >= 0 'timeoutlen' 'ttimeoutlen' + + The timeout only happens when the 'timeout' and 'ttimeout' options + tell so. A useful setting would be > + :set timeout timeoutlen=3000 ttimeoutlen=100 +< (time out on mapping after three seconds, time out on key codes after + a tenth of a second). + + *'title'* *'notitle'* +'title' boolean (default off, on when title can be restored) + global + {not in Vi} + {not available when compiled without the |+title| + feature} + When on, the title of the window will be set to the value of + 'titlestring' (if it is not empty), or to: + filename [+=-] (path) - VIM + Where: + filename the name of the file being edited + - indicates the file cannot be modified, 'ma' off + + indicates the file was modified + = indicates the file is read-only + =+ indicates the file is read-only and modified + (path) is the path of the file being edited + - VIM the server name |v:servername| or "VIM" + Only works if the terminal supports setting window titles + (currently Amiga console, Win32 console, all GUI versions and + terminals with a non- empty 't_ts' option - these are Unix xterm and + iris-ansi by default, where 't_ts' is taken from the builtin termcap). + *X11* + When Vim was compiled with HAVE_X11 defined, the original title will + be restored if possible. The output of ":version" will include "+X11" + when HAVE_X11 was defined, otherwise it will be "-X11". This also + works for the icon name |'icon'|. + But: When Vim was started with the |-X| argument, restoring the title + will not work (except in the GUI). + If the title cannot be restored, it is set to the value of 'titleold'. + You might want to restore the title outside of Vim then. + When using an xterm from a remote machine you can use this command: + rsh machine_name xterm -display $DISPLAY & + then the WINDOWID environment variable should be inherited and the + title of the window should change back to what it should be after + exiting Vim. + + *'titlelen'* +'titlelen' number (default 85) + global + {not in Vi} + {not available when compiled without the |+title| + feature} + Gives the percentage of 'columns' to use for the length of the window + title. When the title is longer, only the end of the path name is + shown. A '<' character before the path name is used to indicate this. + Using a percentage makes this adapt to the width of the window. But + it won't work perfectly, because the actual number of characters + available also depends on the font used and other things in the title + bar. When 'titlelen' is zero the full path is used. Otherwise, + values from 1 to 30000 percent can be used. + 'titlelen' is also used for the 'titlestring' option. + + *'titleold'* +'titleold' string (default "Thanks for flying Vim") + global + {not in Vi} + {only available when compiled with the |+title| + feature} + This option will be used for the window title when exiting Vim if the + original title cannot be restored. Only happens if 'title' is on or + 'titlestring' is not empty. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + *'titlestring'* +'titlestring' string (default "") + global + {not in Vi} + {not available when compiled without the |+title| + feature} + When this option is not empty, it will be used for the title of the + window. This happens only when the 'title' option is on. + Only works if the terminal supports setting window titles (currently + Amiga console, Win32 console, all GUI versions and terminals with a + non-empty 't_ts' option). + When Vim was compiled with HAVE_X11 defined, the original title will + be restored if possible |X11|. + When this option contains printf-style '%' items, they will be + expanded according to the rules used for 'statusline'. + Example: > + :auto BufEnter * let &titlestring = hostname() . "/" . expand("%:p") + :set title titlestring=%<%F%=%l/%L-%P titlelen=70 +< The value of 'titlelen' is used to align items in the middle or right + of the available space. + Some people prefer to have the file name first: > + :set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:~:.:h\")})%)%(\ %a%) +< Note the use of "%{ }" and an expression to get the path of the file, + without the file name. The "%( %)" constructs are used to add a + separating space only when needed. + NOTE: Use of special characters in 'titlestring' may cause the display + to be garbled (e.g., when it contains a CR or NL character). + {not available when compiled without the |+statusline| feature} + + *'toolbar'* *'tb'* +'toolbar' 'tb' string (default "icons,tooltips") + global + {only for |+GUI_GTK|, |+GUI_Athena|, |+GUI_Motif| and + |+GUI_Photon|} + The contents of this option controls various toolbar settings. The + possible values are: + icons Toolbar buttons are shown with icons. + text Toolbar buttons shown with text. + horiz Icon and text of a toolbar button are + horizontally arranged. {only in GTK+ 2 GUI} + tooltips Tooltips are active for toolbar buttons. + Tooltips refer to the popup help text which appears after the mouse + cursor is placed over a toolbar button for a brief moment. + + If you want the toolbar to be shown with icons as well as text, do the + following: > + :set tb=icons,text +< Motif and Athena cannot display icons and text at the same time. They + will show icons if both are requested. + + If none of the strings specified in 'toolbar' are valid or if + 'toolbar' is empty, this option is ignored. If you want to disable + the toolbar, you need to set the 'guioptions' option. For example: > + :set guioptions-=T +< Also see |gui-toolbar|. + + *'toolbariconsize'* *'tbis'* +'toolbariconsize' 'tbis' string (default "small") + global + {not in Vi} + {only in the GTK+ 2 GUI} + Controls the size of toolbar icons. The possible values are: + tiny Use tiny toolbar icons. + small Use small toolbar icons (default). + medium Use medium-sized toolbar icons. + large Use large toolbar icons. + The exact dimensions in pixels of the various icon sizes depend on + the current theme. Common dimensions are large=32x32, medium=24x24, + small=20x20 and tiny=16x16. + + If 'toolbariconsize' is empty, the global default size as determined + by user preferences or the current theme is used. + + *'ttybuiltin'* *'tbi'* *'nottybuiltin'* *'notbi'* +'ttybuiltin' 'tbi' boolean (default on) + global + {not in Vi} + When on, the builtin termcaps are searched before the external ones. + When off the builtin termcaps are searched after the external ones. + When this option is changed, you should set the 'term' option next for + the change to take effect, for example: > + :set notbi term=$TERM +< See also |termcap|. + Rationale: The default for this option is "on", because the builtin + termcap entries are generally better (many systems contain faulty + xterm entries...). + + *'ttyfast'* *'tf'* *'nottyfast'* *'notf'* +'ttyfast' 'tf' boolean (default off, on when 'term' is xterm, hpterm, + sun-cmd, screen, rxvt, dtterm or + iris-ansi; also on when running Vim in + a DOS console) + global + {not in Vi} + Indicates a fast terminal connection. More characters will be sent to + the screen for redrawing, instead of using insert/delete line + commands. Improves smoothness of redrawing when there are multiple + windows and the terminal does not support a scrolling region. + Also enables the extra writing of characters at the end of each screen + line for lines that wrap. This helps when using copy/paste with the + mouse in an xterm and other terminals. + + *'ttymouse'* *'ttym'* +'ttymouse' 'ttym' string (default depends on 'term') + global + {not in Vi} + {only in Unix and VMS, doesn't work in the GUI; not + available when compiled without |+mouse|} + Name of the terminal type for which mouse codes are to be recognized. + Currently these strings are valid: + *xterm-mouse* + xterm xterm-like mouse handling. The mouse generates + "[Mscr", where "scr" is three bytes: + "s" = button state + "c" = column plus 33 + "r" = row plus 33 + This only works up to 223 columns! See "dec" for a + solution. + xterm2 Works like "xterm", but with the xterm reporting the + mouse position while the mouse is dragged. This works + much faster and more precise. Your xterm must at + least at patchlevel 88 / XFree 3.3.3 for this to + work. See below for how Vim detects this + automatically. + *netterm-mouse* + netterm NetTerm mouse handling. The mouse generates + "}r,c", where "r,c" are two decimal numbers + for the row and column. + *dec-mouse* + dec DEC terminal mouse handling. The mouse generates a + rather complex sequence, starting with "[". + This is also available for an Xterm, if it was + configured with "--enable-dec-locator". + *jsbterm-mouse* + jsbterm JSB term mouse handling. + *pterm-mouse* + pterm QNX pterm mouse handling. + + The mouse handling must be enabled at compile time |+mouse_xterm| + |+mouse_dec| |+mouse_netterm|. + Only "xterm"(2) is really recognized. NetTerm mouse codes are always + recognized, if enabled at compile time. DEC terminal mouse codes + are recognized if enabled at compile time, and 'ttymouse' is not + "xterm" (because the xterm and dec mouse codes conflict). + This option is automatically set to "xterm", when the 'term' option is + set to a name that starts with "xterm", and 'ttymouse' is not "xterm" + or "xterm2" already. The main use of this option is to set it to + "xterm", when the terminal name doesn't start with "xterm", but it can + handle xterm mouse codes. + The "xterm2" value will be set if the xterm version is reported to be + 95 or higher. This only works when compiled with the |+termresponse| + feature and if |t_RV| is set to the escape sequence to request the + xterm version number. Otherwise "xterm2" must be set explicitly. + If you do not want 'ttymouse' to be set to "xterm2" automatically, set + t_RV to an empty string: > + :set t_RV= +< + *'ttyscroll'* *'tsl'* +'ttyscroll' 'tsl' number (default 999) + global + Maximum number of lines to scroll the screen. If there are more lines + to scroll the window is redrawn. For terminals where scrolling is + very slow and redrawing is not slow this can be set to a small number, + e.g., 3, to speed up displaying. + + *'ttytype'* *'tty'* +'ttytype' 'tty' string (default from $TERM) + global + Alias for 'term', see above. + + *'undodir'* *'udir'* +'undodir' 'udir' string (default ".") + global + {not in Vi} + {only when compiled with the |+persistent_undo| feature} + List of directory names for undo files, separated with commas. + See |'backupdir'| for details of the format. + "." means using the directory of the file. The undo file name for + "file.txt" is ".file.txt.un~". + For other directories the file name is the full path of the edited + file, with path separators replaced with "%". + When writing: The first directory that exists is used. "." always + works, no directories after "." will be used for writing. + When reading all entries are tried to find an undo file. The first + undo file that exists is used. When it cannot be read an error is + given, no further entry is used. + See |undo-persistence|. + + *'undofile'* *'udf'* +'undofile' 'udf' boolean (default off) + local to buffer + {not in Vi} + {only when compiled with the |+persistent_undo| feature} + When on, Vim automatically saves undo history to an undo file when + writing a buffer to a file, and restores undo history from the same + file on buffer read. + The directory where the undo file is stored is specified by 'undodir'. + For more information about this feature see |undo-persistence|. + The undo file is not read when 'undoreload' causes the buffer from + before a reload to be saved for undo. + WARNING: this is a very new feature. Use at your own risk! + + *'undolevels'* *'ul'* +'undolevels' 'ul' number (default 100, 1000 for Unix, VMS, + Win32 and OS/2) + global + {not in Vi} + Maximum number of changes that can be undone. Since undo information + is kept in memory, higher numbers will cause more memory to be used + (nevertheless, a single change can use an unlimited amount of memory). + Set to 0 for Vi compatibility: One level of undo and "u" undoes + itself: > + set ul=0 +< But you can also get Vi compatibility by including the 'u' flag in + 'cpoptions', and still be able to use CTRL-R to repeat undo. + Also see |undo-two-ways|. + Set to a negative number for no undo at all: > + set ul=-1 +< This helps when you run out of memory for a single change. + Also see |clear-undo|. + + *'undoreload'* *'ur'* +'undoreload' 'ur' number (default 10000) + global + {not in Vi} + Save the whole buffer for undo when reloading it. This applies to the + ":e!" command and reloading for when the buffer changed outside of + Vim. |FileChangedShell| + The save only happens when this options is negative or when the number + of lines is smaller than the value of this option. + Set this option to zero to disable undo for a reload. + + When saving undo for a reload, any undo file is not read. + + Note that this causes the whole buffer to be stored in memory. Set + this option to a lower value if you run out of memory. + + *'updatecount'* *'uc'* +'updatecount' 'uc' number (default: 200) + global + {not in Vi} + After typing this many characters the swap file will be written to + disk. When zero, no swap file will be created at all (see chapter on + recovery |crash-recovery|). 'updatecount' is set to zero by starting + Vim with the "-n" option, see |startup|. When editing in readonly + mode this option will be initialized to 10000. + The swapfile can be disabled per buffer with |'swapfile'|. + When 'updatecount' is set from zero to non-zero, swap files are + created for all buffers that have 'swapfile' set. When 'updatecount' + is set to zero, existing swap files are not deleted. + Also see |'swapsync'|. + This option has no meaning in buffers where |'buftype'| is "nofile" + or "nowrite". + + *'updatetime'* *'ut'* +'updatetime' 'ut' number (default 4000) + global + {not in Vi} + If this many milliseconds nothing is typed the swap file will be + written to disk (see |crash-recovery|). Also used for the + |CursorHold| autocommand event. + + *'verbose'* *'vbs'* +'verbose' 'vbs' number (default 0) + global + {not in Vi, although some versions have a boolean + verbose option} + When bigger than zero, Vim will give messages about what it is doing. + Currently, these messages are given: + >= 1 When the viminfo file is read or written. + >= 2 When a file is ":source"'ed. + >= 5 Every searched tags file and include file. + >= 8 Files for which a group of autocommands is executed. + >= 9 Every executed autocommand. + >= 12 Every executed function. + >= 13 When an exception is thrown, caught, finished, or discarded. + >= 14 Anything pending in a ":finally" clause. + >= 15 Every executed Ex command (truncated at 200 characters). + + This option can also be set with the "-V" argument. See |-V|. + This option is also set by the |:verbose| command. + + When the 'verbosefile' option is set then the verbose messages are not + displayed. + + *'verbosefile'* *'vfile'* +'verbosefile' 'vfile' string (default empty) + global + {not in Vi} + When not empty all messages are written in a file with this name. + When the file exists messages are appended. + Writing to the file ends when Vim exits or when 'verbosefile' is made + empty. Writes are buffered, thus may not show up for some time. + Setting 'verbosefile' to a new value is like making it empty first. + The difference with |:redir| is that verbose messages are not + displayed when 'verbosefile' is set. + + *'viewdir'* *'vdir'* +'viewdir' 'vdir' string (default for Amiga, MS-DOS, OS/2 and Win32: + "$VIM/vimfiles/view", + for Unix: "~/.vim/view", + for Macintosh: "$VIM:vimfiles:view" + for VMS: "sys$login:vimfiles/view" + for RiscOS: "Choices:vimfiles/view") + global + {not in Vi} + {not available when compiled without the |+mksession| + feature} + Name of the directory where to store files for |:mkview|. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'viewoptions'* *'vop'* +'viewoptions' 'vop' string (default: "folds,options,cursor") + global + {not in Vi} + {not available when compiled without the |+mksession| + feature} + Changes the effect of the |:mkview| command. It is a comma separated + list of words. Each word enables saving and restoring something: + word save and restore ~ + cursor cursor position in file and in window + folds manually created folds, opened/closed folds and local + fold options + options options and mappings local to a window or buffer (not + global values for local options) + slash backslashes in file names replaced with forward + slashes + unix with Unix end-of-line format (single ), even when + on Windows or DOS + + "slash" and "unix" are useful on Windows when sharing view files + with Unix. The Unix version of Vim cannot source dos format scripts, + but the Windows version of Vim can source unix format scripts. + + *'viminfo'* *'vi'* *E526* *E527* *E528* +'viminfo' 'vi' string (Vi default: "", Vim default for MS-DOS, + Windows and OS/2: '100,<50,s10,h,rA:,rB:, + for Amiga: '100,<50,s10,h,rdf0:,rdf1:,rdf2: + for others: '100,<50,s10,h) + global + {not in Vi} + {not available when compiled without the |+viminfo| + feature} + When non-empty, the viminfo file is read upon startup and written + when exiting Vim (see |viminfo-file|). The string should be a comma + separated list of parameters, each consisting of a single character + identifying the particular parameter, followed by a number or string + which specifies the value of that parameter. If a particular + character is left out, then the default value is used for that + parameter. The following is a list of the identifying characters and + the effect of their value. + CHAR VALUE ~ + ! When included, save and restore global variables that start + with an uppercase letter, and don't contain a lowercase + letter. Thus "KEEPTHIS and "K_L_M" are stored, but "KeepThis" + and "_K_L_M" are not. Nested List and Dict items may not be + read back correctly, you end up with a string representation + instead. + " Maximum number of lines saved for each register. Old name of + the '<' item, with the disadvantage that you need to put a + backslash before the ", otherwise it will be recognized as the + start of a comment! + % When included, save and restore the buffer list. If Vim is + started with a file name argument, the buffer list is not + restored. If Vim is started without a file name argument, the + buffer list is restored from the viminfo file. Buffers + without a file name and buffers for help files are not written + to the viminfo file. + When followed by a number, the number specifies the maximum + number of buffers that are stored. Without a number all + buffers are stored. + ' Maximum number of previously edited files for which the marks + are remembered. This parameter must always be included when + 'viminfo' is non-empty. + Including this item also means that the |jumplist| and the + |changelist| are stored in the viminfo file. + / Maximum number of items in the search pattern history to be + saved. If non-zero, then the previous search and substitute + patterns are also saved. When not included, the value of + 'history' is used. + : Maximum number of items in the command-line history to be + saved. When not included, the value of 'history' is used. + < Maximum number of lines saved for each register. If zero then + registers are not saved. When not included, all lines are + saved. '"' is the old name for this item. + Also see the 's' item below: limit specified in Kbyte. + @ Maximum number of items in the input-line history to be + saved. When not included, the value of 'history' is used. + c When included, convert the text in the viminfo file from the + 'encoding' used when writing the file to the current + 'encoding'. See |viminfo-encoding|. + f Whether file marks need to be stored. If zero, file marks ('0 + to '9, 'A to 'Z) are not stored. When not present or when + non-zero, they are all stored. '0 is used for the current + cursor position (when exiting or when doing ":wviminfo"). + h Disable the effect of 'hlsearch' when loading the viminfo + file. When not included, it depends on whether ":nohlsearch" + has been used since the last search command. + n Name of the viminfo file. The name must immediately follow + the 'n'. Must be the last one! If the "-i" argument was + given when starting Vim, that file name overrides the one + given here with 'viminfo'. Environment variables are expanded + when opening the file, not when setting the option. + r Removable media. The argument is a string (up to the next + ','). This parameter can be given several times. Each + specifies the start of a path for which no marks will be + stored. This is to avoid removable media. For MS-DOS you + could use "ra:,rb:", for Amiga "rdf0:,rdf1:,rdf2:". You can + also use it for temp files, e.g., for Unix: "r/tmp". Case is + ignored. Maximum length of each 'r' argument is 50 + characters. + s Maximum size of an item in Kbyte. If zero then registers are + not saved. Currently only applies to registers. The default + "s10" will exclude registers with more than 10 Kbyte of text. + Also see the '<' item above: line count limit. + + Example: > + :set viminfo='50,<1000,s100,:0,n~/vim/viminfo +< + '50 Marks will be remembered for the last 50 files you + edited. + <1000 Contents of registers (up to 1000 lines each) will be + remembered. + s100 Registers with more than 100 Kbyte text are skipped. + :0 Command-line history will not be saved. + n~/vim/viminfo The name of the file to use is "~/vim/viminfo". + no / Since '/' is not specified, the default will be used, + that is, save all of the search history, and also the + previous search and substitute patterns. + no % The buffer list will not be saved nor read back. + no h 'hlsearch' highlighting will be restored. + + When setting 'viminfo' from an empty value you can use |:rviminfo| to + load the contents of the file, this is not done automatically. + + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + + *'virtualedit'* *'ve'* +'virtualedit' 've' string (default "") + global + {not in Vi} + {not available when compiled without the + |+virtualedit| feature} + A comma separated list of these words: + block Allow virtual editing in Visual block mode. + insert Allow virtual editing in Insert mode. + all Allow virtual editing in all modes. + onemore Allow the cursor to move just past the end of the line + + Virtual editing means that the cursor can be positioned where there is + no actual character. This can be halfway into a tab or beyond the end + of the line. Useful for selecting a rectangle in Visual mode and + editing a table. + "onemore" is not the same, it will only allow moving the cursor just + after the last character of the line. This makes some commands more + consistent. Previously the cursor was always past the end of the line + if the line was empty. But it is far from Vi compatible. It may also + break some plugins or Vim scripts. For example because |l| can move + the cursor after the last character. Use with care! + Using the |$| command will move to the last character in the line, not + past it. This may actually move the cursor to the left! + It doesn't make sense to combine "all" with "onemore", but you will + not get a warning for it. + + *'visualbell'* *'vb'* *'novisualbell'* *'novb'* *beep* +'visualbell' 'vb' boolean (default off) + global + {not in Vi} + Use visual bell instead of beeping. The terminal code to display the + visual bell is given with 't_vb'. When no beep or flash is wanted, + use ":set vb t_vb=". + Note: When the GUI starts, 't_vb' is reset to its default value. You + might want to set it again in your |gvimrc|. + In the GUI, 't_vb' defaults to "|f", which inverts the display + for 20 msec. If you want to use a different time, use "|40f", + where 40 is the time in msec. + Does not work on the Amiga, you always get a screen flash. + Also see 'errorbells'. + + *'warn'* *'nowarn'* +'warn' boolean (default on) + global + Give a warning message when a shell command is used while the buffer + has been changed. + + *'weirdinvert'* *'wiv'* *'noweirdinvert'* *'nowiv'* +'weirdinvert' 'wiv' boolean (default off) + global + {not in Vi} + This option has the same effect as the 't_xs' terminal option. + It is provided for backwards compatibility with version 4.x. + Setting 'weirdinvert' has the effect of making 't_xs' non-empty, and + vice versa. Has no effect when the GUI is running. + + *'whichwrap'* *'ww'* +'whichwrap' 'ww' string (Vim default: "b,s", Vi default: "") + global + {not in Vi} + Allow specified keys that move the cursor left/right to move to the + previous/next line when the cursor is on the first/last character in + the line. Concatenate characters to allow this for these keys: + char key mode ~ + b Normal and Visual + s Normal and Visual + h "h" Normal and Visual (not recommended) + l "l" Normal and Visual (not recommended) + < Normal and Visual + > Normal and Visual + ~ "~" Normal + [ Insert and Replace + ] Insert and Replace + For example: > + :set ww=<,>,[,] +< allows wrap only when cursor keys are used. + When the movement keys are used in combination with a delete or change + operator, the also counts for a character. This makes "3h" + different from "3dh" when the cursor crosses the end of a line. This + is also true for "x" and "X", because they do the same as "dl" and + "dh". If you use this, you may also want to use the mapping + ":map X" to make backspace delete the character in front of the + cursor. + When 'l' is included and it is used after an operator at the end of a + line then it will not move to the next line. This makes "dl", "cl", + "yl" etc. work normally. + NOTE: This option is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + + *'wildchar'* *'wc'* +'wildchar' 'wc' number (Vim default: , Vi default: CTRL-E) + global + {not in Vi} + Character you have to type to start wildcard expansion in the + command-line, as specified with 'wildmode'. + More info here: |cmdline-completion|. + The character is not recognized when used inside a macro. See + 'wildcharm' for that. + Although 'wc' is a number option, you can set it to a special key: > + :set wc= +< NOTE: This option is set to the Vi default value when 'compatible' is + set and to the Vim default value when 'compatible' is reset. + + *'wildcharm'* *'wcm'* +'wildcharm' 'wcm' number (default: none (0)) + global + {not in Vi} + 'wildcharm' works exactly like 'wildchar', except that it is + recognized when used inside a macro. You can find "spare" command-line + keys suitable for this option by looking at |ex-edit-index|. Normally + you'll never actually type 'wildcharm', just use it in mappings that + automatically invoke completion mode, e.g.: > + :set wcm= + :cnoremap ss so $vim/sessions/*.vim +< Then after typing :ss you can use CTRL-P & CTRL-N. + + *'wildignore'* *'wig'* +'wildignore' 'wig' string (default "") + global + {not in Vi} + {not available when compiled without the |+wildignore| + feature} + A list of file patterns. A file that matches with one of these + patterns is ignored when completing file or directory names, and + influences the result of |expand()|, |glob()| and |globpath()| unless + a flag is passed to disable this. + The pattern is used like with |:autocmd|, see |autocmd-patterns|. + Also see 'suffixes'. + Example: > + :set wildignore=*.o,*.obj +< The use of |:set+=| and |:set-=| is preferred when adding or removing + a pattern from the list. This avoids problems when a future version + uses another default. + + + *'wildignorecase* *'wic'* *'nowildignorecase* *'nowic'* +'wildignorecase' 'wic' boolean (default off) + global + {not in Vi} + When set case is ignored when completing file names and directories. + Has no effect on systems where file name case is generally ignored. + Does not apply when the shell is used to expand wildcards, which + happens when there are special characters. + + + *'wildmenu'* *'wmnu'* *'nowildmenu'* *'nowmnu'* +'wildmenu' 'wmnu' boolean (default off) + global + {not in Vi} + {not available if compiled without the |+wildmenu| + feature} + When 'wildmenu' is on, command-line completion operates in an enhanced + mode. On pressing 'wildchar' (usually ) to invoke completion, + the possible matches are shown just above the command line, with the + first match highlighted (overwriting the status line, if there is + one). Keys that show the previous/next match, such as or + CTRL-P/CTRL-N, cause the highlight to move to the appropriate match. + When 'wildmode' is used, "wildmenu" mode is used where "full" is + specified. "longest" and "list" do not start "wildmenu" mode. + If there are more matches than can fit in the line, a ">" is shown on + the right and/or a "<" is shown on the left. The status line scrolls + as needed. + The "wildmenu" mode is abandoned when a key is hit that is not used + for selecting a completion. + While the "wildmenu" is active the following keys have special + meanings: + + - select previous/next match (like CTRL-P/CTRL-N) + - in filename/menu name completion: move into a + subdirectory or submenu. + - in menu completion, when the cursor is just after a + dot: move into a submenu. + - in filename/menu name completion: move up into + parent directory or parent menu. + + This makes the menus accessible from the console |console-menus|. + + If you prefer the and keys to move the cursor instead + of selecting a different match, use this: > + :cnoremap + :cnoremap +< + The "WildMenu" highlighting is used for displaying the current match + |hl-WildMenu|. + + *'wildmode'* *'wim'* +'wildmode' 'wim' string (Vim default: "full") + global + {not in Vi} + Completion mode that is used for the character specified with + 'wildchar'. It is a comma separated list of up to four parts. Each + part specifies what to do for each consecutive use of 'wildchar'. The + first part specifies the behavior for the first use of 'wildchar', + The second part for the second use, etc. + These are the possible values for each part: + "" Complete only the first match. + "full" Complete the next full match. After the last match, + the original string is used and then the first match + again. + "longest" Complete till longest common string. If this doesn't + result in a longer string, use the next part. + "longest:full" Like "longest", but also start 'wildmenu' if it is + enabled. + "list" When more than one match, list all matches. + "list:full" When more than one match, list all matches and + complete first match. + "list:longest" When more than one match, list all matches and + complete till longest common string. + When there is only a single match, it is fully completed in all cases. + + Examples: > + :set wildmode=full +< Complete first full match, next match, etc. (the default) > + :set wildmode=longest,full +< Complete longest common string, then each full match > + :set wildmode=list:full +< List all matches and complete each full match > + :set wildmode=list,full +< List all matches without completing, then each full match > + :set wildmode=longest,list +< Complete longest common string, then list alternatives. + More info here: |cmdline-completion|. + + *'wildoptions'* *'wop'* +'wildoptions' 'wop' string (default "") + global + {not in Vi} + {not available when compiled without the |+wildignore| + feature} + A list of words that change how command line completion is done. + Currently only one word is allowed: + tagfile When using CTRL-D to list matching tags, the kind of + tag and the file of the tag is listed. Only one match + is displayed per line. Often used tag kinds are: + d #define + f function + Also see |cmdline-completion|. + + *'winaltkeys'* *'wak'* +'winaltkeys' 'wak' string (default "menu") + global + {not in Vi} + {only used in Win32, Motif, GTK and Photon GUI} + Some GUI versions allow the access to menu entries by using the ALT + key in combination with a character that appears underlined in the + menu. This conflicts with the use of the ALT key for mappings and + entering special characters. This option tells what to do: + no Don't use ALT keys for menus. ALT key combinations can be + mapped, but there is no automatic handling. This can then be + done with the |:simalt| command. + yes ALT key handling is done by the windowing system. ALT key + combinations cannot be mapped. + menu Using ALT in combination with a character that is a menu + shortcut key, will be handled by the windowing system. Other + keys can be mapped. + If the menu is disabled by excluding 'm' from 'guioptions', the ALT + key is never used for the menu. + This option is not used for ; on Win32 and with GTK will + select the menu, unless it has been mapped. + + *'window'* *'wi'* +'window' 'wi' number (default screen height - 1) + global + Window height. Do not confuse this with the height of the Vim window, + use 'lines' for that. + Used for |CTRL-F| and |CTRL-B| when there is only one window and the + value is smaller than 'lines' minus one. The screen will scroll + 'window' minus two lines, with a minimum of one. + When 'window' is equal to 'lines' minus one CTRL-F and CTRL-B scroll + in a much smarter way, taking care of wrapping lines. + When resizing the Vim window, the value is smaller than 1 or more than + or equal to 'lines' it will be set to 'lines' minus 1. + {Vi also uses the option to specify the number of displayed lines} + + *'winheight'* *'wh'* *E591* +'winheight' 'wh' number (default 1) + global + {not in Vi} + {not available when compiled without the |+windows| + feature} + Minimal number of lines for the current window. This is not a hard + minimum, Vim will use fewer lines if there is not enough room. If the + focus goes to a window that is smaller, its size is increased, at the + cost of the height of other windows. + Set 'winheight' to a small number for normal editing. + Set it to 999 to make the current window fill most of the screen. + Other windows will be only 'winminheight' high. This has the drawback + that ":all" will create only two windows. To avoid "vim -o 1 2 3 4" + to create only two windows, set the option after startup is done, + using the |VimEnter| event: > + au VimEnter * set winheight=999 +< Minimum value is 1. + The height is not adjusted after one of the commands that change the + height of the current window. + 'winheight' applies to the current window. Use 'winminheight' to set + the minimal height for other windows. + + *'winfixheight'* *'wfh'* *'nowinfixheight'* *'nowfh'* +'winfixheight' 'wfh' boolean (default off) + local to window + {not in Vi} + {not available when compiled without the |+windows| + feature} + Keep the window height when windows are opened or closed and + 'equalalways' is set. Also for |CTRL-W_=|. Set by default for the + |preview-window| and |quickfix-window|. + The height may be changed anyway when running out of room. + + *'winfixwidth'* *'wfw'* *'nowinfixwidth'* *'nowfw'* +'winfixwidth' 'wfw' boolean (default off) + local to window + {not in Vi} + {not available when compiled without the |+windows| + feature} + Keep the window width when windows are opened or closed and + 'equalalways' is set. Also for |CTRL-W_=|. + The width may be changed anyway when running out of room. + + *'winminheight'* *'wmh'* +'winminheight' 'wmh' number (default 1) + global + {not in Vi} + {not available when compiled without the |+windows| + feature} + The minimal height of a window, when it's not the current window. + This is a hard minimum, windows will never become smaller. + When set to zero, windows may be "squashed" to zero lines (i.e. just a + status bar) if necessary. They will return to at least one line when + they become active (since the cursor has to have somewhere to go.) + Use 'winheight' to set the minimal height of the current window. + This option is only checked when making a window smaller. Don't use a + large number, it will cause errors when opening more than a few + windows. A value of 0 to 3 is reasonable. + + *'winminwidth'* *'wmw'* +'winminwidth' 'wmw' number (default 1) + global + {not in Vi} + {not available when compiled without the |+vertsplit| + feature} + The minimal width of a window, when it's not the current window. + This is a hard minimum, windows will never become smaller. + When set to zero, windows may be "squashed" to zero columns (i.e. just + a vertical separator) if necessary. They will return to at least one + line when they become active (since the cursor has to have somewhere + to go.) + Use 'winwidth' to set the minimal width of the current window. + This option is only checked when making a window smaller. Don't use a + large number, it will cause errors when opening more than a few + windows. A value of 0 to 12 is reasonable. + + *'winwidth'* *'wiw'* *E592* +'winwidth' 'wiw' number (default 20) + global + {not in Vi} + {not available when compiled without the |+vertsplit| + feature} + Minimal number of columns for the current window. This is not a hard + minimum, Vim will use fewer columns if there is not enough room. If + the current window is smaller, its size is increased, at the cost of + the width of other windows. Set it to 999 to make the current window + always fill the screen. Set it to a small number for normal editing. + The width is not adjusted after one of the commands to change the + width of the current window. + 'winwidth' applies to the current window. Use 'winminwidth' to set + the minimal width for other windows. + + *'wrap'* *'nowrap'* +'wrap' boolean (default on) + local to window + {not in Vi} + This option changes how text is displayed. It doesn't change the text + in the buffer, see 'textwidth' for that. + When on, lines longer than the width of the window will wrap and + displaying continues on the next line. When off lines will not wrap + and only part of long lines will be displayed. When the cursor is + moved to a part that is not shown, the screen will scroll + horizontally. + The line will be broken in the middle of a word if necessary. See + 'linebreak' to get the break at a word boundary. + To make scrolling horizontally a bit more useful, try this: > + :set sidescroll=5 + :set listchars+=precedes:<,extends:> +< See 'sidescroll', 'listchars' and |wrap-off|. + This option can't be set from a |modeline| when the 'diff' option is + on. + + *'wrapmargin'* *'wm'* +'wrapmargin' 'wm' number (default 0) + local to buffer + Number of characters from the right window border where wrapping + starts. When typing text beyond this limit, an will be inserted + and inserting continues on the next line. + Options that add a margin, such as 'number' and 'foldcolumn', cause + the text width to be further reduced. This is Vi compatible. + When 'textwidth' is non-zero, this option is not used. + See also 'formatoptions' and |ins-textwidth|. {Vi: works differently + and less usefully} + + *'wrapscan'* *'ws'* *'nowrapscan'* *'nows'* +'wrapscan' 'ws' boolean (default on) *E384* *E385* + global + Searches wrap around the end of the file. Also applies to |]s| and + |[s|, searching for spelling mistakes. + + *'write'* *'nowrite'* +'write' boolean (default on) + global + {not in Vi} + Allows writing files. When not set, writing a file is not allowed. + Can be used for a view-only mode, where modifications to the text are + still allowed. Can be reset with the |-m| or |-M| command line + argument. Filtering text is still possible, even though this requires + writing a temporary file. + + *'writeany'* *'wa'* *'nowriteany'* *'nowa'* +'writeany' 'wa' boolean (default off) + global + Allows writing to any file with no need for "!" override. + + *'writebackup'* *'wb'* *'nowritebackup'* *'nowb'* +'writebackup' 'wb' boolean (default on with |+writebackup| feature, off + otherwise) + global + {not in Vi} + Make a backup before overwriting a file. The backup is removed after + the file was successfully written, unless the 'backup' option is + also on. Reset this option if your file system is almost full. See + |backup-table| for another explanation. + When the 'backupskip' pattern matches, a backup is not made anyway. + NOTE: This option is set to the default value when 'compatible' is + set. + + *'writedelay'* *'wd'* +'writedelay' 'wd' number (default 0) + global + {not in Vi} + The number of microseconds to wait for each character sent to the + screen. When non-zero, characters are sent to the terminal one by + one. For MS-DOS pcterm this does not work. For debugging purposes. + + vim:tw=78:ts=8:ft=help:norl: diff -Naur vim73.orig/runtime/doc/os_risc.txt vim73.patched/runtime/doc/os_risc.txt --- vim73.orig/runtime/doc/os_risc.txt 2010-08-15 07:23:21.000000000 -0500 +++ vim73.patched/runtime/doc/os_risc.txt 2012-05-20 12:55:41.000000000 -0500 @@ -1,322 +1,12 @@ -*os_risc.txt* For Vim version 7.3. Last change: 2010 Aug 07 +*os_risc.txt* For Vim version 7.3. Last change: 2011 May 10 VIM REFERENCE MANUAL by Thomas Leonard *riscos* *RISCOS* *RISC-OS* -This file contains the particularities for the RISC OS version of Vim. +The RISC OS support has been removed from Vim with patch 7.3.187. +If you would like to use Vim on RISC OS get the files from before that patch. -The RISC OS port is a completely new port and is not based on the old "archi" -port. -1. File locations |riscos-locations| -2. Filename munging |riscos-munging| -3. Command-line use |riscos-commandline| -4. Desktop (GUI) use |riscos-gui| -5. Remote use (telnet) |riscos-remote| -6. Temporary files |riscos-temp-files| -7. Interrupting |riscos-interrupt| -8. Memory usage |riscos-memory| -9. Filetypes |riscos-filetypes| -10. The shell |riscos-shell| -11. Porting new releases |riscos-porting| - -If I've missed anything, email me and I'll try to fix it. In fact, even if I -haven't missed anything then email me anyway to give me some confidence that it -actually works! - -Thomas Leonard - - [these URLs no longer work...] - Port homepage: http://www.ecs.soton.ac.uk/~tal197/ - or try: http://www.soton.ac.uk/~tal197/ - -============================================================================== - *riscos-locations* -1. File locations - -The Vim executable and shared resource files are all stored inside the !Vim -application directory. - -When !Vim is first seen by the filer, it aliases the *vi and *ex commands to -run the command-line versions of Vim (see |riscos-commandline|). - -!Vim.Resources and !Vim.Resources2 contain the files from the standard Vim -distribution, but modified slightly to work within the limits of ADFS, plus -some extra files such as the window templates. - -User choices are read from "Choices:*" and are saved to ".*". -If you have the new !Boot structure then these should be set up already. If -not, set Choices$Path to a list of directories to search when looking for -user configuration files. Set Choices$Write to the directory you want files -to be saved into (so your search patterns and marks can be remembered between -sessions). - -============================================================================== - *riscos-munging* -2. Filename munging - -All pathname munging is disabled by default, so Vim should behave like a -normal RISC OS application now. So, if you want to edit "doc/html" then you -actually type "*vi doc/html". - -The only times munging is done is when: - -- Searching included files from C programs, since these are always munged. - See |[I|. - Note: make sure you are in the right directory when you use this - command (i.e. the one with subdirectories "c" and "h"). - -- Sourcing files using |:so|. - Paths starting "$VIM/" are munged like this: - - $VIM/syntax/help.vim -> Vim:syntax.help - - Also, files ending in ".vim" have their extensions removed, and slashes - replaced with dots. - -Some tag files and script files may have to be edited to work under this port. - -============================================================================== - *riscos-commandline* -3. Command-line use - -To use Vim from the command-line use the "*vi" command (or "*ex" for -|Ex-mode|). - -Type "*vi -h" for a list of options. - -Running the command-line version of Vim in a large high-color mode may cause -the scrolling to be very slow. Either change to a mode with fewer colors or -use the GUI version. - -Also, holding down Ctrl will slow it down even more, and Ctrl-Shift will -freeze it, as usual for text programs. - -============================================================================== - *riscos-gui* -4. Desktop use - -Limitations: - -- Left scrollbars don't work properly (right and bottom are fine). -- Doesn't increase scroll speed if it gets behind. - -You can resize the window by dragging the lower-right corner, even though -there is no icon shown there. - -You can use the --rows and --columns arguments to specify the initial size of -the Vim window, like this: > - - *Vi -g --rows 20 --columns 80 - -The global clipboard is supported, so you can select some text and then -paste it directly into another application (provided it supports the -clipboard too). - -Clicking Menu now opens a menu like a normal RISC OS program. Hold down Shift -when clicking Menu to paste (from the global clipboard). - -Dragging a file to the window replaces the CURRENT buffer (the one with the -cursor, NOT the one you dragged to) with the file. - -Dragging with Ctrl held down causes a new Vim window to be opened for the -file (see |:sp|). - -Dragging a file in with Shift held down in insert mode inserts the pathname of -the file. - -:browse :w opens a standard RISC OS save box. -:browse :e opens a directory viewer. - -For fonts, you have the choice of the system font, an outline font, the system -font via ZapRedraw and any of the Zap fonts via ZapRedraw: > - - :set guifont= -< To use the system font via the VDU drivers. Supports - bold and underline. -> - :set guifont=Corpus.Medium -< Use the named outline font. You can use any font, but - only monospaced ones like Corpus look right. -> - :set guifont=Corpus.Medium:w8:h12:b:i -< As before, but with size of 8 point by 12 point, and - in bold italic. - If only one of width and height is given then that - value is used for both. If neither is given then 10 - point is used. - -Thanks to John Kortink, Vim can use the ZapRedraw module. Start the font name -with "!" (or "!!" for double height), like this: > - - :set guifont=!! -< Use the system font, but via ZapRedraw. This gives a - faster redraw on StrongARM processors, but you can't - get bold or italic text. Double height. -> - :set guifont=!script -< Uses the named Zap font (a directory in VimFont$Path). - The redraw is the same speed as for "!!", but you get - a nicer looking font. - Only the "man+" and "script" fonts are supplied - currently, but you can use any of the Zap fonts if - they are in VimFont$Path. - Vim will try to load font files "0", "B", "I" and "IB" - from the named directory. Only "0" (normal style) MUST - be present. Link files are not currently supported. - -Note that when using ZapRedraw the edit bar is drawn in front of the character -you are on rather than behind it. Also redraw is incorrect for screen modes -with eigen values of 0. If the font includes control characters then you can -get Vim to display them by changing the 'isprint' option. - -If you find the scrolling is too slow on your machine, try experimenting -with the 'scrolljump' and 'ttyscroll' options. - -In particular, StrongARM users may find that: > - - :set ttyscroll=0 - -makes scrolling faster in high-color modes. - -============================================================================= - *riscos-remote* -5. Remote use (telnet) - -I have included a built-in termcap entry, but you can edit the termcap file to -allow other codes to be used if you want to use Vim from a remote terminal. - -Although I do not have an internet connection to my Acorn, I have managed to -run Vim in a FreeTerm window using the loopback connection. - -It seems to work pretty well now, using "*vi -T ansi". - -============================================================================== - *riscos-temp-files* -6. Temporary files - -If Vim crashes then the swap and backup files (if any) will be in the -directories set with the 'directory' and 'bdir' options. By default the swap -files are in (i.e. inside !Scrap) and backups are in the -directory you were saving to. Vim will allow you to try and recover the file -when you next try to edit it. - -To see a list of swap files, press and type "*vi -r". - -Vim no longer brings up ATTENTION warnings if you try to edit two files with -the same name in different directories. - -However, it also no longer warns if you try to edit the same file twice (with -two copies of Vim), though you will still be warned when you save that the -datestamp has changed. - -============================================================================== - *riscos-interrupt* -7. Interrupting - -To break out of a looping macro, or similar, hold down Escape in the -command-line version, or press CTRL-C in the GUI version. - -============================================================================== - *riscos-memory* -8. Memory usage - -Vim will use dynamic areas on RISC OS 3.5 or later. If you can use them on -older machines then edit the !RunTxt and GVim files. I don't know what UnixLib -does by default on these machines so I'm playing safe. - -It doesn't work at all well without dynamic areas, since it can't change its -memory allocation once running. Hence you should edit "!Vim.GVim" and -"!Vim.!RunTxt" to choose the best size for you. You probably need at least -about 1400K. - -============================================================================== - *riscos-filetypes* -9. Filetypes - -You can now specify that autocommands are only executed for files of certain -types. The filetype is given in the form &xxx, when xxx is the filetype. - -Filetypes must be specified by number (e.g. &fff for Text). - -The system has changed from version 5.3. The new sequence of events is: - -- A file is loaded. |'osfiletype'| is set to the RISC OS filetype. -- Based on the filetype and pathname, Vim will try to set |'filetype'| to the - Vim-type of the file. -- Setting this option may load syntax files and perform other actions. -- Saving the file will give it a filetype of |'osfiletype'|. - -Some examples may make this clearer: - - Kind of file loaded osfiletype filetype ~ - C code "c.hellow" Text (&fff) C - LaTeX document LaTeX (&2a8) TeX - Draw document DrawFile (&aff) (not changed) - -============================================================================== - *riscos-shell* -10. The shell - -- Bangs (!s) are only replaced if they are followed by a space or end-of-line, - since many pathnames contain them. - -- You can prefix the command with "~", which stops any output from being - displayed. This also means that you don't have to press afterwards, - and stops the screen from being redrawn. {only in the GUI version} - -============================================================================== - *riscos-porting* -11. Porting new releases to RISC OS - -Downloading everything you need: - -- Get the latest source distribution (see www.vim.org) -- Get the runtime environment files (e.g. these help files) -- Get the RISC OS binary distribution (if possible) - - -Unarchiving: - -- Create a raFS disk and put the archives on it -- Un-gzip them -- Un-tar them (*tar xELf 50 archive/tar) - - -Recompiling the sources: - -- Create c, s, and h directories. -- Put all the header files in "h". \ -- Put all the C files in "c". | And lose the extensions -- Put the assembler file ("swis/s") in "s". / -- Rename all the files in "proto" to "h", like this: - raFS::VimSrc.source.proto.file/pro - becomes - raFS::VimSrc.source.h.file_pro -- In the files "h.proto" and "c.termlib", search and replace - .pro" - with - _pro.h" -- Create a simple Makefile if desired and do "*make -k". - Use "CC = gcc -DRISCOS -DUSE_GUI -O2 -x c" in the Makefile. -- Save the binary as !Vim.Vim in the binary distribution. - - -Updating the run-time environment: - -- Replace old or missing files inside !Vim.Resources with the - new files. -- Remove files in "doc" not ending in "/txt", except for "tags". -- Lose the extensions from the files in "doc". -- Edit the "doc.tags" file. Remove extensions from the second column: > - :%s/^\(.[^\t]*\t.*\)\.txt\t/\1\t/ -- Remove extensions from the syntax files. Split them into two directories - to avoid the 77 entry limit on old ADFS filesystems. -- Edit "Vim:FileType" to match "*.c.*" as well as "*/c" and so on. - Add filetype checking too. -- Edit "Vim:Menu" and remove all the keys from the menus: > - :%s/[^ \t]*// -< vim:tw=78:ts=8:ft=help:norl: diff -Naur vim73.orig/runtime/doc/os_win32.txt vim73.patched/runtime/doc/os_win32.txt --- vim73.orig/runtime/doc/os_win32.txt 2010-08-15 07:23:21.000000000 -0500 +++ vim73.patched/runtime/doc/os_win32.txt 2012-05-20 12:55:42.000000000 -0500 @@ -313,6 +313,37 @@ with :!start do not get passed Vim's open file handles, which means they do not have to be closed before Vim. To avoid this special treatment, use ":! start". + There are two optional arguments (see the next Q): + /min the window will be minimized. + /b" no console window will be opened + You can only one of these flags at a time. A second second one will be + treated as the start of the command. + +Q. How do I avoid getting a window for programs that I run asynchronously? +A. You have two possible solutions depending on what exactly do you want: + 1) You may use the /min flag in order to run program in a minimized state + with no other changes. It will work equally for console and GUI + applications. + 2) You can use the /b flag to run console applications without creating a + console window for them (GUI applications are not affected). But you + should use this flag only if the application you run doesn't require any + input. Otherwise it will get an EOF error because its input stream + (stdin) would be redirected to \\.\NUL (stdoud and stderr too). + + Example for a console application, run Exuberant ctags: > + :!start /min ctags -R . +< When it has finished you should see file named "tags" in your current + directory. You should notice the window title blinking on your taskbar. + This is more noticable for commands that take longer. + Now delete the "tags" file and run this command: > + :!start /b ctags -R . +< You should have the same "tags" file, but this time there will be no + blinking on the taskbar. + Example for a GUI application: > + :!start /min notepad + :!start /b notepad +< The first command runs notepad minimized and the second one runs it + normally. Q. I'm using Win32s, and when I try to run an external command like "make", Vim doesn't wait for it to finish! Help! diff -Naur vim73.orig/runtime/doc/pattern.txt vim73.patched/runtime/doc/pattern.txt --- vim73.orig/runtime/doc/pattern.txt 2010-08-15 07:23:21.000000000 -0500 +++ vim73.patched/runtime/doc/pattern.txt 2012-05-20 12:55:42.000000000 -0500 @@ -1027,11 +1027,9 @@ These items only work for 8-bit characters. */[[=* *[==]* - An equivalence class. This means that characters are matched that - have almost the same meaning, e.g., when ignoring accents. The form - is: + have almost the same meaning, e.g., when ignoring accents. This + only works for Unicode, latin1 and latin9. The form is: [=a=] - Currently this is only implemented for latin1. Also works for the - latin1 characters in utf-8 and latin9. */[[.* *[..]* - A collation element. This currently simply accepts a single character in the form: diff -Naur vim73.orig/runtime/filetype.vim vim73.patched/runtime/filetype.vim --- vim73.orig/runtime/filetype.vim 2010-08-03 15:44:00.000000000 -0500 +++ vim73.patched/runtime/filetype.vim 2012-05-20 12:55:43.000000000 -0500 @@ -2475,17 +2475,19 @@ " detected filetypes. runtime! ftdetect/*.vim +" NOTE: The above command could have ended the filetypedetect autocmd group +" and started another one. Let's make sure it has ended to get to a consistant +" state. +augroup END " Generic configuration file (check this last, it's just guessing!) -au BufNewFile,BufRead,StdinReadPost * +au filetypedetect BufNewFile,BufRead,StdinReadPost * \ if !did_filetype() && expand("") !~ g:ft_ignore_pat \ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#' \ || getline(4) =~ '^#' || getline(5) =~ '^#') | \ setf conf | \ endif -augroup END - " If the GUI is already running, may still need to install the Syntax menu. " Don't do it when the 'M' flag is included in 'guioptions'. diff -Naur vim73.orig/runtime/filetype.vim.orig vim73.patched/runtime/filetype.vim.orig --- vim73.orig/runtime/filetype.vim.orig 1969-12-31 18:00:00.000000000 -0600 +++ vim73.patched/runtime/filetype.vim.orig 2010-08-03 15:44:00.000000000 -0500 @@ -0,0 +1,2514 @@ +" Vim support file to detect file types +" +" Maintainer: Bram Moolenaar +" Last Change: 2010 Jul 30 + +" Listen very carefully, I will say this only once +if exists("did_load_filetypes") + finish +endif +let did_load_filetypes = 1 + +" Line continuation is used here, remove 'C' from 'cpoptions' +let s:cpo_save = &cpo +set cpo&vim + +augroup filetypedetect + +" Ignored extensions +if exists("*fnameescape") +au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.dpkg-dist,?\+.dpkg-old,?\+.rpmsave,?\+.rpmnew + \ exe "doau filetypedetect BufRead " . fnameescape(expand(":r")) +au BufNewFile,BufRead *~ + \ let s:name = expand("") | + \ let s:short = substitute(s:name, '\~$', '', '') | + \ if s:name != s:short && s:short != "" | + \ exe "doau filetypedetect BufRead " . fnameescape(s:short) | + \ endif | + \ unlet! s:name s:short +au BufNewFile,BufRead ?\+.in + \ if expand(":t") != "configure.in" | + \ exe "doau filetypedetect BufRead " . fnameescape(expand(":r")) | + \ endif +elseif &verbose > 0 + echomsg "Warning: some filetypes will not be recognized because this version of Vim does not have fnameescape()" +endif + +" Pattern used to match file names which should not be inspected. +" Currently finds compressed files. +if !exists("g:ft_ignore_pat") + let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$' +endif + +" Function used for patterns that end in a star: don't set the filetype if the +" file name matches ft_ignore_pat. +func! s:StarSetf(ft) + if expand("") !~ g:ft_ignore_pat + exe 'setf ' . a:ft + endif +endfunc + +" Abaqus or Trasys +au BufNewFile,BufRead *.inp call s:Check_inp() + +func! s:Check_inp() + if getline(1) =~ '^\*' + setf abaqus + else + let n = 1 + if line("$") > 500 + let nmax = 500 + else + let nmax = line("$") + endif + while n <= nmax + if getline(n) =~? "^header surface data" + setf trasys + break + endif + let n = n + 1 + endwhile + endif +endfunc + +" A-A-P recipe +au BufNewFile,BufRead *.aap setf aap + +" A2ps printing utility +au BufNewFile,BufRead etc/a2ps.cfg,etc/a2ps/*.cfg,a2psrc,.a2psrc setf a2ps + +" ABAB/4 +au BufNewFile,BufRead *.abap setf abap + +" ABC music notation +au BufNewFile,BufRead *.abc setf abc + +" ABEL +au BufNewFile,BufRead *.abl setf abel + +" AceDB +au BufNewFile,BufRead *.wrm setf acedb + +" Ada (83, 9X, 95) +au BufNewFile,BufRead *.adb,*.ads,*.ada setf ada +if has("vms") + au BufNewFile,BufRead *.gpr,*.ada_m,*.adc setf ada +else + au BufNewFile,BufRead *.gpr setf ada +endif + +" AHDL +au BufNewFile,BufRead *.tdf setf ahdl + +" AMPL +au BufNewFile,BufRead *.run setf ampl + +" Ant +au BufNewFile,BufRead build.xml setf ant + +" Apache style config file +au BufNewFile,BufRead proftpd.conf* call s:StarSetf('apachestyle') + +" Apache config file +au BufNewFile,BufRead .htaccess,/etc/httpd/*.conf setf apache +au BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/apache2/*.conf*,/etc/httpd/conf.d/*.conf* call s:StarSetf('apache') + +" XA65 MOS6510 cross assembler +au BufNewFile,BufRead *.a65 setf a65 + +" Applescript +au BufNewFile,BufRead *.scpt setf applescript + +" Applix ELF +au BufNewFile,BufRead *.am + \ if expand("") !~? 'Makefile.am\>' | setf elf | endif + +" ALSA configuration +au BufNewFile,BufRead ~/.asoundrc,/usr/share/alsa/alsa.conf,/etc/asound.conf setf alsaconf + +" Arc Macro Language +au BufNewFile,BufRead *.aml setf aml + +" Arch Inventory file +au BufNewFile,BufRead .arch-inventory,=tagging-method setf arch + +" ART*Enterprise (formerly ART-IM) +au BufNewFile,BufRead *.art setf art + +" ASN.1 +au BufNewFile,BufRead *.asn,*.asn1 setf asn + +" Active Server Pages (with Visual Basic Script) +au BufNewFile,BufRead *.asa + \ if exists("g:filetype_asa") | + \ exe "setf " . g:filetype_asa | + \ else | + \ setf aspvbs | + \ endif + +" Active Server Pages (with Perl or Visual Basic Script) +au BufNewFile,BufRead *.asp + \ if exists("g:filetype_asp") | + \ exe "setf " . g:filetype_asp | + \ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" | + \ setf aspperl | + \ else | + \ setf aspvbs | + \ endif + +" Grub (must be before catch *.lst) +au BufNewFile,BufRead /boot/grub/menu.lst,/boot/grub/grub.conf,/etc/grub.conf setf grub + +" Assembly (all kinds) +" *.lst is not pure assembly, it has two extra columns (address, byte codes) +au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call s:FTasm() + +" This function checks for the kind of assembly that is wanted by the user, or +" can be detected from the first five lines of the file. +func! s:FTasm() + " make sure b:asmsyntax exists + if !exists("b:asmsyntax") + let b:asmsyntax = "" + endif + + if b:asmsyntax == "" + call s:FTasmsyntax() + endif + + " if b:asmsyntax still isn't set, default to asmsyntax or GNU + if b:asmsyntax == "" + if exists("g:asmsyntax") + let b:asmsyntax = g:asmsyntax + else + let b:asmsyntax = "asm" + endif + endif + + exe "setf " . fnameescape(b:asmsyntax) +endfunc + +func! s:FTasmsyntax() + " see if file contains any asmsyntax=foo overrides. If so, change + " b:asmsyntax appropriately + let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4). + \" ".getline(5)." " + let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s') + if match != '' + let b:asmsyntax = match + elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library')) + let b:asmsyntax = "vmasm" + endif +endfunc + +" Macro (VAX) +au BufNewFile,BufRead *.mar setf vmasm + +" Atlas +au BufNewFile,BufRead *.atl,*.as setf atlas + +" Autoit v3 +au BufNewFile,BufRead *.au3 setf autoit + +" Autohotkey +au BufNewFile,BufRead *.ahk setf autohotkey + +" Automake +au BufNewFile,BufRead [mM]akefile.am,GNUmakefile.am setf automake + +" Autotest .at files are actually m4 +au BufNewFile,BufRead *.at setf m4 + +" Avenue +au BufNewFile,BufRead *.ave setf ave + +" Awk +au BufNewFile,BufRead *.awk setf awk + +" B +au BufNewFile,BufRead *.mch,*.ref,*.imp setf b + +" BASIC or Visual Basic +au BufNewFile,BufRead *.bas call s:FTVB("basic") + +" Check if one of the first five lines contains "VB_Name". In that case it is +" probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype. +func! s:FTVB(alt) + if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' + setf vb + else + exe "setf " . a:alt + endif +endfunc + +" Visual Basic Script (close to Visual Basic) +au BufNewFile,BufRead *.vbs,*.dsm,*.ctl setf vb + +" IBasic file (similar to QBasic) +au BufNewFile,BufRead *.iba,*.ibi setf ibasic + +" FreeBasic file (similar to QBasic) +au BufNewFile,BufRead *.fb,*.bi setf freebasic + +" Batch file for MSDOS. +au BufNewFile,BufRead *.bat,*.sys setf dosbatch +" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd. +au BufNewFile,BufRead *.cmd + \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif + +" Batch file for 4DOS +au BufNewFile,BufRead *.btm call s:FTbtm() +func! s:FTbtm() + if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm + setf dosbatch + else + setf btm + endif +endfunc + +" BC calculator +au BufNewFile,BufRead *.bc setf bc + +" BDF font +au BufNewFile,BufRead *.bdf setf bdf + +" BibTeX bibliography database file +au BufNewFile,BufRead *.bib setf bib + +" BibTeX Bibliography Style +au BufNewFile,BufRead *.bst setf bst + +" BIND configuration +au BufNewFile,BufRead named.conf,rndc.conf setf named + +" BIND zone +au BufNewFile,BufRead named.root setf bindzone +au BufNewFile,BufRead *.db call s:BindzoneCheck('') + +func! s:BindzoneCheck(default) + if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA' + setf bindzone + elseif a:default != '' + exe 'setf ' . a:default + endif +endfunc + +" Blank +au BufNewFile,BufRead *.bl setf blank + +" Blkid cache file +au BufNewFile,BufRead /etc/blkid.tab,/etc/blkid.tab.old setf xml + +" C or lpc +au BufNewFile,BufRead *.c call s:FTlpc() + +func! s:FTlpc() + if exists("g:lpc_syntax_for_c") + let lnum = 1 + while lnum <= 12 + if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)' + setf lpc + return + endif + let lnum = lnum + 1 + endwhile + endif + setf c +endfunc + +" Calendar +au BufNewFile,BufRead calendar setf calendar +au BufNewFile,BufRead */.calendar/*, + \*/share/calendar/*/calendar.*,*/share/calendar/calendar.* + \ call s:StarSetf('calendar') + +" C# +au BufNewFile,BufRead *.cs setf cs + +" Cabal +au BufNewFile,BufRead *.cabal setf cabal + +" Cdrdao TOC +au BufNewFile,BufRead *.toc setf cdrtoc + +" Cdrdao config +au BufNewFile,BufRead etc/cdrdao.conf,etc/defaults/cdrdao,etc/default/cdrdao,~/.cdrdao setf cdrdaoconf + +" Cfengine +au BufNewFile,BufRead cfengine.conf setf cfengine + +" ChaiScript +au BufRead,BufNewFile *.chai setf chaiscript + +" Comshare Dimension Definition Language +au BufNewFile,BufRead *.cdl setf cdl + +" Conary Recipe +au BufNewFile,BufRead *.recipe setf conaryrecipe + +" Controllable Regex Mutilator +au BufNewFile,BufRead *.crm setf crm + +" Cyn++ +au BufNewFile,BufRead *.cyn setf cynpp + +" Cynlib +" .cc and .cpp files can be C++ or Cynlib. +au BufNewFile,BufRead *.cc + \ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cpp|endif +au BufNewFile,BufRead *.cpp + \ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cpp|endif + +" C++ +au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.ipp,*.moc,*.tcc,*.inl setf cpp +if has("fname_case") + au BufNewFile,BufRead *.C,*.H setf cpp +endif + +" .h files can be C, Ch C++, ObjC or ObjC++. +" Set c_syntax_for_h if you want C, ch_syntax_for_h if you want Ch. ObjC is +" detected automatically. +au BufNewFile,BufRead *.h call s:FTheader() + +func! s:FTheader() + if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1 + setf objc + elseif exists("g:c_syntax_for_h") + setf c + elseif exists("g:ch_syntax_for_h") + setf ch + else + setf cpp + endif +endfunc + +" Ch (CHscript) +au BufNewFile,BufRead *.chf setf ch + +" TLH files are C++ headers generated by Visual C++'s #import from typelibs +au BufNewFile,BufRead *.tlh setf cpp + +" Cascading Style Sheets +au BufNewFile,BufRead *.css setf css + +" Century Term Command Scripts (*.cmd too) +au BufNewFile,BufRead *.con setf cterm + +" Changelog +au BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch + \ setf debchangelog + +au BufNewFile,BufRead [cC]hange[lL]og + \ if getline(1) =~ '; urgency=' + \| setf debchangelog + \| else + \| setf changelog + \| endif + +au BufNewFile,BufRead NEWS + \ if getline(1) =~ '; urgency=' + \| setf debchangelog + \| endif + +" CHILL +au BufNewFile,BufRead *..ch setf chill + +" Changes for WEB and CWEB or CHILL +au BufNewFile,BufRead *.ch call s:FTchange() + +" This function checks if one of the first ten lines start with a '@'. In +" that case it is probably a change file. +" If the first line starts with # or ! it's probably a ch file. +" If a line has "main", "include", "//" ir "/*" it's probably ch. +" Otherwise CHILL is assumed. +func! s:FTchange() + let lnum = 1 + while lnum <= 10 + if getline(lnum)[0] == '@' + setf change + return + endif + if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!') + setf ch + return + endif + if getline(lnum) =~ "MODULE" + setf chill + return + endif + if getline(lnum) =~ 'main\s*(\|#\s*include\|//' + setf ch + return + endif + let lnum = lnum + 1 + endwhile + setf chill +endfunc + +" ChordPro +au BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro setf chordpro + +" Clean +au BufNewFile,BufRead *.dcl,*.icl setf clean + +" Clever +au BufNewFile,BufRead *.eni setf cl + +" Clever or dtd +au BufNewFile,BufRead *.ent call s:FTent() + +func! s:FTent() + " This function checks for valid cl syntax in the first five lines. + " Look for either an opening comment, '#', or a block start, '{". + " If not found, assume SGML. + let lnum = 1 + while lnum < 6 + let line = getline(lnum) + if line =~ '^\s*[#{]' + setf cl + return + elseif line !~ '^\s*$' + " Not a blank line, not a comment, and not a block start, + " so doesn't look like valid cl code. + break + endif + let lnum = lnum + 1 + endw + setf dtd +endfunc + +" Clipper (or FoxPro; could also be eviews) +au BufNewFile,BufRead *.prg + \ if exists("g:filetype_prg") | + \ exe "setf " . g:filetype_prg | + \ else | + \ setf clipper | + \ endif + +" Cmake +au BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in setf cmake + +" Cmusrc +au BufNewFile,BufRead ~/.cmus/{autosave,rc,command-history,*.theme} setf cmusrc +au BufNewFile,BufRead */cmus/{rc,*.theme} setf cmusrc + +" Cobol +au BufNewFile,BufRead *.cbl,*.cob,*.lib setf cobol +" cobol or zope form controller python script? (heuristic) +au BufNewFile,BufRead *.cpy + \ if getline(1) =~ '^##' | + \ setf python | + \ else | + \ setf cobol | + \ endif + +" Coco/R +au BufNewFile,BufRead *.atg setf coco + +" Cold Fusion +au BufNewFile,BufRead *.cfm,*.cfi,*.cfc setf cf + +" Configure scripts +au BufNewFile,BufRead configure.in,configure.ac setf config + +" CUDA Cumpute Unified Device Architecture +au BufNewFile,BufRead *.cu setf cuda + +" WildPackets EtherPeek Decoder +au BufNewFile,BufRead *.dcd setf dcd + +" Enlightenment configuration files +au BufNewFile,BufRead *enlightenment/*.cfg setf c + +" Eterm +au BufNewFile,BufRead *Eterm/*.cfg setf eterm + +" Lynx config files +au BufNewFile,BufRead lynx.cfg setf lynx + +" Quake +au BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg setf quake +au BufNewFile,BufRead *quake[1-3]/*.cfg setf quake + +" Quake C +au BufNewFile,BufRead *.qc setf c + +" Configure files +au BufNewFile,BufRead *.cfg setf cfg + +" Cucumber +au BufNewFile,BufRead *.feature setf cucumber + +" Communicating Sequential Processes +au BufNewFile,BufRead *.csp,*.fdr setf csp + +" CUPL logic description and simulation +au BufNewFile,BufRead *.pld setf cupl +au BufNewFile,BufRead *.si setf cuplsim + +" Debian Control +au BufNewFile,BufRead */debian/control setf debcontrol +au BufNewFile,BufRead control + \ if getline(1) =~ '^Source:' + \| setf debcontrol + \| endif + +" Debian Sources.list +au BufNewFile,BufRead /etc/apt/sources.list setf debsources + +" Deny hosts +au BufNewFile,BufRead denyhosts.conf setf denyhosts + +" ROCKLinux package description +au BufNewFile,BufRead *.desc setf desc + +" the D language or dtrace +au BufNewFile,BufRead *.d call s:DtraceCheck() + +func! s:DtraceCheck() + let lines = getline(1, min([line("$"), 100])) + if match(lines, '^#!\S\+dtrace\|#pragma\s\+D\s\+option\|:\S\{-}:\S\{-}:') > -1 + setf dtrace + else + setf d + endif +endfunc + +" Desktop files +au BufNewFile,BufRead *.desktop,.directory setf desktop + +" Dict config +au BufNewFile,BufRead dict.conf,.dictrc setf dictconf + +" Dictd config +au BufNewFile,BufRead dictd.conf setf dictdconf + +" Diff files +au BufNewFile,BufRead *.diff,*.rej,*.patch setf diff + +" Dircolors +au BufNewFile,BufRead .dir_colors,/etc/DIR_COLORS setf dircolors + +" Diva (with Skill) or InstallShield +au BufNewFile,BufRead *.rul + \ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield' | + \ setf ishd | + \ else | + \ setf diva | + \ endif + +" DCL (Digital Command Language - vms) or DNS zone file +au BufNewFile,BufRead *.com call s:BindzoneCheck('dcl') + +" DOT +au BufNewFile,BufRead *.dot setf dot + +" Dylan - lid files +au BufNewFile,BufRead *.lid setf dylanlid + +" Dylan - intr files (melange) +au BufNewFile,BufRead *.intr setf dylanintr + +" Dylan +au BufNewFile,BufRead *.dylan setf dylan + +" Microsoft Module Definition +au BufNewFile,BufRead *.def setf def + +" Dracula +au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe setf dracula + +" Datascript +au BufNewFile,BufRead *.ds setf datascript + +" dsl +au BufNewFile,BufRead *.dsl setf dsl + +" DTD (Document Type Definition for XML) +au BufNewFile,BufRead *.dtd setf dtd + +" EDIF (*.edf,*.edif,*.edn,*.edo) +au BufNewFile,BufRead *.ed\(f\|if\|n\|o\) setf edif + +" Embedix Component Description +au BufNewFile,BufRead *.ecd setf ecd + +" Eiffel or Specman +au BufNewFile,BufRead *.e,*.E call s:FTe() + +" Elinks configuration +au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf setf elinks + +func! s:FTe() + let n = 1 + while n < 100 && n < line("$") + if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$" + setf specman + return + endif + let n = n + 1 + endwhile + setf eiffel +endfunc + +" ERicsson LANGuage; Yaws is erlang too +au BufNewFile,BufRead *.erl,*.hrl,*.yaws setf erlang + +" Elm Filter Rules file +au BufNewFile,BufRead filter-rules setf elmfilt + +" ESMTP rc file +au BufNewFile,BufRead *esmtprc setf esmtprc + +" ESQL-C +au BufNewFile,BufRead *.ec,*.EC setf esqlc + +" Esterel +au BufNewFile,BufRead *.strl setf esterel + +" Essbase script +au BufNewFile,BufRead *.csc setf csc + +" Exim +au BufNewFile,BufRead exim.conf setf exim + +" Expect +au BufNewFile,BufRead *.exp setf expect + +" Exports +au BufNewFile,BufRead exports setf exports + +" Fantom +au BufNewFile,BufRead *.fan,*.fwt setf fan + +" Factor +au BufNewFile,BufRead *.factor setf factor + +" Fetchmail RC file +au BufNewFile,BufRead .fetchmailrc setf fetchmail + +" FlexWiki - disabled, because it has side effects when a .wiki file +" is not actually FlexWiki +"au BufNewFile,BufRead *.wiki setf flexwiki + +" Focus Executable +au BufNewFile,BufRead *.fex,*.focexec setf focexec + +" Focus Master file (but not for auto.master) +au BufNewFile,BufRead auto.master setf conf +au BufNewFile,BufRead *.mas,*.master setf master + +" Forth +au BufNewFile,BufRead *.fs,*.ft setf forth + +" Reva Forth +au BufNewFile,BufRead *.frt setf reva + +" Fortran +if has("fname_case") + au BufNewFile,BufRead *.F,*.FOR,*.FPP,*.FTN,*.F77,*.F90,*.F95,*.F03,*.F08 setf fortran +endif +au BufNewFile,BufRead *.f,*.for,*.fortran,*.fpp,*.ftn,*.f77,*.f90,*.f95,*.f03,*.f08 setf fortran + +" Framescript +au BufNewFile,BufRead *.fsl setf framescript + +" FStab +au BufNewFile,BufRead fstab,mtab setf fstab + +" GDB command files +au BufNewFile,BufRead .gdbinit setf gdb + +" GDMO +au BufNewFile,BufRead *.mo,*.gdmo setf gdmo + +" Gedcom +au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom + +" Git +autocmd BufNewFile,BufRead *.git/COMMIT_EDITMSG setf gitcommit +autocmd BufNewFile,BufRead *.git/config,.gitconfig,.gitmodules setf gitconfig +autocmd BufNewFile,BufRead git-rebase-todo setf gitrebase +autocmd BufNewFile,BufRead .msg.[0-9]* + \ if getline(1) =~ '^From.*# This line is ignored.$' | + \ setf gitsendemail | + \ endif +autocmd BufNewFile,BufRead *.git/** + \ if getline(1) =~ '^\x\{40\}\>\|^ref: ' | + \ setf git | + \ endif + +" Gkrellmrc +au BufNewFile,BufRead gkrellmrc,gkrellmrc_? setf gkrellmrc + +" GP scripts (2.0 and onward) +au BufNewFile,BufRead *.gp,.gprc setf gp + +" GPG +au BufNewFile,BufRead */.gnupg/options setf gpg +au BufNewFile,BufRead */.gnupg/gpg.conf setf gpg +au BufNewFile,BufRead /usr/**/gnupg/options.skel setf gpg + +" Gnuplot scripts +au BufNewFile,BufRead *.gpi setf gnuplot + +" GrADS scripts +au BufNewFile,BufRead *.gs setf grads + +" Gretl +au BufNewFile,BufRead *.gretl setf gretl + +" Groovy +au BufNewFile,BufRead *.groovy setf groovy + +" GNU Server Pages +au BufNewFile,BufRead *.gsp setf gsp + +" Group file +au BufNewFile,BufRead /etc/group,/etc/group-,/etc/group.edit,/etc/gshadow,/etc/gshadow-,/etc/gshadow.edit,/var/backups/group.bak,/var/backups/gshadow.bak setf group + +" GTK RC +au BufNewFile,BufRead .gtkrc,gtkrc setf gtkrc + +" Haml +au BufNewFile,BufRead *.haml setf haml + +" Hamster Classic | Playground files +au BufNewFile,BufRead *.hsc,*.hsm setf hamster + +" Haskell +au BufNewFile,BufRead *.hs,*.hs-boot setf haskell +au BufNewFile,BufRead *.lhs setf lhaskell +au BufNewFile,BufRead *.chs setf chaskell + +" Haste +au BufNewFile,BufRead *.ht setf haste +au BufNewFile,BufRead *.htpp setf hastepreproc + +" Hercules +au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum setf hercules + +" HEX (Intel) +au BufNewFile,BufRead *.hex,*.h32 setf hex + +" Tilde (must be before HTML) +au BufNewFile,BufRead *.t.html setf tilde + +" HTML (.shtml and .stm for server side) +au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm call s:FThtml() + +" Distinguish between HTML, XHTML and Django +func! s:FThtml() + let n = 1 + while n < 10 && n < line("$") + if getline(n) =~ '\' + setf htmldjango + return + endif + let n = n + 1 + endwhile + setf html +endfunc + +" HTML with Ruby - eRuby +au BufNewFile,BufRead *.erb,*.rhtml setf eruby + +" HTML with M4 +au BufNewFile,BufRead *.html.m4 setf htmlm4 + +" HTML Cheetah template +au BufNewFile,BufRead *.tmpl setf htmlcheetah + +" Host config +au BufNewFile,BufRead /etc/host.conf setf hostconf + +" Hosts access +au BufNewFile,BufRead /etc/hosts.allow,/etc/hosts.deny setf hostsaccess + +" Hyper Builder +au BufNewFile,BufRead *.hb setf hb + +" Icon +au BufNewFile,BufRead *.icn setf icon + +" IDL (Interface Description Language) +au BufNewFile,BufRead *.idl call s:FTidl() + +" Distinguish between standard IDL and MS-IDL +func! s:FTidl() + let n = 1 + while n < 50 && n < line("$") + if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"' + setf msidl + return + endif + let n = n + 1 + endwhile + setf idl +endfunc + +" Microsoft IDL (Interface Description Language) Also *.idl +" MOF = WMI (Windows Management Instrumentation) Managed Object Format +au BufNewFile,BufRead *.odl,*.mof setf msidl + +" Icewm menu +au BufNewFile,BufRead */.icewm/menu setf icemenu + +" Indent profile (must come before IDL *.pro!) +au BufNewFile,BufRead .indent.pro setf indent +au BufNewFile,BufRead indent.pro call s:ProtoCheck('indent') + +" IDL (Interactive Data Language) +au BufNewFile,BufRead *.pro call s:ProtoCheck('idlang') + +" Distinguish between "default" and Cproto prototype file. */ +func! s:ProtoCheck(default) + " Cproto files have a comment in the first line and a function prototype in + " the second line, it always ends in ";". Indent files may also have + " comments, thus we can't match comments to see the difference. + if getline(2) =~ ';$' + setf cpp + else + exe 'setf ' . a:default + endif +endfunc + + +" Indent RC +au BufNewFile,BufRead indentrc setf indent + +" Inform +au BufNewFile,BufRead *.inf,*.INF setf inform + +" Initng +au BufNewFile,BufRead /etc/initng/**/*.i,*.ii setf initng + +" Ipfilter +au BufNewFile,BufRead ipf.conf,ipf6.conf,ipf.rules setf ipfilter + +" Informix 4GL (source - canonical, include file, I4GL+M4 preproc.) +au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl setf fgl + +" .INI file for MSDOS +au BufNewFile,BufRead *.ini setf dosini + +" SysV Inittab +au BufNewFile,BufRead inittab setf inittab + +" Inno Setup +au BufNewFile,BufRead *.iss setf iss + +" JAL +au BufNewFile,BufRead *.jal,*.JAL setf jal + +" Jam +au BufNewFile,BufRead *.jpl,*.jpr setf jam + +" Java +au BufNewFile,BufRead *.java,*.jav setf java + +" JavaCC +au BufNewFile,BufRead *.jj,*.jjt setf javacc + +" JavaScript, ECMAScript +au BufNewFile,BufRead *.js,*.javascript,*.es,*.jsx setf javascript + +" Java Server Pages +au BufNewFile,BufRead *.jsp setf jsp + +" Java Properties resource file (note: doesn't catch font.properties.pl) +au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_?? setf jproperties +au BufNewFile,BufRead *.properties_??_??_* call s:StarSetf('jproperties') + +" Jess +au BufNewFile,BufRead *.clp setf jess + +" Jgraph +au BufNewFile,BufRead *.jgr setf jgraph + +" Kixtart +au BufNewFile,BufRead *.kix setf kix + +" Kimwitu[++] +au BufNewFile,BufRead *.k setf kwt + +" KDE script +au BufNewFile,BufRead *.ks setf kscript + +" Kconfig +au BufNewFile,BufRead Kconfig,Kconfig.debug setf kconfig + +" Lace (ISE) +au BufNewFile,BufRead *.ace,*.ACE setf lace + +" Latte +au BufNewFile,BufRead *.latte,*.lte setf latte + +" Limits +au BufNewFile,BufRead /etc/limits setf limits + +" LambdaProlog (*.mod too, see Modsim) +au BufNewFile,BufRead *.sig setf lprolog + +" LDAP LDIF +au BufNewFile,BufRead *.ldif setf ldif + +" Ld loader +au BufNewFile,BufRead *.ld setf ld + +" Lex +au BufNewFile,BufRead *.lex,*.l setf lex + +" Libao +au BufNewFile,BufRead /etc/libao.conf,*/.libao setf libao + +" Libsensors +au BufNewFile,BufRead /etc/sensors.conf setf sensors + +" LFTP +au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc setf lftp + +" Lifelines (or Lex for C++!) +au BufNewFile,BufRead *.ll setf lifelines + +" Lilo: Linux loader +au BufNewFile,BufRead lilo.conf* call s:StarSetf('lilo') + +" Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp) +if has("fname_case") + au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp +else + au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp +endif + +" SBCL implementation of Common Lisp +au BufNewFile,BufRead sbclrc,.sbclrc setf lisp + +" Liquid +au BufNewFile,BufRead *.liquid setf liquid + +" Lite +au BufNewFile,BufRead *.lite,*.lt setf lite + +" LiteStep RC files +au BufNewFile,BufRead */LiteStep/*/*.rc setf litestep + +" Login access +au BufNewFile,BufRead /etc/login.access setf loginaccess + +" Login defs +au BufNewFile,BufRead /etc/login.defs setf logindefs + +" Logtalk +au BufNewFile,BufRead *.lgt setf logtalk + +" LOTOS +au BufNewFile,BufRead *.lot,*.lotos setf lotos + +" Lout (also: *.lt) +au BufNewFile,BufRead *.lou,*.lout setf lout + +" Lua +au BufNewFile,BufRead *.lua setf lua + +" Linden Scripting Language (Second Life) +au BufNewFile,BufRead *.lsl setf lsl + +" Lynx style file (or LotusScript!) +au BufNewFile,BufRead *.lss setf lss + +" M4 +au BufNewFile,BufRead *.m4 + \ if expand("") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif + +" MaGic Point +au BufNewFile,BufRead *.mgp setf mgp + +" Mail (for Elm, trn, mutt, muttng, rn, slrn) +au BufNewFile,BufRead snd.\d\+,.letter,.letter.\d\+,.followup,.article,.article.\d\+,pico.\d\+,mutt{ng,}-*-\w\+,mutt[[:alnum:]_-]\{6\},ae\d\+.txt,/tmp/SLRN[0-9A-Z.]\+,*.eml setf mail + +" Mail aliases +au BufNewFile,BufRead /etc/mail/aliases,/etc/aliases setf mailaliases + +" Mailcap configuration file +au BufNewFile,BufRead .mailcap,mailcap setf mailcap + +" Makefile +au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make + +" MakeIndex +au BufNewFile,BufRead *.ist,*.mst setf ist + +" Manpage +au BufNewFile,BufRead *.man setf man + +" Man config +au BufNewFile,BufRead /etc/man.conf,man.config setf manconf + +" Maple V +au BufNewFile,BufRead *.mv,*.mpl,*.mws setf maple + +" Map (UMN mapserver config file) +au BufNewFile,BufRead *.map setf map + +" Markdown +au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,README.md setf markdown + +" Mason +au BufNewFile,BufRead *.mason,*.mhtml setf mason + +" Matlab or Objective C +au BufNewFile,BufRead *.m call s:FTm() + +func! s:FTm() + let n = 1 + while n < 10 + let line = getline(n) + if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\|//\)' + setf objc + return + endif + if line =~ '^\s*%' + setf matlab + return + endif + if line =~ '^\s*(\*' + setf mma + return + endif + let n = n + 1 + endwhile + if exists("g:filetype_m") + exe "setf " . g:filetype_m + else + setf matlab + endif +endfunc + +" Mathematica notebook +au BufNewFile,BufRead *.nb setf mma + +" Maya Extension Language +au BufNewFile,BufRead *.mel setf mel + +" Mercurial config (looks like generic config file) +au BufNewFile,BufRead *.hgrc,*hgrc setf cfg + +" Messages +au BufNewFile,BufRead /var/log/messages,/var/log/messages.*[0-9] setf messages + +" Metafont +au BufNewFile,BufRead *.mf setf mf + +" MetaPost +au BufNewFile,BufRead *.mp setf mp + +" MGL +au BufNewFile,BufRead *.mgl setf mgl + +" MMIX or VMS makefile +au BufNewFile,BufRead *.mms call s:FTmms() + +" Symbian meta-makefile definition (MMP) +au BufNewFile,BufRead *.mmp setf mmp + +func! s:FTmms() + let n = 1 + while n < 10 + let line = getline(n) + if line =~ '^\s*\(%\|//\)' || line =~ '^\*' + setf mmix + return + endif + if line =~ '^\s*#' + setf make + return + endif + let n = n + 1 + endwhile + setf mmix +endfunc + + +" Modsim III (or LambdaProlog) +au BufNewFile,BufRead *.mod + \ if getline(1) =~ '\' | + \ setf lprolog | + \ else | + \ setf modsim3 | + \ endif + +" Modula 2 +au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.md,*.mi setf modula2 + +" Modula 3 (.m3, .i3, .mg, .ig) +au BufNewFile,BufRead *.[mi][3g] setf modula3 + +" Monk +au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc setf monk + +" MOO +au BufNewFile,BufRead *.moo setf moo + +" Modconf +au BufNewFile,BufRead /etc/modules.conf,/etc/conf.modules setf modconf +au BufNewFile,BufRead /etc/modutils/* + \ if executable(expand("")) != 1 + \| call s:StarSetf('modconf') + \|endif + +" Mplayer config +au BufNewFile,BufRead mplayer.conf,*/.mplayer/config setf mplayerconf + +" Moterola S record +au BufNewFile,BufRead *.s19,*.s28,*.s37 setf srec + +" Mrxvtrc +au BufNewFile,BufRead mrxvtrc,.mrxvtrc setf mrxvtrc + +" Msql +au BufNewFile,BufRead *.msql setf msql + +" Mysql +au BufNewFile,BufRead *.mysql setf mysql + +" M$ Resource files +au BufNewFile,BufRead *.rc setf rc + +" MuPAD source +au BufRead,BufNewFile *.mu setf mupad + +" Mush +au BufNewFile,BufRead *.mush setf mush + +" Mutt setup file (also for Muttng) +au BufNewFile,BufRead Mutt{ng,}rc setf muttrc + +" Nano +au BufNewFile,BufRead /etc/nanorc,.nanorc setf nanorc + +" Nastran input/DMAP +"au BufNewFile,BufRead *.dat setf nastran + +" Natural +au BufNewFile,BufRead *.NS[ACGLMNPS] setf natural + +" Netrc +au BufNewFile,BufRead .netrc setf netrc + +" Novell netware batch files +au BufNewFile,BufRead *.ncf setf ncf + +" Nroff/Troff (*.ms and *.t are checked below) +au BufNewFile,BufRead *.me + \ if expand("") != "read.me" && expand("") != "click.me" | + \ setf nroff | + \ endif +au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom setf nroff +au BufNewFile,BufRead *.[1-9] call s:FTnroff() + +" This function checks if one of the first five lines start with a dot. In +" that case it is probably an nroff file: 'filetype' is set and 1 is returned. +func! s:FTnroff() + if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.' + setf nroff + return 1 + endif + return 0 +endfunc + +" Nroff or Objective C++ +au BufNewFile,BufRead *.mm call s:FTmm() + +func! s:FTmm() + let n = 1 + while n < 10 + let line = getline(n) + if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)' + setf objcpp + return + endif + let n = n + 1 + endwhile + setf nroff +endfunc + +" Not Quite C +au BufNewFile,BufRead *.nqc setf nqc + +" NSIS +au BufNewFile,BufRead *.nsi setf nsis + +" OCAML +au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly setf ocaml + +" Occam +au BufNewFile,BufRead *.occ setf occam + +" Omnimark +au BufNewFile,BufRead *.xom,*.xin setf omnimark + +" OpenROAD +au BufNewFile,BufRead *.or setf openroad + +" OPL +au BufNewFile,BufRead *.[Oo][Pp][Ll] setf opl + +" Oracle config file +au BufNewFile,BufRead *.ora setf ora + +" Packet filter conf +au BufNewFile,BufRead pf.conf setf pf + +" Pam conf +au BufNewFile,BufRead /etc/pam.conf setf pamconf + +" PApp +au BufNewFile,BufRead *.papp,*.pxml,*.pxsl setf papp + +" Password file +au BufNewFile,BufRead /etc/passwd,/etc/passwd-,/etc/passwd.edit,/etc/shadow,/etc/shadow-,/var/backups/passwd.bak,/var/backups/shadow.bak setf passwd + +" Pascal (also *.p) +au BufNewFile,BufRead *.pas setf pascal + +" Delphi project file +au BufNewFile,BufRead *.dpr setf pascal + +" PDF +au BufNewFile,BufRead *.pdf setf pdf + +" Perl +if has("fname_case") + au BufNewFile,BufRead *.pl,*.PL call s:FTpl() +else + au BufNewFile,BufRead *.pl call s:FTpl() +endif +au BufNewFile,BufRead *.plx,*.al setf perl +au BufNewFile,BufRead *.p6,*.pm6 setf perl6 + +func! s:FTpl() + if exists("g:filetype_pl") + exe "setf " . g:filetype_pl + else + " recognize Prolog by specific text in the first non-empty line + " require a blank after the '%' because Perl uses "%list" and "%translate" + let l = getline(nextnonblank(1)) + if l =~ '\' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-' + setf prolog + else + setf perl + endif + endif +endfunc + +" Perl, XPM or XPM2 +au BufNewFile,BufRead *.pm + \ if getline(1) =~ "XPM2" | + \ setf xpm2 | + \ elseif getline(1) =~ "XPM" | + \ setf xpm | + \ else | + \ setf perl | + \ endif + +" Perl POD +au BufNewFile,BufRead *.pod setf pod + +" Php, php3, php4, etc. +" Also Phtml (was used for PHP 2 in the past) +" Also .ctp for Cake template file +au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp setf php + +" Pike +au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike + +" Pinfo config +au BufNewFile,BufRead */etc/pinforc,*/.pinforc setf pinfo + +" Palm Resource compiler +au BufNewFile,BufRead *.rcp setf pilrc + +" Pine config +au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex setf pine + +" PL/M (also: *.inp) +au BufNewFile,BufRead *.plm,*.p36,*.pac setf plm + +" PL/SQL +au BufNewFile,BufRead *.pls,*.plsql setf plsql + +" PLP +au BufNewFile,BufRead *.plp setf plp + +" PO and PO template (GNU gettext) +au BufNewFile,BufRead *.po,*.pot setf po + +" Postfix main config +au BufNewFile,BufRead main.cf setf pfmain + +" PostScript (+ font files, encapsulated PostScript, Adobe Illustrator) +au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai setf postscr + +" PostScript Printer Description +au BufNewFile,BufRead *.ppd setf ppd + +" Povray +au BufNewFile,BufRead *.pov setf pov + +" Povray configuration +au BufNewFile,BufRead .povrayrc setf povini + +" Povray, PHP or assembly +au BufNewFile,BufRead *.inc call s:FTinc() + +func! s:FTinc() + if exists("g:filetype_inc") + exe "setf " . g:filetype_inc + else + let lines = getline(1).getline(2).getline(3) + if lines =~? "perlscript" + setf aspperl + elseif lines =~ "<%" + setf aspvbs + elseif lines =~ "' + \ || line =~ '^\s*{' || line =~ '^\s*(\*' + setf pascal + return + elseif line !~ '^\s*$' || line =~ '^/\*' + " Not an empty line: Doesn't look like valid Pascal code. + " Or it looks like a Progress /* comment + break + endif + let lnum = lnum + 1 + endw + setf progress +endfunc + + +" Software Distributor Product Specification File (POSIX 1387.2-1995) +au BufNewFile,BufRead *.psf setf psf +au BufNewFile,BufRead INDEX,INFO + \ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' | + \ setf psf | + \ endif + +" Prolog +au BufNewFile,BufRead *.pdb setf prolog + +" Promela +au BufNewFile,BufRead *.pml setf promela + +" Protocols +au BufNewFile,BufRead /etc/protocols setf protocols + +" Pyrex +au BufNewFile,BufRead *.pyx,*.pxd setf pyrex + +" Python +au BufNewFile,BufRead *.py,*.pyw setf python + +" Quixote (Python-based web framework) +au BufNewFile,BufRead *.ptl setf python + +" Radiance +au BufNewFile,BufRead *.rad,*.mat setf radiance + +" Ratpoison config/command files +au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc setf ratpoison + +" RCS file +au BufNewFile,BufRead *\,v setf rcs + +" Readline +au BufNewFile,BufRead .inputrc,inputrc setf readline + +" Registry for MS-Windows +au BufNewFile,BufRead *.reg + \ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif + +" Renderman Interface Bytestream +au BufNewFile,BufRead *.rib setf rib + +" Rexx +au BufNewFile,BufRead *.rexx,*.rex,*.jrexx,*.rxj,*.orx setf rexx + +" R (Splus) +if has("fname_case") + au BufNewFile,BufRead *.s,*.S setf r +else + au BufNewFile,BufRead *.s setf r +endif + +" R Help file +if has("fname_case") + au BufNewFile,BufRead *.rd,*.Rd setf rhelp +else + au BufNewFile,BufRead *.rd setf rhelp +endif + +" R noweb file +if has("fname_case") + au BufNewFile,BufRead *.Rnw,*.rnw,*.Snw,*.snw setf rnoweb +else + au BufNewFile,BufRead *.rnw,*.snw setf rnoweb +endif + +" Rexx, Rebol or R +au BufNewFile,BufRead *.r,*.R call s:FTr() + +func! s:FTr() + let max = line("$") > 50 ? 50 : line("$") + + for n in range(1, max) + " Rebol is easy to recognize, check for that first + if getline(n) =~? '\' + setf rebol + return + endif + endfor + + for n in range(1, max) + " R has # comments + if getline(n) =~ '^\s*#' + setf r + return + endif + " Rexx has /* comments */ + if getline(n) =~ '^\s*/\*' + setf rexx + return + endif + endfor + + " Nothing recognized, assume Rexx + setf rexx +endfunc + +" Remind +au BufNewFile,BufRead .reminders* call s:StarSetf('remind') +au BufNewFile,BufRead *.remind,*.rem setf remind + +" Resolv.conf +au BufNewFile,BufRead resolv.conf setf resolv + +" Relax NG Compact +au BufNewFile,BufRead *.rnc setf rnc + +" RPL/2 +au BufNewFile,BufRead *.rpl setf rpl + +" Robots.txt +au BufNewFile,BufRead robots.txt setf robots + +" Rpcgen +au BufNewFile,BufRead *.x setf rpcgen + +" reStructuredText Documentation Format +au BufNewFile,BufRead *.rst setf rst + +" RTF +au BufNewFile,BufRead *.rtf setf rtf + +" Interactive Ruby shell +au BufNewFile,BufRead .irbrc,irbrc setf ruby + +" Ruby +au BufNewFile,BufRead *.rb,*.rbw,*.gem,*.gemspec setf ruby + +" Ruby on Rails +au BufNewFile,BufRead *.builder,*.rxml,*.rjs setf ruby + +" Rantfile and Rakefile is like Ruby +au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake setf ruby + +" S-lang (or shader language, or SmallLisp) +au BufNewFile,BufRead *.sl setf slang + +" Samba config +au BufNewFile,BufRead smb.conf setf samba + +" SAS script +au BufNewFile,BufRead *.sas setf sas + +" Sass +au BufNewFile,BufRead *.sass setf sass + +" Sather +au BufNewFile,BufRead *.sa setf sather + +" Scilab +au BufNewFile,BufRead *.sci,*.sce setf scilab + +" SCSS +au BufNewFile,BufRead *.scss setf scss + +" SD: Streaming Descriptors +au BufNewFile,BufRead *.sd setf sd + +" SDL +au BufNewFile,BufRead *.sdl,*.pr setf sdl + +" sed +au BufNewFile,BufRead *.sed setf sed + +" Sieve (RFC 3028) +au BufNewFile,BufRead *.siv setf sieve + +" Sendmail +au BufNewFile,BufRead sendmail.cf setf sm + +" Sendmail .mc files are actually m4. Could also be MS Message text file. +au BufNewFile,BufRead *.mc call s:McSetf() + +func! s:McSetf() + " Rely on the file to start with a comment. + " MS message text files use ';', Sendmail files use '#' or 'dnl' + for lnum in range(1, min([line("$"), 20])) + let line = getline(lnum) + if line =~ '^\s*\(#\|dnl\)' + setf m4 " Sendmail .mc file + return + elseif line =~ '^\s*;' + setf msmessages " MS Message text file + return + endif + endfor + setf m4 " Default: Sendmail .mc file +endfunc + +" Services +au BufNewFile,BufRead /etc/services setf services + +" Service Location config +au BufNewFile,BufRead /etc/slp.conf setf slpconf + +" Service Location registration +au BufNewFile,BufRead /etc/slp.reg setf slpreg + +" Service Location SPI +au BufNewFile,BufRead /etc/slp.spi setf slpspi + +" Setserial config +au BufNewFile,BufRead /etc/serial.conf setf setserial + +" SGML +au BufNewFile,BufRead *.sgm,*.sgml + \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' | + \ setf sgmllnx | + \ elseif getline(1) =~ '") =~ g:ft_ignore_pat + return + endif + if a:name =~ '\' + " Some .sh scripts contain #!/bin/csh. + call SetFileTypeShell("csh") + return + elseif a:name =~ '\' + " Some .sh scripts contain #!/bin/tcsh. + call SetFileTypeShell("tcsh") + return + elseif a:name =~ '\' + let b:is_kornshell = 1 + if exists("b:is_bash") + unlet b:is_bash + endif + if exists("b:is_sh") + unlet b:is_sh + endif + elseif exists("g:bash_is_sh") || a:name =~ '\' || a:name =~ '\' + let b:is_bash = 1 + if exists("b:is_kornshell") + unlet b:is_kornshell + endif + if exists("b:is_sh") + unlet b:is_sh + endif + elseif a:name =~ '\' + let b:is_sh = 1 + if exists("b:is_kornshell") + unlet b:is_kornshell + endif + if exists("b:is_bash") + unlet b:is_bash + endif + endif + call SetFileTypeShell("sh") +endfunc + +" For shell-like file types, check for an "exec" command hidden in a comment, +" as used for Tcl. +" Also called from scripts.vim, thus can't be local to this script. +func! SetFileTypeShell(name) + if expand("") =~ g:ft_ignore_pat + return + endif + let l = 2 + while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)' + " Skip empty and comment lines. + let l = l + 1 + endwhile + if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$' + " Found an "exec" line after a comment with continuation + let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '') + if n =~ '\' | + \ setf xml | + \ else | + \ setf smil | + \ endif + +" SMIL or SNMP MIB file +au BufNewFile,BufRead *.smi + \ if getline(1) =~ '\' | + \ setf smil | + \ else | + \ setf mib | + \ endif + +" SMITH +au BufNewFile,BufRead *.smt,*.smith setf smith + +" Snobol4 and spitbol +au BufNewFile,BufRead *.sno,*.spt setf snobol4 + +" SNMP MIB files +au BufNewFile,BufRead *.mib,*.my setf mib + +" Snort Configuration +au BufNewFile,BufRead *.hog,snort.conf,vision.conf setf hog +au BufNewFile,BufRead *.rules call s:FTRules() + +let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*' +func! s:FTRules() + let path = expand(':p') + if path =~ '^/etc/udev/\%(rules\.d/\)\=.*\.rules$' + setf udevrules + return + endif + if path =~ '^/etc/ufw/' + setf conf " Better than hog + return + endif + try + let config_lines = readfile('/etc/udev/udev.conf') + catch /^Vim\%((\a\+)\)\=:E484/ + setf hog + return + endtry + let dir = expand(':p:h') + for line in config_lines + if line =~ s:ft_rules_udev_rules_pattern + let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "") + if dir == udev_rules + setf udevrules + endif + break + endif + endfor + setf hog +endfunc + + +" Spec (Linux RPM) +au BufNewFile,BufRead *.spec setf spec + +" Speedup (AspenTech plant simulator) +au BufNewFile,BufRead *.speedup,*.spdata,*.spd setf spup + +" Slice +au BufNewFile,BufRead *.ice setf slice + +" Spice +au BufNewFile,BufRead *.sp,*.spice setf spice + +" Spyce +au BufNewFile,BufRead *.spy,*.spi setf spyce + +" Squid +au BufNewFile,BufRead squid.conf setf squid + +" SQL for Oracle Designer +au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks setf sql + +" SQL +au BufNewFile,BufRead *.sql call s:SQL() + +func! s:SQL() + if exists("g:filetype_sql") + exe "setf " . g:filetype_sql + else + setf sql + endif +endfunc + +" SQLJ +au BufNewFile,BufRead *.sqlj setf sqlj + +" SQR +au BufNewFile,BufRead *.sqr,*.sqi setf sqr + +" OpenSSH configuration +au BufNewFile,BufRead ssh_config,*/.ssh/config setf sshconfig + +" OpenSSH server configuration +au BufNewFile,BufRead sshd_config setf sshdconfig + +" Stata +au BufNewFile,BufRead *.ado,*.class,*.do,*.imata,*.mata setf stata + +" SMCL +au BufNewFile,BufRead *.hlp,*.ihlp,*.smcl setf smcl + +" Stored Procedures +au BufNewFile,BufRead *.stp setf stp + +" Standard ML +au BufNewFile,BufRead *.sml setf sml + +" Sratus VOS command macro +au BufNewFile,BufRead *.cm setf voscm + +" Sysctl +au BufNewFile,BufRead /etc/sysctl.conf setf sysctl + +" Synopsys Design Constraints +au BufNewFile,BufRead *.sdc setf sdc + +" Sudoers +au BufNewFile,BufRead /etc/sudoers,sudoers.tmp setf sudoers + +" SVG (Scalable Vector Graphics) +au BufNewFile,BufRead *.svg setf svg + +" If the file has an extension of 't' and is in a directory 't' then it is +" almost certainly a Perl test file. +" If the first line starts with '#' and contains 'perl' it's probably a Perl +" file. +" (Slow test) If a file contains a 'use' statement then it is almost certainly +" a Perl file. +func! s:FTperl() + if expand("%:e") == 't' && expand("%:p:h:t") == 't' + setf perl + return 1 + endif + if getline(1)[0] == '#' && getline(1) =~ 'perl' + setf perl + return 1 + endif + if search('^use\s\s*\k', 'nc', 30) + setf perl + return 1 + endif + return 0 +endfunc + +" Tads (or Nroff or Perl test file) +au BufNewFile,BufRead *.t + \ if !s:FTnroff() && !s:FTperl() | setf tads | endif + +" Tags +au BufNewFile,BufRead tags setf tags + +" TAK +au BufNewFile,BufRead *.tak setf tak + +" Task +au BufRead,BufNewFile {pending,completed,undo}.data setf taskdata +au BufRead,BufNewFile *.task setf taskedit + +" Tcl (JACL too) +au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl setf tcl + +" TealInfo +au BufNewFile,BufRead *.tli setf tli + +" Telix Salt +au BufNewFile,BufRead *.slt setf tsalt + +" Terminfo +au BufNewFile,BufRead *.ti setf terminfo + +" TeX +au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl setf tex +au BufNewFile,BufRead *.tex call s:FTtex() + +" Choose context, plaintex, or tex (LaTeX) based on these rules: +" 1. Check the first line of the file for "%&". +" 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords. +" 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc. +func! s:FTtex() + let firstline = getline(1) + if firstline =~ '^%&\s*\a\+' + let format = tolower(matchstr(firstline, '\a\+')) + let format = substitute(format, 'pdf', '', '') + if format == 'tex' + let format = 'plain' + endif + else + " Default value, may be changed later: + let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain' + " Save position, go to the top of the file, find first non-comment line. + let save_cursor = getpos('.') + call cursor(1,1) + let firstNC = search('^\s*[^[:space:]%]', 'c', 1000) + if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword. + let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>' + let cpat = 'start\a\+\|setup\a\+\|usemodule\|enablemode\|enableregime\|setvariables\|useencoding\|usesymbols\|stelle\a\+\|verwende\a\+\|stel\a\+\|gebruik\a\+\|usa\a\+\|imposta\a\+\|regle\a\+\|utilisemodule\>' + let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)', + \ 'cnp', firstNC + 1000) + if kwline == 1 " lpat matched + let format = 'latex' + elseif kwline == 2 " cpat matched + let format = 'context' + endif " If neither matched, keep default set above. + " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000) + " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000) + " if cline > 0 + " let format = 'context' + " endif + " if lline > 0 && (cline == 0 || cline > lline) + " let format = 'tex' + " endif + endif " firstNC + call setpos('.', save_cursor) + endif " firstline =~ '^%&\s*\a\+' + + " Translation from formats to file types. TODO: add AMSTeX, RevTex, others? + if format == 'plain' + setf plaintex + elseif format == 'context' + setf context + else " probably LaTeX + setf tex + endif + return +endfunc + +" ConTeXt +au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv setf context + +" Texinfo +au BufNewFile,BufRead *.texinfo,*.texi,*.txi setf texinfo + +" TeX configuration +au BufNewFile,BufRead texmf.cnf setf texmf + +" Tidy config +au BufNewFile,BufRead .tidyrc,tidyrc setf tidy + +" TF mud client +au BufNewFile,BufRead *.tf,.tfrc,tfrc setf tf + +" TPP - Text Presentation Program +au BufNewFile,BufReadPost *.tpp setf tpp + +" Trustees +au BufNewFile,BufRead trustees.conf setf trustees + +" TSS - Geometry +au BufNewFile,BufReadPost *.tssgm setf tssgm + +" TSS - Optics +au BufNewFile,BufReadPost *.tssop setf tssop + +" TSS - Command Line (temporary) +au BufNewFile,BufReadPost *.tsscl setf tsscl + +" Motif UIT/UIL files +au BufNewFile,BufRead *.uit,*.uil setf uil + +" Udev conf +au BufNewFile,BufRead /etc/udev/udev.conf setf udevconf + +" Udev permissions +au BufNewFile,BufRead /etc/udev/permissions.d/*.permissions setf udevperm +" +" Udev symlinks config +au BufNewFile,BufRead /etc/udev/cdsymlinks.conf setf sh + +" UnrealScript +au BufNewFile,BufRead *.uc setf uc + +" Updatedb +au BufNewFile,BufRead /etc/updatedb.conf setf updatedb + +" Vera +au BufNewFile,BufRead *.vr,*.vri,*.vrh setf vera + +" Verilog HDL +au BufNewFile,BufRead *.v setf verilog + +" Verilog-AMS HDL +au BufNewFile,BufRead *.va,*.vams setf verilogams + +" VHDL +au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vbe,*.vst setf vhdl +au BufNewFile,BufRead *.vhdl_[0-9]* call s:StarSetf('vhdl') + +" Vim script +au BufNewFile,BufRead *.vim,*.vba,.exrc,_exrc setf vim + +" Viminfo file +au BufNewFile,BufRead .viminfo,_viminfo setf viminfo + +" Virata Config Script File or Drupal module +au BufRead,BufNewFile *.hw,*.module,*.pkg + \ if getline(1) =~ '' | + \ let b:xf86c_xfree86_version = 3 | + \ endif | + \ setf xf86conf + +" Xorg config +au BufNewFile,BufRead xorg.conf,xorg.conf-4 let b:xf86c_xfree86_version = 4 | setf xf86conf + +" Xinetd conf +au BufNewFile,BufRead /etc/xinetd.conf setf xinetd + +" XS Perl extension interface language +au BufNewFile,BufRead *.xs setf xs + +" X resources file +au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults + +" Xmath +au BufNewFile,BufRead *.msc,*.msf setf xmath +au BufNewFile,BufRead *.ms + \ if !s:FTnroff() | setf xmath | endif + +" XML specific variants: docbk and xbl +au BufNewFile,BufRead *.xml call s:FTxml() + +func! s:FTxml() + let n = 1 + while n < 100 && n < line("$") + let line = getline(n) + if line =~ '\)' && getline(n) !~ '^\s*#\s*include' + setf racc + return + endif + let n = n + 1 + endwhile + setf yacc +endfunc + + +" Yaml +au BufNewFile,BufRead *.yaml,*.yml setf yaml + +" Zope +" dtml (zope dynamic template markup language), pt (zope page template), +" cpt (zope form controller page template) +au BufNewFile,BufRead *.dtml,*.pt,*.cpt call s:FThtml() +" zsql (zope sql method) +au BufNewFile,BufRead *.zsql call s:SQL() + +" Z80 assembler asz80 +au BufNewFile,BufRead *.z8a setf z8a + +augroup END + + +" Source the user-specified filetype file, for backwards compatibility with +" Vim 5.x. +if exists("myfiletypefile") && filereadable(expand(myfiletypefile)) + execute "source " . myfiletypefile +endif + + +" Check for "*" after loading myfiletypefile, so that scripts.vim is only used +" when there are no matching file name extensions. +" Don't do this for compressed files. +augroup filetypedetect +au BufNewFile,BufRead * + \ if !did_filetype() && expand("") !~ g:ft_ignore_pat + \ | runtime! scripts.vim | endif +au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif + + +" Extra checks for when no filetype has been detected now. Mostly used for +" patterns that end in "*". E.g., "zsh*" matches "zsh.vim", but that's a Vim +" script file. +" Most of these should call s:StarSetf() to avoid names ending in .gz and the +" like are used. + +" More Apache files. +au BufNewFile,BufRead /etc/apache2/conf.*/*,/etc/apache2/sites-*/*,/etc/apache2/mods-*/* call s:StarSetf('apache') + +" Asterisk config file +au BufNewFile,BufRead *asterisk/*.conf* call s:StarSetf('asterisk') +au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm') + +" Bazaar version control +au BufNewFile,BufRead bzr_log.* setf bzr + +" BIND zone +au BufNewFile,BufRead */named/db.*,*/bind/db.* call s:StarSetf('bindzone') + +" Changelog +au BufNewFile,BufRead [cC]hange[lL]og* + \ if getline(1) =~ '; urgency=' + \| call s:StarSetf('debchangelog') + \|else + \| call s:StarSetf('changelog') + \|endif + +" Crontab +au BufNewFile,BufRead crontab,crontab.*,/etc/cron.d/* call s:StarSetf('crontab') + +" Debian Sources.list +au BufNewFile,BufRead /etc/apt/sources.list.d/* call s:StarSetf('debsources') + +" Dracula +au BufNewFile,BufRead drac.* call s:StarSetf('dracula') + +" Fvwm +au BufNewFile,BufRead */.fvwm/* call s:StarSetf('fvwm') +au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook + \ let b:fvwm_version = 1 | call s:StarSetf('fvwm') +au BufNewFile,BufRead *fvwm2rc* + \ if expand(":e") == "m4" + \| call s:StarSetf('fvwm2m4') + \|else + \| let b:fvwm_version = 2 | call s:StarSetf('fvwm') + \|endif + +" Gedcom +au BufNewFile,BufRead /tmp/lltmp* call s:StarSetf('gedcom') + +" GTK RC +au BufNewFile,BufRead .gtkrc*,gtkrc* call s:StarSetf('gtkrc') + +" Jam +au BufNewFile,BufRead Prl*.*,JAM*.* call s:StarSetf('jam') + +" Jargon +au! BufNewFile,BufRead *jarg* + \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE' + \| call s:StarSetf('jargon') + \|endif + +" Kconfig +au BufNewFile,BufRead Kconfig.* call s:StarSetf('kconfig') + +" Logcheck +au BufNewFile,BufRead /etc/logcheck/*.d*/* call s:StarSetf('logcheck') + +" Makefile +au BufNewFile,BufRead [mM]akefile* call s:StarSetf('make') + +" Ruby Makefile +au BufNewFile,BufRead [rR]akefile* call s:StarSetf('ruby') + +" Mail (also matches muttrc.vim, so this is below the other checks) +au BufNewFile,BufRead mutt[[:alnum:]._-]\{6\} setf mail + +" Modconf +au BufNewFile,BufRead /etc/modprobe.* call s:StarSetf('modconf') + +" Mutt setup file +au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc* call s:StarSetf('muttrc') +au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc* call s:StarSetf('muttrc') + +" Nroff macros +au BufNewFile,BufRead tmac.* call s:StarSetf('nroff') + +" Pam conf +au BufNewFile,BufRead /etc/pam.d/* call s:StarSetf('pamconf') + +" Printcap and Termcap +au BufNewFile,BufRead *printcap* + \ if !did_filetype() + \| let b:ptcap_type = "print" | call s:StarSetf('ptcap') + \|endif +au BufNewFile,BufRead *termcap* + \ if !did_filetype() + \| let b:ptcap_type = "term" | call s:StarSetf('ptcap') + \|endif + +" Vim script +au BufNewFile,BufRead *vimrc* call s:StarSetf('vim') + +" Subversion commit file +au BufNewFile,BufRead svn-commit*.tmp setf svn + +" X resources file +au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* call s:StarSetf('xdefaults') + +" XFree86 config +au BufNewFile,BufRead XF86Config-4* + \ let b:xf86c_xfree86_version = 4 | call s:StarSetf('xf86conf') +au BufNewFile,BufRead XF86Config* + \ if getline(1) =~ '\' + \| let b:xf86c_xfree86_version = 3 + \|endif + \|call s:StarSetf('xf86conf') + +" X11 xmodmap +au BufNewFile,BufRead *xmodmap* call s:StarSetf('xmodmap') + +" Xinetd conf +au BufNewFile,BufRead /etc/xinetd.d/* call s:StarSetf('xinetd') + +" Z-Shell script +au BufNewFile,BufRead zsh*,zlog* call s:StarSetf('zsh') + + + +" Use the filetype detect plugins. They may overrule any of the previously +" detected filetypes. +runtime! ftdetect/*.vim + + +" Generic configuration file (check this last, it's just guessing!) +au BufNewFile,BufRead,StdinReadPost * + \ if !did_filetype() && expand("") !~ g:ft_ignore_pat + \ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#' + \ || getline(4) =~ '^#' || getline(5) =~ '^#') | + \ setf conf | + \ endif + +augroup END + + +" If the GUI is already running, may still need to install the Syntax menu. +" Don't do it when the 'M' flag is included in 'guioptions'. +if has("menu") && has("gui_running") + \ && !exists("did_install_syntax_menu") && &guioptions !~# "M" + source :p:h/menu.vim +endif + +" Function called for testing all functions defined here. These are +" script-local, thus need to be executed here. +" Returns a string with error messages (hopefully empty). +func! TestFiletypeFuncs(testlist) + let output = '' + for f in a:testlist + try + exe f + catch + let output = output . "\n" . f . ": " . v:exception + endtry + endfor + return output +endfunc + +" Restore 'cpoptions' +let &cpo = s:cpo_save +unlet s:cpo_save diff -Naur vim73.orig/runtime/ftplugof.vim vim73.patched/runtime/ftplugof.vim --- vim73.orig/runtime/ftplugof.vim 2010-05-15 06:03:57.000000000 -0500 +++ vim73.patched/runtime/ftplugof.vim 2012-05-20 12:55:42.000000000 -0500 @@ -1,11 +1,13 @@ " Vim support file to switch off loading plugins for file types " " Maintainer: Bram Moolenaar -" Last Change: 2002 Apr 04 +" Last Change: 2011 Oct 20 if exists("did_load_ftplugin") unlet did_load_ftplugin endif -" Remove all autocommands in the filetypeplugin group -silent! au! filetypeplugin * +" Remove all autocommands in the filetypeplugin group, if any exist. +if exists("#filetypeplugin") + silent! au! filetypeplugin * +endif diff -Naur vim73.orig/src/GvimExt/Make_cyg.mak vim73.patched/src/GvimExt/Make_cyg.mak --- vim73.orig/src/GvimExt/Make_cyg.mak 1969-12-31 18:00:00.000000000 -0600 +++ vim73.patched/src/GvimExt/Make_cyg.mak 2012-05-20 12:55:42.000000000 -0500 @@ -0,0 +1,77 @@ +# Project: gvimext +# Generates gvimext.dll with gcc. +# To be used with Cygwin. +# +# Originally, the DLL base address was fixed: -Wl,--image-base=0x1C000000 +# Now it is allocated dymanically by the linker by evaluating all DLLs +# already loaded in memory. The binary image contains as well information +# for automatic pseudo-rebasing, if needed by the system. ALV 2004-02-29 + +# If cross-compiling set this to yes, else set it to no +CROSS = no +#CROSS = yes +# For the old MinGW 2.95 (the one you get e.g. with debian woody) +# set the following variable to yes and check if the executables are +# really named that way. +# If you have a newer MinGW or you are using cygwin set it to no and +# check also the executables +MINGWOLD = no + +# Link against the shared versions of libgcc/libstdc++ by default. Set +# STATIC_STDCPLUS to "yes" to link against static versions instead. +STATIC_STDCPLUS=no +#STATIC_STDCPLUS=yes + +# Note: -static-libstdc++ is not available until gcc 4.5.x. +LDFLAGS += -shared +ifeq (yes, $(STATIC_STDCPLUS)) +LDFLAGS += -static-libgcc -static-libstdc++ +endif + +ifeq ($(CROSS),yes) +DEL = rm +ifeq ($(MINGWOLD),yes) +CXXFLAGS := -O2 -mno-cygwin -fvtable-thunks +else +CXXFLAGS := -O2 -mno-cygwin +endif +else +CXXFLAGS := -O2 -mno-cygwin +ifneq (sh.exe, $(SHELL)) +DEL = rm +else +DEL = del +endif +endif +CXX := $(CROSS_COMPILE)g++ +WINDRES := $(CROSS_COMPILE)windres +WINDRES_CXX = $(CXX) +WINDRES_FLAGS = --preprocessor="$(WINDRES_CXX) -E -xc" -DRC_INVOKED +LIBS := -luuid +RES := gvimext.res +DEFFILE = gvimext_ming.def +OBJ := gvimext.o + +DLL := gvimext.dll + +.PHONY: all all-before all-after clean clean-custom + +all: all-before $(DLL) all-after + +$(DLL): $(OBJ) $(RES) $(DEFFILE) + $(CXX) $(LDFLAGS) $(CXXFLAGS) -s -o $@ \ + -Wl,--enable-auto-image-base \ + -Wl,--enable-auto-import \ + -Wl,--whole-archive \ + $^ \ + -Wl,--no-whole-archive \ + $(LIBS) + +gvimext.o: gvimext.cpp + $(CXX) $(CXXFLAGS) -DFEAT_GETTEXT -c $? -o $@ + +$(RES): gvimext_ming.rc + $(WINDRES) $(WINDRES_FLAGS) --input-format=rc --output-format=coff -DMING $? -o $@ + +clean: clean-custom + -$(DEL) $(OBJ) $(RES) $(DLL) diff -Naur vim73.orig/src/GvimExt/Make_ming.mak vim73.patched/src/GvimExt/Make_ming.mak --- vim73.orig/src/GvimExt/Make_ming.mak 2010-05-15 06:04:10.000000000 -0500 +++ vim73.patched/src/GvimExt/Make_ming.mak 2012-05-20 12:55:42.000000000 -0500 @@ -1,6 +1,6 @@ # Project: gvimext # Generates gvimext.dll with gcc. -# Can be used for Cygwin and MingW (MingW ignores -mno-cygwin) +# To be used with MingW. # # Originally, the DLL base address was fixed: -Wl,--image-base=0x1C000000 # Now it is allocated dymanically by the linker by evaluating all DLLs @@ -17,15 +17,26 @@ # check also the executables MINGWOLD = no +# Link against the shared versions of libgcc/libstdc++ by default. Set +# STATIC_STDCPLUS to "yes" to link against static versions instead. +STATIC_STDCPLUS=no +#STATIC_STDCPLUS=yes + +# Note: -static-libstdc++ is not available until gcc 4.5.x. +LDFLAGS += -shared +ifeq (yes, $(STATIC_STDCPLUS)) +LDFLAGS += -static-libgcc -static-libstdc++ +endif + ifeq ($(CROSS),yes) DEL = rm ifeq ($(MINGWOLD),yes) -CXXFLAGS := -O2 -mno-cygwin -fvtable-thunks +CXXFLAGS := -O2 -fvtable-thunks else -CXXFLAGS := -O2 -mno-cygwin +CXXFLAGS := -O2 endif else -CXXFLAGS := -O2 -mno-cygwin +CXXFLAGS := -O2 ifneq (sh.exe, $(SHELL)) DEL = rm else @@ -34,6 +45,8 @@ endif CXX := $(CROSS_COMPILE)g++ WINDRES := $(CROSS_COMPILE)windres +WINDRES_CXX = $(CXX) +WINDRES_FLAGS = --preprocessor="$(WINDRES_CXX) -E -xc" -DRC_INVOKED LIBS := -luuid RES := gvimext.res DEFFILE = gvimext_ming.def @@ -46,7 +59,7 @@ all: all-before $(DLL) all-after $(DLL): $(OBJ) $(RES) $(DEFFILE) - $(CXX) -shared $(CXXFLAGS) -s -o $@ \ + $(CXX) $(LDFLAGS) $(CXXFLAGS) -s -o $@ \ -Wl,--enable-auto-image-base \ -Wl,--enable-auto-import \ -Wl,--whole-archive \ @@ -58,8 +71,7 @@ $(CXX) $(CXXFLAGS) -DFEAT_GETTEXT -c $? -o $@ $(RES): gvimext_ming.rc - $(WINDRES) --input-format=rc --output-format=coff -DMING $? -o $@ + $(WINDRES) $(WINDRES_FLAGS) --input-format=rc --output-format=coff -DMING $? -o $@ clean: clean-custom -$(DEL) $(OBJ) $(RES) $(DLL) - diff -Naur vim73.orig/src/GvimExt/gvimext.cpp vim73.patched/src/GvimExt/gvimext.cpp --- vim73.orig/src/GvimExt/gvimext.cpp 2010-07-10 12:21:34.000000000 -0500 +++ vim73.patched/src/GvimExt/gvimext.cpp 2012-05-20 12:55:42.000000000 -0500 @@ -142,6 +142,7 @@ static int dyn_libintl_init(char *dir); static void dyn_libintl_end(void); +static wchar_t *oldenv = NULL; static HINSTANCE hLibintlDLL = 0; static char *(*dyn_libintl_gettext)(const char *) = null_libintl_gettext; static char *(*dyn_libintl_textdomain)(const char *) = null_libintl_textdomain; @@ -339,8 +340,10 @@ inc_cRefThisDLL() { #ifdef FEAT_GETTEXT - if (g_cRefThisDll == 0) + if (g_cRefThisDll == 0) { dyn_gettext_load(); + oldenv = GetEnvironmentStringsW(); + } #endif InterlockedIncrement((LPLONG)&g_cRefThisDll); } @@ -349,8 +352,13 @@ dec_cRefThisDLL() { #ifdef FEAT_GETTEXT - if (InterlockedDecrement((LPLONG)&g_cRefThisDll) == 0) + if (InterlockedDecrement((LPLONG)&g_cRefThisDll) == 0) { dyn_gettext_free(); + if (oldenv != NULL) { + FreeEnvironmentStringsW(oldenv); + oldenv = NULL; + } + } #else InterlockedDecrement((LPLONG)&g_cRefThisDll); #endif @@ -586,8 +594,23 @@ // Initialize m_cntOfHWnd to 0 m_cntOfHWnd = 0; - // Retrieve all the vim instances - EnumWindows(EnumWindowsProc, (LPARAM)this); + + HKEY keyhandle; + bool showExisting = true; + + // Check whether "Edit with existing Vim" entries are disabled. + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", 0, + KEY_READ, &keyhandle) == ERROR_SUCCESS) + { + if (RegQueryValueEx(keyhandle, "DisableEditWithExisting", 0, NULL, + NULL, NULL) == ERROR_SUCCESS) + showExisting = false; + RegCloseKey(keyhandle); + } + + // Retrieve all the vim instances, unless disabled. + if (showExisting) + EnumWindows(EnumWindowsProc, (LPARAM)this); if (cbFiles > 1) { @@ -890,8 +913,8 @@ NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. FALSE, // Set handle inheritance to FALSE. - 0, // No creation flags. - NULL, // Use parent's environment block. + oldenv == NULL ? 0 : CREATE_UNICODE_ENVIRONMENT, + oldenv, // Use unmodified environment block. NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi) // Pointer to PROCESS_INFORMATION structure. @@ -972,8 +995,8 @@ NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. FALSE, // Set handle inheritance to FALSE. - 0, // No creation flags. - NULL, // Use parent's environment block. + oldenv == NULL ? 0 : CREATE_UNICODE_ENVIRONMENT, + oldenv, // Use unmodified environment block. NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi) // Pointer to PROCESS_INFORMATION structure. diff -Naur vim73.orig/src/GvimExt/gvimext.def vim73.patched/src/GvimExt/gvimext.def --- vim73.orig/src/GvimExt/gvimext.def 2010-05-15 06:04:10.000000000 -0500 +++ vim73.patched/src/GvimExt/gvimext.def 2012-05-20 12:55:42.000000000 -0500 @@ -1,7 +1,7 @@ ;gvimdef.def : Declares the module parameters for the DLL. LIBRARY gvimext -DESCRIPTION 'Vim Shell Extension' +; DESCRIPTION 'Vim Shell Extension' EXPORTS DllCanUnloadNow private diff -Naur vim73.orig/src/GvimExt/gvimext_ming.def vim73.patched/src/GvimExt/gvimext_ming.def --- vim73.orig/src/GvimExt/gvimext_ming.def 2010-05-15 06:04:10.000000000 -0500 +++ vim73.patched/src/GvimExt/gvimext_ming.def 2012-05-20 12:55:42.000000000 -0500 @@ -3,7 +3,7 @@ ;Hence this is the same file as gvimext.def with private removed LIBRARY gvimext -DESCRIPTION 'Vim Shell Extension build with MinGW' +; DESCRIPTION 'Vim Shell Extension build with MinGW' EXPORTS DllCanUnloadNow = DllCanUnloadNow@0 diff -Naur vim73.orig/src/INSTALL vim73.patched/src/INSTALL --- vim73.orig/src/INSTALL 2010-06-25 23:04:51.000000000 -0500 +++ vim73.patched/src/INSTALL 2012-05-20 12:55:41.000000000 -0500 @@ -6,9 +6,8 @@ Contents: 1. Generic 2. Unix -3. RISC OS -4. OS/2 (with EMX 0.9b) -5. Atari MiNT +3. OS/2 (with EMX 0.9b) +4. Atari MiNT See INSTALLami.txt for Amiga See INSTALLmac.txt for Macintosh @@ -174,25 +173,7 @@ ./configure --without-local-dir -3. RISC OS -============= - -Much file renaming is needed before you can compile anything. -You'll need UnixLib to link against, GCC and GNU make. - -I suggest you get the RISC OS binary distribution, which includes the -Templates file and the loader. - -Try here: http://www.ecs.soton.ac.uk/~tal197 - -Do - :help riscos - -within the editor for more information, or read the -../runtime/doc/os_risc.txt help file. - - -4. OS/2 +3. OS/2 ======= Summary: @@ -237,7 +218,7 @@ Check ../runtime/doc/os_os2.txt for additional info on running Vim. -5. Atari MiNT +4. Atari MiNT ============= [NOTE: this is quite old, it might not work anymore] diff -Naur vim73.orig/src/INSTALLpc.txt vim73.patched/src/INSTALLpc.txt --- vim73.orig/src/INSTALLpc.txt 2010-05-24 07:58:06.000000000 -0500 +++ vim73.patched/src/INSTALLpc.txt 2012-05-20 12:55:43.000000000 -0500 @@ -11,9 +11,9 @@ this, then you will get the default behavior as is documented, which should be fine for most people. -With the exception of the last two sections (Windows 3.1 and MS-DOS), -this document assumes that you are building Vim for Win32 -(Windows NT/2000/XP/2003/Vista and Windows 95/98/Me) +With the exception of two sections (Windows 3.1 and MS-DOS), this document +assumes that you are building Vim for Win32 or later. +(Windows 95/98/Me/NT/2000/XP/2003/Vista/7) Contents: @@ -27,9 +27,13 @@ 8. Windows 3.1 9. MS-DOS +10. Installing after building from sources + + The currently preferred method is using the free Visual C++ Toolkit 2008 -|msvc-2008-express|. If you need the executable to run on Windows 98 or ME, -use the 2003 one |msvc-2003-toolkit|. +|msvc-2008-express|, the produced binary runs on most MS-Windows systems. If +you need the executable to run on Windows 98 or ME, use the 2003 one +|msvc-2003-toolkit|. 1. Microsoft Visual C++ @@ -176,7 +180,7 @@ http://www.microsoft.com/express/vc/Default.aspx This includes the IDE and the debugger. -To set the environment execute the msvc2008.bat script. You can then build +To set the environment execute the msvc2010.bat script. You can then build Vim with Make_mvc.mak. @@ -235,6 +239,12 @@ found at http://www.upx.org/ +As of 2011, UPX still does not support compressing 64-bit EXE's; if you have +built a 64-bit vim then an alternative to UPX is 'MPRESS'. MPRESS can be found +at: + http://www.matcode.com/mpress.htm + + ADDITION: NLS support with MinGW (by Eduardo F. Amatria ) @@ -408,3 +418,59 @@ If you get all kinds of strange error messages when compiling, try adding changing the file format from "unix" to "dos". + + +10. Installing after building from sources +========================================== + +[provided by Michael Soyka] + +After you've built the Vim binaries as described above, you're ready to +install Vim on your system. However, if you've obtained the Vim sources +using Mercurial or by downloading them as a unix tar file, you must first +create a "vim73" directory. If you instead downloaded the sources as +zip files, you can skip this setup as the zip archives already have the +correct directory structure. + + A. Create a Vim "runtime" subdirectory named "vim73" + ----------------------------------------------------- + If you obtained your Vim sources as zip files, you can skip this step. + Otherwise, continue reading. + + Go to the directory that contains the Vim "src" and "runtime" + directories and create a new subdirectory named "vim73". + + Copy the "runtime" files into "vim73": + copy runtime\* vim73 + + B. Copy the new binaries into the "vim73" directory + ---------------------------------------------------- + Regardless of how you installed the Vim sources, you need to copy the + new binaries you created above into "vim73": + + copy src\*.exe vim73 + copy src\GvimExt\gvimext.dll vim73 + copy src\xxd\xxd.exe vim73 + + C. Move the "vim73" directory into the Vim installation subdirectory + --------------------------------------------------------------------- + Move the "vim73" subdirectory into the subdirectory where you want Vim + to be installed. Typically, this subdirectory will be named "vim". + If you already have a "vim73" subdirectory in "vim", delete it first + by running its unstal.exe program. + + D. Install Vim + --------------- + "cd" to your Vim installation subdirectory "vim\vim73" and run the + "install.exe" program. It will ask you a number of questions about + how you would like to have your Vim setup. Among these are: + - You can tell it to write a "_vimrc" file with your preferences in the + parent directory. + - It can also install an "Edit with Vim" entry in the Windows Explorer + popup menu. + - You can have it create batch files, so that you can run Vim from the + console or in a shell. You can select one of the directories in your + PATH or add the directory to PATH using the Windows Control Panel. + - Create entries for Vim on the desktop and in the Start menu. + +Happy Vimming! diff -Naur vim73.orig/src/Make_cyg.mak vim73.patched/src/Make_cyg.mak --- vim73.orig/src/Make_cyg.mak 2010-08-02 14:09:22.000000000 -0500 +++ vim73.patched/src/Make_cyg.mak 2012-05-20 12:55:42.000000000 -0500 @@ -1,6 +1,6 @@ # # Makefile for VIM on Win32, using Cygnus gcc -# Last updated by Dan Sharp. Last Change: 2010 Feb 24 +# Last updated by Dan Sharp. Last Change: 2010 Nov 03 # # Also read INSTALLpc.txt! # @@ -27,6 +27,7 @@ # MZSCHEME_VER define to version of MzScheme being used (209_000) # DYNAMIC_MZSCHEME no or yes: use yes to load the MzScheme DLLs dynamically (yes) # MZSCHEME_DLLS path to MzScheme DLLs (libmzgc and libmzsch), for "static" build. +# MZSCHEME_USE_RACKET define to use "racket" instead of "mzsch". # LUA define to path to Lua dir to get Lua support (not defined) # LUA_VER define to version of Lua being used (51) # DYNAMIC_LUA no or yes: use yes to load the Lua DLL dynamically (yes) @@ -254,16 +255,22 @@ MZSCHEME_GENERATE_BASE=no endif +ifndef MZSCHEME_USE_RACKET +MZSCHEME_MAIN_LIB=mzsch +else +MZSCHEME_MAIN_LIB=racket +endif + ifeq (yes, $(DYNAMIC_MZSCHEME)) -DEFINES += -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"libmzsch$(MZSCHEME_VER).dll\" -DDYNAMIC_MZGC_DLL=\"libmzgc$(MZSCHEME_VER).dll\" +DEFINES += -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).dll\" -DDYNAMIC_MZGC_DLL=\"libmzgc$(MZSCHEME_VER).dll\" else ifndef MZSCHEME_DLLS MZSCHEME_DLLS = $(MZSCHEME) endif ifeq (yes,$(MZSCHEME_PRECISE_GC)) -MZSCHEME_LIB=-lmzsch$(MZSCHEME_VER) +MZSCHEME_LIB=-l$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER) else -MZSCHEME_LIB = -lmzsch$(MZSCHEME_VER) -lmzgc$(MZSCHEME_VER) +MZSCHEME_LIB = -l$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER) -lmzgc$(MZSCHEME_VER) endif EXTRA_LIBS += -L$(MZSCHEME_DLLS) -L$(MZSCHEME_DLLS)/lib $(MZSCHEME_LIB) endif @@ -529,7 +536,7 @@ $(MAKE) -C xxd -f Make_cyg.mak CC=$(CC) USEDLL=$(USEDLL) GvimExt/gvimext.dll: GvimExt/gvimext.cpp GvimExt/gvimext.rc GvimExt/gvimext.h - $(MAKE) -C GvimExt -f Make_ming.mak CROSS_COMPILE=$(CROSS_COMPILE) + $(MAKE) -C GvimExt -f Make_cyg.mak CROSS_COMPILE=$(CROSS_COMPILE) vimrun.exe: vimrun.c $(CC) $(CFLAGS) -o vimrun.exe vimrun.c $(LIBS) @@ -558,7 +565,7 @@ endif -$(DEL) pathdef.c $(MAKE) -C xxd -f Make_cyg.mak clean - $(MAKE) -C GvimExt -f Make_ming.mak clean + $(MAKE) -C GvimExt -f Make_cyg.mak clean distclean: clean -$(DEL) obj$(DIRSLASH)*.o diff -Naur vim73.orig/src/Make_ming.mak vim73.patched/src/Make_ming.mak --- vim73.orig/src/Make_ming.mak 2010-08-02 14:09:43.000000000 -0500 +++ vim73.patched/src/Make_ming.mak 2012-05-20 12:55:43.000000000 -0500 @@ -14,9 +14,11 @@ # it's just run out of memory or something. Run again, and it will continue # with 'xxd'. # -# "make upx" makes *compressed* versions of the GUI and console EXEs, using the -# excellent UPX compressor: +# "make upx" makes *compressed* versions of the 32 bit GUI and console EXEs, +# using the excellent UPX compressor: # http://upx.sourceforge.net/ +# "make mpress" uses the MPRESS compressor for 32- and 64-bit EXEs: +# http://www.matcode.com/mpress.htm # # Maintained by Ron Aaron # updated 2003 Jan 20 @@ -49,13 +51,21 @@ # set to yes to enable OLE support OLE=no # Set the default $(WINVER) to make it work with pre-Win2k +ifndef WINVER WINVER = 0x0400 +endif # Set to yes to enable Cscope support CSCOPE=yes # Set to yes to enable Netbeans support NETBEANS=$(GUI) +# Link against the shared version of libstdc++ by default. Set +# STATIC_STDCPLUS to "yes" to link against static version instead. +ifndef STATIC_STDCPLUS +STATIC_STDCPLUS=no +endif + # If the user doesn't want gettext, undefine it. ifeq (no, $(GETTEXT)) GETTEXT= @@ -81,7 +91,7 @@ # If you are using gettext-0.10.35 from http://sourceforge.net/projects/gettext # or gettext-0.10.37 from http://sourceforge.net/projects/mingwrep/ -# uncomment the following, but I can't build a static versión with them, ?-(| +# uncomment the following, but I can't build a static version with them, ?-(| #GETTEXT=c:/gettext-0.10.37-20010430 #STATIC_GETTEXT=USE_STATIC_GETTEXT #DYNAMIC_GETTEXT=DYNAMIC_GETTEXT @@ -102,6 +112,13 @@ # on NT, it's here: PERLLIB=$(PERL)/lib PERLLIBS=$(PERLLIB)/Core +XSUBPPTRY=$(PERLLIB)/ExtUtils/xsubpp +XSUBPP_EXISTS=$(shell perl -e "print 1 unless -e '$(XSUBPPTRY)'") +ifeq "$(XSUBPP_EXISTS)" "" +XSUBPP=perl $(XSUBPPTRY) +else +XSUBPP=xsubpp +endif endif # uncomment 'LUA' if you want a Lua-enabled version @@ -141,11 +158,17 @@ MZSCHEME_GENERATE_BASE=no endif +ifndef MZSCHEME_USE_RACKET +MZSCHEME_MAIN_LIB=mzsch +else +MZSCHEME_MAIN_LIB=racket +endif + ifeq (no,$(DYNAMIC_MZSCHEME)) ifeq (yes,$(MZSCHEME_PRECISE_GC)) -MZSCHEME_LIB=-lmzsch$(MZSCHEME_VER) +MZSCHEME_LIB=-l$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER) else -MZSCHEME_LIB = -lmzsch$(MZSCHEME_VER) -lmzgc$(MZSCHEME_VER) +MZSCHEME_LIB = -l$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER) -lmzgc$(MZSCHEME_VER) endif # the modern MinGW can dynamically link to dlls directly. # point MZSCHEME_DLLS to where you put libmzschXXXXXXX.dll and libgcXXXXXXX.dll @@ -304,11 +327,13 @@ endif CC := $(CROSS_COMPILE)gcc WINDRES := $(CROSS_COMPILE)windres +WINDRES_CC = $(CC) #>>>>> end of choices ########################################################################### CFLAGS = -Iproto $(DEFINES) -pipe -w -march=$(ARCH) -Wall +WINDRES_FLAGS = --preprocessor="$(WINDRES_CC) -E -xc" -DRC_INVOKED ifdef GETTEXT DEFINES += -DHAVE_GETTEXT -DHAVE_LOCALE_H @@ -343,7 +368,7 @@ ifdef MZSCHEME CFLAGS += -I$(MZSCHEME)/include -DFEAT_MZSCHEME -DMZSCHEME_COLLECTS=\"$(MZSCHEME)/collects\" ifeq (yes, $(DYNAMIC_MZSCHEME)) -CFLAGS += -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"libmzsch$(MZSCHEME_VER).dll\" -DDYNAMIC_MZGC_DLL=\"libmzgc$(MZSCHEME_VER).dll\" +CFLAGS += -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).dll\" -DDYNAMIC_MZGC_DLL=\"libmzgc$(MZSCHEME_VER).dll\" endif endif @@ -571,8 +596,13 @@ endif ifeq (yes, $(OLE)) -LIB += -loleaut32 -lstdc++ +LIB += -loleaut32 OBJ += $(OUTDIR)/if_ole.o +ifeq (yes, $(STATIC_STDCPLUS)) +LIB += -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic +else +LIB += -lstdc++ +endif endif ifeq (yes, $(MBYTE)) @@ -614,8 +644,12 @@ upx gvim.exe upx vim.exe +mpress: exes + mpress gvim.exe + mpress vim.exe + xxd/xxd.exe: xxd/xxd.c - $(MAKE) -C xxd -f Make_cyg.mak CC=$(CC) + $(MAKE) -C xxd -f Make_ming.mak CC=$(CC) GvimExt/gvimext.dll: GvimExt/gvimext.cpp GvimExt/gvimext.rc GvimExt/gvimext.h $(MAKE) -C GvimExt -f Make_ming.mak CROSS=$(CROSS) CROSS_COMPILE=$(CROSS_COMPILE) @@ -633,7 +667,7 @@ -$(DEL) mzscheme_base.c endif $(MAKE) -C GvimExt -f Make_ming.mak clean - $(MAKE) -C xxd -f Make_cyg.mak clean + $(MAKE) -C xxd -f Make_ming.mak clean ########################################################################### INCL = vim.h feature.h os_win32.h os_dos.h ascii.h keymap.h term.h macros.h \ @@ -649,11 +683,9 @@ $(OUTDIR)/%.o : %.c $(INCL) $(CC) -c $(CFLAGS) $< -o $@ -$(OUTDIR)/vimres.res: vim.rc version.h gui_w32_rc.h - $(WINDRES) $(DEFINES) vim.rc $(OUTDIR)/vimres.res - -$(OUTDIR)/vimrc.o: $(OUTDIR)/vimres.res - $(WINDRES) $(OUTDIR)/vimres.res $(OUTDIR)/vimrc.o +$(OUTDIR)/vimrc.o: vim.rc version.h gui_w32_rc.h + $(WINDRES) $(WINDRES_FLAGS) $(DEFINES) \ + --input-format=rc --output-format=coff -i vim.rc -o $@ $(OUTDIR): $(MKDIR) $(OUTDIR) @@ -677,7 +709,7 @@ endif if_perl.c: if_perl.xs typemap - perl $(PERLLIB)/ExtUtils/xsubpp -prototypes -typemap \ + $(XSUBPP) -prototypes -typemap \ $(PERLLIB)/ExtUtils/typemap if_perl.xs > $@ $(OUTDIR)/netbeans.o: netbeans.c $(INCL) $(NBDEBUG_INCL) $(NBDEBUG_SRC) diff -Naur vim73.orig/src/Make_mvc.mak vim73.patched/src/Make_mvc.mak --- vim73.orig/src/Make_mvc.mak 2010-07-18 14:24:20.000000000 -0500 +++ vim73.patched/src/Make_mvc.mak 2012-05-20 12:55:43.000000000 -0500 @@ -380,9 +380,6 @@ !if "$(_NMAKE_VER)" == "10.00.30319.01" MSVCVER = 10.0 !endif -!if "$(_NMAKE_VER)" == "9.00.30729.01" -MSVCVER = 9.0 -!endif !endif # Abort bulding VIM if version of VC is unrecognised. @@ -412,8 +409,8 @@ CPUARG = !endif !else -# VC8/9 only allows specifying SSE architecture -!if "$(CPUNR)" == "pentium4" +# VC8/9/10 only allows specifying SSE architecture but only for 32bit +!if "$(ASSEMBLY_ARCHITECTURE)" == "x86" && "$(CPUNR)" == "pentium4" CPUARG = /arch:SSE2 !endif !endif @@ -619,7 +616,7 @@ -DDYNAMIC_TCL_VER=\"$(TCL_VER_LONG)\" TCL_OBJ = $(OUTDIR)\if_tcl.obj TCL_INC = /I "$(TCL)\Include" /I "$(TCL)" -TCL_LIB = $(TCL)\lib\tclstub$(TCL_VER).lib +TCL_LIB = "$(TCL)\lib\tclstub$(TCL_VER).lib" !else CFLAGS = $(CFLAGS) -DFEAT_TCL TCL_OBJ = $(OUTDIR)\if_tcl.obj @@ -705,12 +702,18 @@ MZSCHEME_VER = 205_000 !endif CFLAGS = $(CFLAGS) -DFEAT_MZSCHEME -I $(MZSCHEME)\include -!if EXIST("$(MZSCHEME)\collects\scheme\base.ss") -# for MzScheme 4.x we need to include byte code for basic Scheme stuff +!if EXIST("$(MZSCHEME)\collects\scheme\base.ss") \ + || EXIST("$(MZSCHEME)\collects\scheme\base.rkt") +# for MzScheme >= 4 we need to include byte code for basic Scheme stuff MZSCHEME_EXTRA_DEP = mzscheme_base.c CFLAGS = $(CFLAGS) -DINCLUDE_MZSCHEME_BASE !endif -!if EXIST("$(MZSCHEME)\lib\msvc\libmzsch$(MZSCHEME_VER).lib") \ +!if EXIST("$(MZSCHEME)\lib\msvc\libmzsch$(MZSCHEME_VER).lib") +MZSCHEME_MAIN_LIB=mzsch +!else +MZSCHEME_MAIN_LIB=racket +!endif +!if EXIST("$(MZSCHEME)\lib\msvc\lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).lib") \ && !EXIST("$(MZSCHEME)\lib\msvc\libmzgc$(MZSCHEME_VER).lib") !message Building with Precise GC MZSCHEME_PRECISE_GC = yes @@ -722,7 +725,7 @@ !endif !message MzScheme DLLs will be loaded dynamically CFLAGS = $(CFLAGS) -DDYNAMIC_MZSCHEME \ - -DDYNAMIC_MZSCH_DLL=\"libmzsch$(MZSCHEME_VER).dll\" \ + -DDYNAMIC_MZSCH_DLL=\"lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).dll\" \ -DDYNAMIC_MZGC_DLL=\"libmzgc$(MZSCHEME_VER).dll\" !else !if "$(MZSCHEME_DEBUG)" == "yes" @@ -730,13 +733,15 @@ !endif !if "$(MZSCHEME_PRECISE_GC)" == "yes" # Precise GC does not use separate dll -MZSCHEME_LIB = $(MZSCHEME)\lib\msvc\libmzsch$(MZSCHEME_VER).lib +MZSCHEME_LIB = $(MZSCHEME)\lib\msvc\lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).lib !else MZSCHEME_LIB = $(MZSCHEME)\lib\msvc\libmzgc$(MZSCHEME_VER).lib \ - $(MZSCHEME)\lib\msvc\libmzsch$(MZSCHEME_VER).lib + $(MZSCHEME)\lib\msvc\lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).lib !endif !endif MZSCHEME_OBJ = $(OUTDIR)\if_mzsch.obj +# increase stack size +MZSCHEME_LIB = $(MZSCHEME_LIB) /STACK:8388608 !endif # Perl interface @@ -782,6 +787,11 @@ PERL_INC = /I $(PERL_INCDIR) PERL_OBJ = $(OUTDIR)\if_perl.obj $(OUTDIR)\if_perlsfio.obj XSUBPP = $(PERL)\lib\ExtUtils\xsubpp +!if exist($(XSUBPP)) +XSUBPP = $(PERL_EXE) $(XSUBPP) +!else +XSUBPP = xsubpp +!endif XSUBPP_TYPEMAP = $(PERL)\lib\ExtUtils\typemap !endif @@ -1038,7 +1048,7 @@ $(CC) $(CFLAGS) $(LUA_INC) if_lua.c if_perl.c : if_perl.xs typemap - $(PERL_EXE) $(XSUBPP) -prototypes -typemap $(XSUBPP_TYPEMAP) \ + $(XSUBPP) -prototypes -typemap $(XSUBPP_TYPEMAP) \ -typemap typemap if_perl.xs > if_perl.c $(OUTDIR)/if_perl.obj: $(OUTDIR) if_perl.c $(INCL) @@ -1156,6 +1166,10 @@ E0_CFLAGS = $(CFLAGS:\=\\) E_CFLAGS = $(E0_CFLAGS:"=\") # ") stop the string +# $LINKARGS2 may contain backslashes and double quotes, escape them both. +E0_LINKARGS2 = $(LINKARGS2:\=\\) +E_LINKARGS2 = $(E0_LINKARGS2:"=\") +# ") stop the string $(PATHDEF_SRC): auto @echo creating $(PATHDEF_SRC) @@ -1164,7 +1178,7 @@ @echo char_u *default_vim_dir = (char_u *)"$(VIMRCLOC:\=\\)"; >> $(PATHDEF_SRC) @echo char_u *default_vimruntime_dir = (char_u *)"$(VIMRUNTIMEDIR:\=\\)"; >> $(PATHDEF_SRC) @echo char_u *all_cflags = (char_u *)"$(CC:\=\\) $(E_CFLAGS)"; >> $(PATHDEF_SRC) - @echo char_u *all_lflags = (char_u *)"$(link:\=\\) $(LINKARGS1:\=\\) $(LINKARGS2:\=\\)"; >> $(PATHDEF_SRC) + @echo char_u *all_lflags = (char_u *)"$(link:\=\\) $(LINKARGS1:\=\\) $(E_LINKARGS2)"; >> $(PATHDEF_SRC) @echo char_u *compiled_user = (char_u *)"$(USERNAME)"; >> $(PATHDEF_SRC) @echo char_u *compiled_sys = (char_u *)"$(USERDOMAIN)"; >> $(PATHDEF_SRC) diff -Naur vim73.orig/src/Make_ro.mak vim73.patched/src/Make_ro.mak --- vim73.orig/src/Make_ro.mak 2010-05-15 06:04:08.000000000 -0500 +++ vim73.patched/src/Make_ro.mak 1969-12-31 18:00:00.000000000 -0600 @@ -1,135 +0,0 @@ -# -# Makefile for Vim on RISC OS - Andy Wingate -# - -GCC = gcc -mthrowback -CFLAGS = -DRISCOS -DFEAT_GUI -CC = $(GCC) $(CFLAGS) -O2 -# -DUP_BC_PC_EXTERN for term.c needed as BC defined in termlib.c and term.c - -TERMFLAG = -DUP_BC_PC_EXTERN - -ASMFLAGS = -throwback -objasm -gcc - -OBJS = o.buffer o.charset o.diff o.digraph o.edit o.eval o.ex_cmds o.ex_cmds2 \ - o.ex_docmd o.ex_eval o.ex_getln o.fileio o.fold o.getchar \ - o.hardcopy o.hashtab o.main o.mark o.mbyte \ - o.memfile o.memline o.menu o.message o.misc1 o.misc2 o.move \ - o.normal o.ops o.option o.popupmnu o.quickfix o.regexp o.screen \ - o.search \ - o.spell o.syntax o.tag o.term o.termlib o.ui o.undo o.version \ - o.window o.os_riscos o.swis o.gui o.gui_riscos - -Vim: $(OBJS) - $(GCC) -o Vim $(OBJS) - -install: Vim - squeeze -v Vim @.!Vim.Vim - -clean: - create o.!fake! 0 - wipe o.* ~cf - remove Vim - -o.swis: s.swis - as $(ASMFLAGS) -o o.swis s.swis - -# Rules for object files - -o.%: c.% - $(CC) -c $< -o $@ - -o.buffer: c.buffer - -o.charset: c.charset - -o.digraph: c.digraph - -o.diff: c.diff - -o.edit: c.edit - -o.eval: c.eval - -o.ex_cmds: c.ex_cmds - -o.ex_cmds2: c.ex_cmds2 - -o.ex_docmd: c.ex_docmd - -o.ex_eval: c.ex_eval - -o.ex_getln: c.ex_getln - -o.fileio: c.fileio - -o.fold: c.fold - -o.getchar: c.getchar - -o.hardcopy: c.hardcopy - -o.hashtab: c.hashtab - -o.gui: c.gui - -o.gui_riscos: c.gui_riscos - -o.main: c.main - -o.mark: c.mark - -o.mbyte: c.mbyte - -o.memfile: c.memfile - -o.memline: c.memline - -o.menu: c.menu - -o.message: c.message - -o.misc1: c.misc1 - -o.misc2: c.misc2 - -o.move: c.move - -o.normal: c.normal - -o.ops: c.ops - -o.option: c.option - -o.os_riscos: c.os_riscos - -o.pty: c.pty - -o.popupmnu: c.popupmnu - -o.quickfix: c.quickfix - -o.regexp: c.regexp - -o.screen: c.screen - -o.search: c.search - -o.spell: c.spell - -o.syntax: c.syntax - -o.tag: c.tag - -o.term: c.term - $(CC) $(TERMFLAG) -c c.term -o o.term - -o.termlib: c.termlib - -o.ui: c.ui - -o.undo: c.undo - -o.version: c.version - -o.window: c.window diff -Naur vim73.orig/src/Makefile vim73.patched/src/Makefile --- vim73.orig/src/Makefile 2010-08-15 07:56:15.000000000 -0500 +++ vim73.patched/src/Makefile 2012-05-20 12:55:43.000000000 -0500 @@ -29,7 +29,7 @@ # - Uncomment the line "CONF_OPT_X = --without-x" if you have X11 but # want to disable using X11 libraries. This speeds up starting Vim, # but the window title will not be set and the X11 selection can not -# used. +# be used. # - Uncomment the line "CONF_OPT_XSMP = --disable-xsmp" if you have the # X11 Session Management Protocol (XSMP) library (libSM) but do not # want to use it. @@ -283,12 +283,13 @@ ######################## auto/config.mk ######################## {{{1 # At this position auto/config.mk is included. When starting from the -# distribution it is almost empty. After running auto/configure it contains -# settings that have been discovered for your system. Settings below this -# include override settings in auto/config.mk! - -# Note: if auto/config.mk is lost somehow (e.g., because configure was -# interrupted), create an empty auto/config.mk file and do "make config". +# toplevel Makefile it is almost empty. After running auto/configure it +# contains settings that have been discovered for your system. Settings below +# this include override settings in auto/config.mk! + +# Note: If make fails because auto/config.mk does not exist (it is not +# included in the repository), do: +# cp config.mk.dist auto/config.mk # (X) How to include auto/config.mk depends on the version of "make" you have, # if the current choice doesn't work, try the other one. @@ -388,6 +389,11 @@ #CONF_OPT_PLTHOME = --with-plthome=/usr/local/drscheme #CONF_OPT_PLTHOME = --with-plthome=/home/me/mz +# Uncomment the next line to fail if one of the requested language interfaces +# cannot be configured. Without this Vim will be build anyway, without +# the failing interfaces. +#CONF_OPT_FAIL = --enable-fail-if-missing + # PERL # Uncomment one of these when you want to include the Perl interface. # First one is for static linking, second one for dynamic loading. @@ -414,12 +420,16 @@ # However, this may still cause problems, such as "import termios" failing. # Build two separate versions of Vim in that case. #CONF_OPT_PYTHON = --enable-pythoninterp +#CONF_OPT_PYTHON = --enable-pythoninterp=dynamic #CONF_OPT_PYTHON3 = --enable-python3interp +#CONF_OPT_PYTHON3 = --enable-python3interp=dynamic # RUBY # Uncomment this when you want to include the Ruby interface. +# First one for static linking, second one for loading when used. # Note: you need the development package (e.g., ruby1.9.1-dev on Ubuntu). #CONF_OPT_RUBY = --enable-rubyinterp +#CONF_OPT_RUBY = --enable-rubyinterp=dynamic #CONF_OPT_RUBY = --enable-rubyinterp --with-ruby-command=ruby1.9.1 # TCL @@ -556,8 +566,8 @@ #CFLAGS = -g -O2 '-DSTARTUPTIME="vimstartup"' -fno-strength-reduce -Wall -Wmissing-prototypes # Use this with GCC to check for mistakes, unused arguments, etc. -#CFLAGS = -g -Wall -Wextra -Wmissing-prototypes -Wunreachable-code -D_FORTIFY_SOURCE=1 -DU_DEBUG -#CFLAGS = -g -O2 -Wall -Wextra -Wmissing-prototypes -D_FORTIFY_SOURCE=1 -DU_DEBUG +#CFLAGS = -g -Wall -Wextra -Wmissing-prototypes -Wunreachable-code -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 +#CFLAGS = -g -O2 -Wall -Wextra -Wmissing-prototypes -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DU_DEBUG #PYTHON_CFLAGS_EXTRA = -Wno-missing-field-initializers #MZSCHEME_CFLAGS_EXTRA = -Wno-unreachable-code -Wno-unused-parameter @@ -589,8 +599,9 @@ # PROFILING - Uncomment the next two lines to do profiling with gcc and gprof. # Might not work with GUI or Perl. -# For unknown reasons adding "-lc" fixes a linking problem with GCC. That's -# probably a bug in the "-pg" implementation. +# For unknown reasons adding "-lc" fixes a linking problem with some versions +# of GCC. That's probably a bug in the "-pg" implementation. +# After running Vim see the profile result with: gmon vim gmon.out | vim - # Need to recompile everything after changing this: "make clean" "make". #PROFILE_CFLAGS = -pg -g -DWE_ARE_PROFILING #PROFILE_LIBS = -pg @@ -601,8 +612,8 @@ # Configuration is in the .ccmalloc or ~/.ccmalloc file. # Doesn't work very well, since memory linked to from global variables # (in libraries) is also marked as leaked memory. -#PROFILE_CFLAGS = -DEXITFREE -#PROFILE_LIBS = -lccmalloc +#LEAK_CFLAGS = -DEXITFREE +#LEAK_LIBS = -lccmalloc ##################################################### ### Specific systems, check if yours is listed! ### {{{ @@ -724,12 +735,6 @@ ### USL for Unix Systems Laboratories (SYSV 4.2) #EXTRA_DEFS = -DUSL -### RISCos on MIPS without X11 -#EXTRA_DEFS = -DMIPS - -### RISCos on MIPS with X11 -#EXTRA_LIBS = -lsun - ### (6) A/UX 3.1.1 with gcc (Jim Jagielski) #CC= gcc -D_POSIX_SOURCE #CFLAGS= -O2 @@ -1047,8 +1052,9 @@ INSTALL_DATA = cp INSTALL_DATA_R = cp -r -### Program to run on installed binary +### Program to run on installed binary. Use the second one to disable strip. #STRIP = strip +#STRIP = /bin/true ### Permissions for binaries {{{1 BINMOD = 755 @@ -1321,15 +1327,15 @@ .SUFFIXES: .c .o .pro PRE_DEFS = -Iproto $(DEFS) $(GUI_DEFS) $(GUI_IPATH) $(CPPFLAGS) $(EXTRA_IPATHS) -POST_DEFS = $(X_CFLAGS) $(MZSCHEME_CFLAGS) $(TCL_CFLAGS) $(RUBY_CFLAGS) $(EXTRA_DEFS) +POST_DEFS = $(X_CFLAGS) $(MZSCHEME_CFLAGS) $(TCL_CFLAGS) $(EXTRA_DEFS) -ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(POST_DEFS) +ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(LEAK_CFLAGS) $(POST_DEFS) # Exclude $CFLAGS for osdef.sh, for Mac 10.4 some flags don't work together # with "-E". OSDEF_CFLAGS = $(PRE_DEFS) $(POST_DEFS) -LINT_CFLAGS = -DLINT -I. $(PRE_DEFS) $(POST_DEFS) $(LUA_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) -Dinline= -D__extension__= -Dalloca=alloca +LINT_CFLAGS = -DLINT -I. $(PRE_DEFS) $(POST_DEFS) $(RUBY_CFLAGS) $(LUA_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) -Dinline= -D__extension__= -Dalloca=alloca LINT_EXTRA = -DUSE_SNIFF -DHANGUL_INPUT -D"__attribute__(x)=" @@ -1352,7 +1358,8 @@ $(PYTHON3_LIBS) \ $(TCL_LIBS) \ $(RUBY_LIBS) \ - $(PROFILE_LIBS) + $(PROFILE_LIBS) \ + $(LEAK_LIBS) # abbreviations DEST_BIN = $(DESTDIR)$(BINDIR) @@ -1474,8 +1481,15 @@ if_python.c if_python3.c if_tcl.c if_ruby.c if_sniff.c \ gui_beval.c workshop.c wsdebug.c integration.c netbeans.c +# Unittest files +MEMFILE_TEST_SRC = memfile_test.c +MEMFILE_TEST_TARGET = memfile_test$(EXEEXT) + +UNITTEST_SRC = $(MEMFILE_TEST_SRC) +UNITTEST_TARGETS = $(MEMFILE_TEST_TARGET) + # All sources, also the ones that are not configured -ALL_SRC = $(BASIC_SRC) $(ALL_GUI_SRC) $(EXTRA_SRC) +ALL_SRC = $(BASIC_SRC) $(ALL_GUI_SRC) $(UNITTEST_SRC) $(EXTRA_SRC) # Which files to check with lint. Select one of these three lines. ALL_SRC # checks more, but may not work well for checking a GUI that wasn't configured. @@ -1486,7 +1500,7 @@ #LINT_SRC = $(ALL_SRC) #LINT_SRC = $(BASIC_SRC) -OBJ = \ +OBJ_COMMON = \ objects/buffer.o \ objects/blowfish.o \ objects/charset.o \ @@ -1507,10 +1521,8 @@ $(HANGULIN_OBJ) \ objects/if_cscope.o \ objects/if_xcmdsrv.o \ - objects/main.o \ objects/mark.o \ - objects/memfile.o \ - objects/memline.o \ + objects/memline.o \ objects/menu.o \ objects/message.o \ objects/misc1.o \ @@ -1535,6 +1547,7 @@ objects/term.o \ objects/ui.o \ objects/undo.o \ + objects/version.o \ objects/window.o \ $(GUI_OBJ) \ $(LUA_OBJ) \ @@ -1549,6 +1562,13 @@ $(NETBEANS_OBJ) \ $(WSDEBUG_OBJ) +OBJ = $(OBJ_COMMON) \ + objects/main.o \ + objects/memfile.o + +MEMFILE_TEST_OBJ = $(OBJ_COMMON) \ + objects/memfile_test.o + PRO_AUTO = \ blowfish.pro \ buffer.pro \ @@ -1612,7 +1632,7 @@ RSRC_DIR = os_mac_rsrc PRO_MANUAL = os_amiga.pro os_msdos.pro os_win16.pro os_win32.pro \ - os_mswin.pro os_beos.pro os_vms.pro os_riscos.pro $(PERL_PRO) + os_mswin.pro os_beos.pro os_vms.pro $(PERL_PRO) # Default target is making the executable and tools all: $(VIMTARGET) $(TOOLS) languages $(GUI_BUNDLE) @@ -1633,7 +1653,8 @@ CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" \ LDFLAGS="$(LDFLAGS)" $(CONF_SHELL) srcdir="$(srcdir)" \ ./configure $(CONF_OPT_GUI) $(CONF_OPT_X) $(CONF_OPT_XSMP) \ - $(CONF_OPT_DARWIN) $(CONF_OPT_PERL) $(CONF_OPT_PYTHON) $(CONF_OPT_PYTHON3) \ + $(CONF_OPT_DARWIN) $(CONF_OPT_FAIL) \ + $(CONF_OPT_PERL) $(CONF_OPT_PYTHON) $(CONF_OPT_PYTHON3) \ $(CONF_OPT_TCL) $(CONF_OPT_RUBY) $(CONF_OPT_NLS) \ $(CONF_OPT_CSCOPE) $(CONF_OPT_MULTIBYTE) $(CONF_OPT_INPUT) \ $(CONF_OPT_OUTPUT) $(CONF_OPT_GPM) $(CONF_OPT_WORKSHOP) \ @@ -1694,11 +1715,12 @@ $(VIMTARGET): auto/config.mk objects $(OBJ) version.c version.h $(CCC) version.c -o objects/version.o @LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \ - -o $(VIMTARGET) $(OBJ) objects/version.o $(ALL_LIBS)" \ - MAKE="$(MAKE)" sh $(srcdir)/link.sh + -o $(VIMTARGET) $(OBJ) $(ALL_LIBS)" \ + MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \ + sh $(srcdir)/link.sh xxd/xxd$(EXEEXT): xxd/xxd.c - cd xxd; CC="$(CC)" CFLAGS="$(CPPFLAGS) $(CFLAGS)" \ + cd xxd; CC="$(CC)" CFLAGS="$(CPPFLAGS) $(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ $(MAKE) -f Makefile # Build the language specific files if they were unpacked. @@ -1818,6 +1840,15 @@ ln -s $(VIMTARGET) vim; \ fi cd testdir; $(MAKE) -f Makefile $(GUI_TESTTARGET) VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) + $(MAKE) -f Makefile unittest + +unittesttargets: + $(MAKE) -f Makefile $(UNITTEST_TARGETS) + +unittest unittests: $(UNITTEST_TARGETS) + @for t in $(UNITTEST_TARGETS); do \ + ./$$t || exit 1; echo $$t passed; \ + done testclean: cd testdir; $(MAKE) -f Makefile clean @@ -1825,6 +1856,17 @@ cd $(PODIR); $(MAKE) checkclean; \ fi +# Unittests +# It's build just like Vim to satisfy all dependencies. +$(MEMFILE_TEST_TARGET): auto/config.mk objects $(MEMFILE_TEST_OBJ) + $(CCC) version.c -o objects/version.o + @LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \ + -o $(MEMFILE_TEST_TARGET) $(MEMFILE_TEST_OBJ) $(ALL_LIBS)" \ + MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \ + sh $(srcdir)/link.sh + +# install targets + install: $(GUI_INSTALL) install_normal: installvim installtools $(INSTALL_LANGS) install-icons @@ -2258,6 +2300,7 @@ -rm -f *.o objects/* core $(VIMTARGET).core $(VIMTARGET) vim xxd/*.o -rm -f $(TOOLS) auto/osdef.h auto/pathdef.c auto/if_perl.c -rm -f conftest* *~ auto/link.sed + -rm -f $(UNITTEST_TARGETS) -rm -f runtime pixmaps -rm -rf $(APPDIR) -rm -rf mzscheme_base.c @@ -2291,6 +2334,7 @@ ../../testdir/vimrc.unix \ ../../testdir/*.in \ ../../testdir/*.vim \ + ../../testdir/test83-tags? \ ../../testdir/*.ok . # Link needed for doing "make install" in a shadow directory. @@ -2532,7 +2576,7 @@ $(CCC) $(PYTHON3_CFLAGS) $(PYTHON3_CFLAGS_EXTRA) -o $@ if_python3.c objects/if_ruby.o: if_ruby.c - $(CCC) -o $@ if_ruby.c + $(CCC) $(RUBY_CFLAGS) -o $@ if_ruby.c objects/if_sniff.o: if_sniff.c $(CCC) -o $@ if_sniff.c @@ -2552,6 +2596,9 @@ objects/memfile.o: memfile.c $(CCC) -o $@ memfile.c +objects/memfile_test.o: memfile_test.c + $(CCC) -o $@ memfile_test.c + objects/memline.o: memline.c $(CCC) -o $@ memline.c @@ -2870,7 +2917,7 @@ objects/os_unix.o: os_unix.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \ - arabic.h if_mzsch.h os_unixx.h + arabic.h os_unixx.h objects/pathdef.o: auto/pathdef.c vim.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \ @@ -3009,6 +3056,10 @@ objects/pty.o: pty.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h ascii.h \ keymap.h term.h macros.h option.h structs.h regexp.h gui.h gui_beval.h \ proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h arabic.h +objects/memfile_test.o: memfile_test.c main.c vim.h auto/config.h feature.h \ + os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h \ + structs.h regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h \ + proto.h globals.h farsi.h arabic.h farsi.c arabic.c memfile.c objects/hangulin.o: hangulin.c vim.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \ @@ -3020,7 +3071,7 @@ objects/if_mzsch.o: if_mzsch.c vim.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \ - globals.h farsi.h arabic.h if_mzsch.h mzscheme_base.c + globals.h farsi.h arabic.h if_mzsch.h objects/if_perl.o: auto/if_perl.c vim.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \ @@ -3041,7 +3092,7 @@ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \ arabic.h -objects/if_ruby.o: if_ruby.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \ +objects/if_ruby.o: if_ruby.c auto/config.h vim.h feature.h os_unix.h auto/osdef.h \ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \ arabic.h version.h diff -Naur vim73.orig/src/VisVim/Commands.cpp vim73.patched/src/VisVim/Commands.cpp --- vim73.orig/src/VisVim/Commands.cpp 2010-05-15 06:04:08.000000000 -0500 +++ vim73.patched/src/VisVim/Commands.cpp 2012-05-20 12:55:42.000000000 -0500 @@ -549,7 +549,7 @@ if (g_bNewTabs) { sprintf(VimCmd, ":tab drop "); - s = VimCmd + 11; + s = VimCmd + 10; } else { @@ -557,8 +557,7 @@ s = VimCmd + 6; } sprintf(FileNameTmp, "%S", (char *)FileName); - for (p = FileNameTmp; *p != '\0' && s < FileNameTmp + MAX_OLE_STR - 4; - ++p) + for (p = FileNameTmp; *p != '\0' && s < VimCmd + MAX_OLE_STR - 4; ++p) if (*p == '\\') *s++ = '/'; else diff -Naur vim73.orig/src/ascii.h vim73.patched/src/ascii.h --- vim73.orig/src/ascii.h 2010-05-15 06:04:07.000000000 -0500 +++ vim73.patched/src/ascii.h 2012-05-20 12:55:42.000000000 -0500 @@ -123,7 +123,7 @@ #define DCS 0x90 /* Device Control String */ #define STERM 0x9c /* String Terminator */ -#define POUND '£' +#define POUND 0xB1 #define CTRL_F_STR "\056" #define CTRL_H_STR "\026" @@ -183,11 +183,6 @@ # define PATHSEP psepc # define PATHSEPSTR pseps #else -# ifdef RISCOS -# define PATHSEP '.' -# define PATHSEPSTR "." -# else -# define PATHSEP '/' -# define PATHSEPSTR "/" -# endif +# define PATHSEP '/' +# define PATHSEPSTR "/" #endif diff -Naur vim73.orig/src/auto/config.mk vim73.patched/src/auto/config.mk --- vim73.orig/src/auto/config.mk 2010-08-15 08:02:25.000000000 -0500 +++ vim73.patched/src/auto/config.mk 1969-12-31 18:00:00.000000000 -0600 @@ -1,5 +0,0 @@ -the first targets to make vim are: scratch config myself -srcdir = . -VIMNAME = vim -EXNAME = ex -VIEWNAME = view diff -Naur vim73.orig/src/auto/configure vim73.patched/src/auto/configure --- vim73.orig/src/auto/configure 2010-08-13 09:17:15.000000000 -0500 +++ vim73.patched/src/auto/configure 2012-05-20 12:55:43.000000000 -0500 @@ -593,6 +593,7 @@ ac_subst_vars='LTLIBOBJS LIBOBJS +LINK_AS_NEEDED DEPEND_CFLAGS_FILTER MAKEMO MSGFMT @@ -740,6 +741,7 @@ ac_subst_files='' ac_user_opts=' enable_option_checking +enable_fail_if_missing enable_darwin with_mac_arch with_developer_dir @@ -1417,6 +1419,8 @@ --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-fail-if-missing Fail if dependencies on additional features + specified on the command line are missing. --disable-darwin Disable Darwin (Mac OS X) support. --disable-selinux Don't check for SELinux support. --disable-xsmp Disable XSMP session management @@ -1427,7 +1431,7 @@ --enable-pythoninterp=OPTS Include Python interpreter. default=no OPTS=no/yes/dynamic --enable-python3interp=OPTS Include Python3 interpreter. default=no OPTS=no/yes/dynamic --enable-tclinterp Include Tcl interpreter. - --enable-rubyinterp Include Ruby interpreter. + --enable-rubyinterp=OPTS Include Ruby interpreter. default=no OPTS=no/yes/dynamic --enable-cscope Include cscope interface. --enable-workshop Include Sun Visual Workshop support. --disable-netbeans Disable NetBeans integration support. @@ -3948,6 +3952,19 @@ fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-fail-if-missing argument" >&5 +$as_echo_n "checking --enable-fail-if-missing argument... " >&6; } +# Check whether --enable-fail_if_missing was given. +if test "${enable_fail_if_missing+set}" = set; then : + enableval=$enable_fail_if_missing; fail_if_missing="yes" +else + fail_if_missing="no" +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $fail_if_missing" >&5 +$as_echo "$fail_if_missing" >&6; } + if test -z "$CFLAGS"; then CFLAGS="-O" test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall" @@ -4726,6 +4743,9 @@ LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"liblua${vi_cv_version_lua}.so$LUA_SONAME\\\" $LUA_CFLAGS" fi fi + if test "$fail_if_missing" = "yes" -a -z "$LUA_SRC"; then + as_fn_error "could not configure lua" "$LINENO" 5 + fi @@ -4862,16 +4882,36 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in /usr/include/plt/" >&5 -$as_echo_n "checking if scheme.h can be found in /usr/include/plt/... " >&6; } - if test -f /usr/include/plt/scheme.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket" >&5 +$as_echo_n "checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket... " >&6; } + if test -f $vi_cv_path_mzscheme_pfx/include/racket/scheme.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - SCHEME_INC=/usr/include/plt + SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - vi_cv_path_mzscheme_pfx= + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in /usr/include/plt/" >&5 +$as_echo_n "checking if scheme.h can be found in /usr/include/plt/... " >&6; } + if test -f /usr/include/plt/scheme.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SCHEME_INC=/usr/include/plt + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in /usr/include/racket/" >&5 +$as_echo_n "checking if scheme.h can be found in /usr/include/racket/... " >&6; } + if test -f /usr/include/racket/scheme.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SCHEME_INC=/usr/include/racket + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + vi_cv_path_mzscheme_pfx= + fi + fi fi fi fi @@ -4883,12 +4923,22 @@ elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a" MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" - elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"; then + elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"; then + MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.a"; then + MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a" + elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a"; then MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a" else if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.so"; then MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme3m" MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.so"; then + MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket3m" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.so"; then + MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket -lmzgc" else MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc" fi @@ -4901,10 +4951,20 @@ fi if test -d $vi_cv_path_mzscheme_pfx/lib/plt/collects; then SCHEME_COLLECTS=lib/plt/ + else + if test -d $vi_cv_path_mzscheme_pfx/lib/racket/collects; then + SCHEME_COLLECTS=lib/racket/ + fi fi if test -f "${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects/scheme/base.ss" ; then - MZSCHEME_EXTRA="mzscheme_base.c" - MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE" + MZSCHEME_EXTRA="mzscheme_base.c" + else + if test -f "${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then + MZSCHEME_EXTRA="mzscheme_base.c" + fi + fi + if test "X$MZSCHEME_EXTRA" != "X" ; then + MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE" MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc" fi MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \ @@ -5099,6 +5159,10 @@ PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS" fi fi + + if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then + as_fn_error "could not configure perl" "$LINENO" 5 + fi fi @@ -5285,9 +5349,9 @@ PYTHON_LIBS="${vi_cv_path_python_plibs}" if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then - PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}" + PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\"" else - PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version}" + PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\"" fi PYTHON_SRC="if_python.c" if test "x$MACOSX" = "xyes"; then @@ -5298,7 +5362,7 @@ if test "${vi_cv_var_python_version}" = "1.4"; then PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o" fi - PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'" + PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -pthread should be used" >&5 $as_echo_n "checking if -pthread should be used... " >&6; } @@ -5388,6 +5452,10 @@ $as_echo "too old" >&6; } fi fi + + if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then + as_fn_error "could not configure python" "$LINENO" 5 + fi fi @@ -5464,6 +5532,23 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_var_python3_version" >&5 $as_echo "$vi_cv_var_python3_version" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python's abiflags" >&5 +$as_echo_n "checking Python's abiflags... " >&6; } +if test "${vi_cv_var_python3_abiflags+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + vi_cv_var_python3_abiflags= + if ${vi_cv_path_python3} -c \ + "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)" + then + vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \ + "import sys; print(sys.abiflags)"` + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_var_python3_abiflags" >&5 +$as_echo "$vi_cv_var_python3_abiflags" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python's install prefix" >&5 $as_echo_n "checking Python's install prefix... " >&6; } if test "${vi_cv_path_python3_pfx+set}" = set; then : @@ -5514,9 +5599,13 @@ else vi_cv_path_python3_conf= + config_dir="config" + if test "${vi_cv_var_python3_abiflags}" != ""; then + config_dir="${config_dir}-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}" + fi for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do for subdir in lib64 lib share; do - d="${path}/${subdir}/python${vi_cv_var_python3_version}/config" + d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}" if test -d "$d" && test -f "$d/config.c"; then vi_cv_path_python3_conf="$d" fi @@ -5545,13 +5634,12 @@ @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'" @echo "python3_LIBS='$(LIBS)'" @echo "python3_SYSLIBS='$(SYSLIBS)'" - @echo "python3_LINKFORSHARED='$(LINKFORSHARED)'" @echo "python3_INSTSONAME='$(INSTSONAME)'" eof eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`" rm -f -- "${tmp_mkf}" - vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}" - vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS} ${python3_LINKFORSHARED}" + vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}" + vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}" vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//` vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//` @@ -5560,9 +5648,9 @@ PYTHON3_LIBS="${vi_cv_path_python3_plibs}" if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then - PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}" + PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" else - PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}" + PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" fi PYTHON3_SRC="if_python3.c" if test "x$MACOSX" = "xyes"; then @@ -5667,12 +5755,12 @@ $as_echo "#define DYNAMIC_PYTHON3 1" >>confdefs.h - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can do without RTLD_GLOBAL" >&5 -$as_echo_n "checking whether we can do without RTLD_GLOBAL... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can do without RTLD_GLOBAL for Python" >&5 +$as_echo_n "checking whether we can do without RTLD_GLOBAL for Python... " >&6; } cflags_save=$CFLAGS - CFLAGS="$CFLAGS $PYTHON3_CFLAGS" + CFLAGS="$CFLAGS $PYTHON_CFLAGS" ldflags_save=$LDFLAGS - LDFLAGS="$LDFLAGS -ldl" + LDFLAGS="-ldl $LDFLAGS" if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} @@ -5689,15 +5777,17 @@ * Only the first pyhton version used will be switched on. */ - int no_rtl_global_needed_for(char *python_instsoname) + int no_rtl_global_needed_for(char *python_instsoname, char *prefix) { int needed = 0; void* pylib = dlopen(python_instsoname, RTLD_LAZY); if (pylib != 0) { + void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome"); void (*init)(void) = dlsym(pylib, "Py_Initialize"); int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString"); void (*final)(void) = dlsym(pylib, "Py_Finalize"); + (*pfx)(prefix); (*init)(); needed = (*simple)("import termios") == -1; (*final)(); @@ -5709,7 +5799,7 @@ int main(int argc, char** argv) { int not_needed = 0; - if (no_rtl_global_needed_for("libpython2.7.so.1.0") && no_rtl_global_needed_for("libpython3.1.so.1.0")) + if (no_rtl_global_needed_for("${python_INSTSONAME}", "${vi_cv_path_python_pfx}")) not_needed = 1; return !not_needed; } @@ -5726,8 +5816,76 @@ conftest.$ac_objext conftest.beam conftest.$ac_ext fi + CFLAGS=$cflags_save LDFLAGS=$ldflags_save + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can do without RTLD_GLOBAL for Python3" >&5 +$as_echo_n "checking whether we can do without RTLD_GLOBAL for Python3... " >&6; } + cflags_save=$CFLAGS + CFLAGS="$CFLAGS $PYTHON3_CFLAGS" + ldflags_save=$LDFLAGS + LDFLAGS="-ldl $LDFLAGS" + if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot run test program while cross compiling +See \`config.log' for more details." "$LINENO" 5; } +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #include + /* If this program fails, then RTLD_GLOBAL is needed. + * RTLD_GLOBAL will be used and then it is not possible to + * have both python versions enabled in the same vim instance. + * Only the first pyhton version used will be switched on. + */ + + int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix) + { + int needed = 0; + void* pylib = dlopen(python_instsoname, RTLD_LAZY); + if (pylib != 0) + { + void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome"); + void (*init)(void) = dlsym(pylib, "Py_Initialize"); + int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString"); + void (*final)(void) = dlsym(pylib, "Py_Finalize"); + (*pfx)(prefix); + (*init)(); + needed = (*simple)("import termios") == -1; + (*final)(); + dlclose(pylib); + } + return !needed; + } + + int main(int argc, char** argv) + { + int not_needed = 0; + if (no_rtl_global_needed_for("${python3_INSTSONAME}", L"${vi_cv_path_python3_pfx}")) + not_needed = 1; + return !not_needed; + } +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; };$as_echo "#define PY3_NO_RTLD_GLOBAL 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + + CFLAGS=$cflags_save + LDFLAGS=$ldflags_save + PYTHON_SRC="if_python.c" PYTHON_OBJ="objects/if_python.o" PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\"" @@ -6085,6 +6243,9 @@ $as_echo "too old; need Tcl version 8.0 or later" >&6; } fi fi + if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then + as_fn_error "could not configure Tcl" "$LINENO" 5 + fi fi @@ -6103,20 +6264,20 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_rubyinterp" >&5 $as_echo "$enable_rubyinterp" >&6; } -if test "$enable_rubyinterp" = "yes"; then +if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-ruby-command argument" >&5 $as_echo_n "checking --with-ruby-command argument... " >&6; } + # Check whether --with-ruby-command was given. if test "${with_ruby_command+set}" = set; then : - withval=$with_ruby_command; RUBY_CMD="$withval"; { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBY_CMD" >&5 + withval=$with_ruby_command; RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBY_CMD" >&5 $as_echo "$RUBY_CMD" >&6; } else RUBY_CMD="ruby"; { $as_echo "$as_me:${as_lineno-$LINENO}: result: defaulting to $RUBY_CMD" >&5 $as_echo "defaulting to $RUBY_CMD" >&6; } fi - # Extract the first word of "$RUBY_CMD", so it can be a program name with args. set dummy $RUBY_CMD; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -6181,17 +6342,14 @@ RUBY_LIBS="$rubylibs" fi librubyarg=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG["LIBRUBYARG"])'` - if test -f "$rubyhdrdir/$librubyarg"; then - librubyarg="$rubyhdrdir/$librubyarg" - else - rubylibdir=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG["libdir"])'` - if test -f "$rubylibdir/$librubyarg"; then - librubyarg="$rubylibdir/$librubyarg" - elif test "$librubyarg" = "libruby.a"; then - librubyarg="-lruby" - else - librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print '$librubyarg'.gsub(/-L\./, %'-L#{Config.expand(Config::CONFIG[\"libdir\"])}')"` - fi + librubya=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG["LIBRUBY_A"])'` + rubylibdir=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG["libdir"])'` + if test -f "$rubylibdir/$librubya"; then + librubyarg="$librubyarg" + RUBY_LIBS="$RUBY_LIBS -L$rubylibdir" + elif test "$librubyarg" = "libruby.a"; then + librubyarg="-lruby" + RUBY_LIBS="$RUBY_LIBS -L$rubylibdir" fi if test "X$librubyarg" != "X"; then @@ -6209,6 +6367,13 @@ RUBY_PRO="if_ruby.pro" $as_echo "#define FEAT_RUBY 1" >>confdefs.h + if test "$enable_rubyinterp" = "dynamic"; then + libruby=`$vi_cv_path_ruby -r rbconfig -e 'printf "lib%s.%s\n", Config::CONFIG["RUBY_SO_NAME"], Config::CONFIG["DLEXT"]'` + $as_echo "#define DYNAMIC_RUBY 1" >>confdefs.h + + RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS" + RUBY_LIBS= + fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found; disabling Ruby" >&5 $as_echo "not found; disabling Ruby" >&6; } @@ -6218,6 +6383,10 @@ $as_echo "too old; need Ruby version 1.6.0 or later" >&6; } fi fi + + if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then + as_fn_error "could not configure Ruby" "$LINENO" 5 + fi fi @@ -9768,9 +9937,9 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: empty: automatic terminal library selection" >&5 $as_echo "empty: automatic terminal library selection" >&6; } - case "`uname -s 2>/dev/null`" in - OSF1|SCO_SV) tlibs="ncurses curses termlib termcap";; - *) tlibs="ncurses termlib termcap curses";; + case "`uname -s 2>/dev/null`" in + OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";; + *) tlibs="tinfo ncurses termlib termcap curses";; esac for libname in $tlibs; do as_ac_Lib=`$as_echo "ac_cv_lib_${libname}''_tgetent" | $as_tr_sh` @@ -11159,7 +11328,47 @@ rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Solaris ACL support" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for acl_get in -lsec" >&5 +$as_echo_n "checking for acl_get in -lsec... " >&6; } +if test "${ac_cv_lib_sec_acl_get+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsec $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char acl_get (); +int +main () +{ +return acl_get (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sec_acl_get=yes +else + ac_cv_lib_sec_acl_get=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sec_acl_get" >&5 +$as_echo "$ac_cv_lib_sec_acl_get" >&6; } +if test "x$ac_cv_lib_sec_acl_get" = x""yes; then : + LIBS="$LIBS -lsec"; $as_echo "#define HAVE_SOLARIS_ZFS_ACL 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Solaris ACL support" >&5 $as_echo_n "checking for Solaris ACL support... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -11186,6 +11395,8 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for AIX ACL support" >&5 $as_echo_n "checking for AIX ACL support... " >&6; } @@ -11642,7 +11853,8 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking uint32_t is 32 bits" >&5 $as_echo_n "checking uint32_t is 32 bits... " >&6; } if test "$cross_compiling" = yes; then : - as_fn_error "could not compile program using uint32_t." "$LINENO" 5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check uint32_t when cross-compiling." >&5 +$as_echo "$as_me: WARNING: cannot check uint32_t when cross-compiling." >&2;} else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -11915,6 +12127,10 @@ test -f tags && mv tags tags.save if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&5 2>&1; then TAGPRG="ctags -I INIT+ --fields=+S" +elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&5 2>&1; then + TAGPRG="exctags -I INIT+ --fields=+S" +elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&5 2>&1; then + TAGPRG="exuberant-ctags -I INIT+ --fields=+S" else TAGPRG="ctags" (eval etags /dev/null) < /dev/null 1>&5 2>&1 && TAGPRG="etags" @@ -12344,10 +12560,10 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we need -D_FORTIFY_SOURCE=1" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we need -D_FORTIFY_SOURCE=1" >&5 $as_echo_n "checking whether we need -D_FORTIFY_SOURCE=1... " >&6; } if test "$gccmajor" -gt "3"; then - CFLAGS=`echo "$CFLAGS" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/-D_FORTIFY_SOURCE=.//g' -e 's/$/ -D_FORTIFY_SOURCE=1/'` + CFLAGS=`echo "$CFLAGS" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/-D_FORTIFY_SOURCE=.//g' -e 's/$/ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1/'` { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else @@ -12357,6 +12573,23 @@ fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker --as-needed support" >&5 +$as_echo_n "checking linker --as-needed support... " >&6; } +LINK_AS_NEEDED= +# Check if linker supports --as-needed and --no-as-needed options +if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then + LDFLAGS="$LDFLAGS -Wl,--as-needed" + LINK_AS_NEEDED=yes +fi +if test "$LINK_AS_NEEDED" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + ac_config_files="$ac_config_files auto/config.mk:config.mk.in" cat >confcache <<\_ACEOF diff -Naur vim73.orig/src/blowfish.c vim73.patched/src/blowfish.c --- vim73.orig/src/blowfish.c 2010-07-14 09:45:39.000000000 -0500 +++ vim73.patched/src/blowfish.c 2012-05-20 12:55:41.000000000 -0500 @@ -413,6 +413,7 @@ int salt_len; { int i, j, keypos = 0; + unsigned u; UINT32_T val, data_l, data_r; char_u *key; int keylen; @@ -432,8 +433,8 @@ } for (i = 0; i < keylen; i++) { - sscanf((char *)&key[i * 2], "%2x", &j); - key[i] = j; + sscanf((char *)&key[i * 2], "%2x", &u); + key[i] = u; } mch_memmove(sbx, sbi, 4 * 4 * 256); diff -Naur vim73.orig/src/buffer.c vim73.patched/src/buffer.c --- vim73.orig/src/buffer.c 2010-08-13 04:14:35.000000000 -0500 +++ vim73.patched/src/buffer.c 2012-05-20 12:55:43.000000000 -0500 @@ -64,6 +64,9 @@ static char *msg_loclist = N_("[Location List]"); static char *msg_qflist = N_("[Quickfix List]"); #endif +#ifdef FEAT_AUTOCMD +static char *e_auabort = N_("E855: Autocommands caused command to abort"); +#endif /* * Open current buffer, that is: open the memfile and read the file into @@ -96,7 +99,7 @@ * There MUST be a memfile, otherwise we can't do anything * If we can't create one for the current buffer, take another buffer */ - close_buffer(NULL, curbuf, 0); + close_buffer(NULL, curbuf, 0, FALSE); for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next) if (curbuf->b_ml.ml_mfp != NULL) break; @@ -316,12 +319,17 @@ * get a new buffer very soon! * * The 'bufhidden' option can force freeing and deleting. + * + * When "abort_if_last" is TRUE then do not close the buffer if autocommands + * cause there to be only one window with this buffer. e.g. when ":quit" is + * supposed to close the window but autocommands close all other windows. */ void -close_buffer(win, buf, action) +close_buffer(win, buf, action, abort_if_last) win_T *win; /* if not NULL, set b_last_cursor */ buf_T *buf; int action; + int abort_if_last UNUSED; { #ifdef FEAT_AUTOCMD int is_curbuf; @@ -371,8 +379,12 @@ { apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, buf->b_fname, FALSE, buf); - if (!buf_valid(buf)) /* autocommands may delete the buffer */ + /* Return if autocommands deleted the buffer or made it the only one. */ + if (!buf_valid(buf) || (abort_if_last && one_window())) + { + EMSG(_(e_auabort)); return; + } /* When the buffer becomes hidden, but is not unloaded, trigger * BufHidden */ @@ -380,8 +392,13 @@ { apply_autocmds(EVENT_BUFHIDDEN, buf->b_fname, buf->b_fname, FALSE, buf); - if (!buf_valid(buf)) /* autocmds may delete the buffer */ + /* Return if autocommands deleted the buffer or made it the only + * one. */ + if (!buf_valid(buf) || (abort_if_last && one_window())) + { + EMSG(_(e_auabort)); return; + } } # ifdef FEAT_EVAL if (aborting()) /* autocmds may abort script processing */ @@ -416,6 +433,14 @@ #endif buf_freeall(buf, (del_buf ? BFA_DEL : 0) + (wipe_buf ? BFA_WIPE : 0)); + if ( +#ifdef FEAT_WINDOWS + win_valid(win) && +#else + win != NULL && +#endif + win->w_buffer == buf) + win->w_buffer = NULL; /* make sure we don't use the buffer now */ #ifdef FEAT_AUTOCMD /* Autocommands may have deleted the buffer. */ @@ -560,6 +585,11 @@ #ifdef FEAT_DIFF diff_buf_delete(buf); /* Can't use 'diff' for unloaded buffer. */ #endif +#ifdef FEAT_SYN_HL + /* Remove any ownsyntax, unless exiting. */ + if (firstwin != NULL && curwin->w_buffer == buf) + reset_synblock(curwin); +#endif #ifdef FEAT_FOLDING /* No folds in an empty buffer. */ @@ -639,6 +669,9 @@ { clear_wininfo(buf); /* including window-local options */ free_buf_options(buf, TRUE); +#ifdef FEAT_SPELL + ga_clear(&buf->b_s.b_langp); +#endif } #ifdef FEAT_EVAL vars_clear(&buf->b_vars.dv_hashtab); /* free all internal variables */ @@ -661,9 +694,6 @@ vim_free(buf->b_start_fenc); buf->b_start_fenc = NULL; #endif -#ifdef FEAT_SPELL - ga_clear(&buf->b_s.b_langp); -#endif } /* @@ -762,7 +792,7 @@ * open a new, empty buffer. */ swap_exists_action = SEA_NONE; /* don't want it again */ swap_exists_did_quit = TRUE; - close_buffer(curwin, curbuf, DOBUF_UNLOAD); + close_buffer(curwin, curbuf, DOBUF_UNLOAD, FALSE); if (!buf_valid(old_curbuf) || old_curbuf == curbuf) old_curbuf = buflist_new(NULL, NULL, 1L, BLN_CURBUF | BLN_LISTED); if (old_curbuf != NULL) @@ -1109,7 +1139,7 @@ * if the buffer still exists. */ if (buf != curbuf && buf_valid(buf) && buf->b_nwindows == 0) - close_buffer(NULL, buf, action); + close_buffer(NULL, buf, action, FALSE); return retval; } @@ -1133,7 +1163,7 @@ close_windows(buf, FALSE); #endif if (buf != curbuf && buf_valid(buf) && buf->b_nwindows <= 0) - close_buffer(NULL, buf, action); + close_buffer(NULL, buf, action, FALSE); return OK; } @@ -1288,9 +1318,12 @@ /* Go to the other buffer. */ set_curbuf(buf, action); -#if defined(FEAT_LISTCMDS) && defined(FEAT_SCROLLBIND) +#if defined(FEAT_LISTCMDS) \ + && (defined(FEAT_SCROLLBIND) || defined(FEAT_CURSORBIND)) if (action == DOBUF_SPLIT) - curwin->w_p_scb = FALSE; /* reset 'scrollbind' */ + { + RESET_BINDING(curwin); /* reset 'scrollbind' and 'cursorbind' */ + } #endif #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) @@ -1343,6 +1376,10 @@ # endif #endif { +#ifdef FEAT_SYN_HL + if (prevbuf == curwin->w_buffer) + reset_synblock(curwin); +#endif #ifdef FEAT_WINDOWS if (unload) close_windows(prevbuf, FALSE); @@ -1358,7 +1395,7 @@ close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, prevbuf, unload ? action : (action == DOBUF_GOTO && !P_HID(prevbuf) - && !bufIsChanged(prevbuf)) ? DOBUF_UNLOAD : 0); + && !bufIsChanged(prevbuf)) ? DOBUF_UNLOAD : 0, FALSE); } } #ifdef FEAT_AUTOCMD @@ -1392,10 +1429,6 @@ foldUpdateAll(curwin); /* update folds (later). */ #endif -#ifdef FEAT_SYN_HL - reset_synblock(curwin); - curwin->w_s = &(buf->b_s); -#endif /* Get the buffer in the current window. */ curwin->w_buffer = buf; curbuf = buf; @@ -1406,6 +1439,10 @@ diff_buf_add(curbuf); #endif +#ifdef FEAT_SYN_HL + curwin->w_s = &(buf->b_s); +#endif + /* Cursor on first line by default. */ curwin->w_cursor.lnum = 1; curwin->w_cursor.col = 0; @@ -1805,9 +1842,6 @@ #ifdef FEAT_AUTOCMD clear_string_option(&buf->b_p_ft); #endif -#ifdef FEAT_OSFILETYPE - clear_string_option(&buf->b_p_oft); -#endif #ifdef FEAT_CINDENT clear_string_option(&buf->b_p_cink); clear_string_option(&buf->b_p_cino); @@ -1917,9 +1951,7 @@ tabpage_new(); else if (win_split(0, 0) == FAIL) /* Open in a new window */ return FAIL; -# ifdef FEAT_SCROLLBIND - curwin->w_p_scb = FALSE; -# endif + RESET_BINDING(curwin); } } #endif @@ -2526,6 +2558,9 @@ if (p_fdls >= 0) curwin->w_p_fdl = p_fdls; #endif +#ifdef FEAT_SYN_HL + check_colorcolumn(curwin); +#endif } /* @@ -2690,7 +2725,8 @@ vim_free(ffname); return FAIL; } - close_buffer(NULL, obuf, DOBUF_WIPE); /* delete from the list */ + /* delete from the list */ + close_buffer(NULL, obuf, DOBUF_WIPE, FALSE); } sfname = vim_strsave(sfname); if (ffname == NULL || sfname == NULL) @@ -3175,7 +3211,7 @@ /* format: "fname + (path) (1 of 2) - VIM" */ if (curbuf->b_fname == NULL) - STRCPY(buf, _("[No Name]")); + vim_strncpy(buf, (char_u *)_("[No Name]"), IOSIZE - 100); else { p = transstr(gettail(curbuf->b_fname)); @@ -3231,7 +3267,7 @@ if (serverName != NULL) { STRCAT(buf, " - "); - STRCAT(buf, serverName); + vim_strcat(buf, serverName, IOSIZE); } else #endif @@ -3240,9 +3276,8 @@ if (maxlen > 0) { /* make it shorter by removing a bit in the middle */ - len = vim_strsize(buf); - if (len > maxlen) - trunc_string(buf, buf, maxlen); + if (vim_strsize(buf) > maxlen) + trunc_string(buf, buf, maxlen, IOSIZE); } } } @@ -3363,7 +3398,8 @@ * or truncated if too long, fillchar is used for all whitespace. */ int -build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hltab, tabtab) +build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, + maxwidth, hltab, tabtab) win_T *wp; char_u *out; /* buffer to write into != NameBuff */ size_t outlen; /* length of out[] */ @@ -3458,6 +3494,18 @@ prevchar_isitem = FALSE; for (s = usefmt; *s; ) { + if (curitem == STL_MAX_ITEM) + { + /* There are too many items. Add the error code to the statusline + * to give the user a hint about what went wrong. */ + if (p + 6 < out + outlen) + { + mch_memmove(p, " E541", (size_t)5); + p += 5; + } + break; + } + if (*s != NUL && *s != '%') prevchar_isflag = prevchar_isitem = FALSE; @@ -3473,6 +3521,8 @@ * Handle one '%' item. */ s++; + if (*s == NUL) /* ignore trailing % */ + break; if (*s == '%') { if (p + 1 >= out + outlen) @@ -4355,7 +4405,12 @@ { int i; win_T *wp, *wpnext; - char_u *opened; /* array of flags for which args are open */ + char_u *opened; /* Array of weight for which args are open: + * 0: not opened + * 1: opened in other tab + * 2: opened in curtab + * 3: opened in curtab and curwin + */ int opened_len; /* length of opened[] */ int use_firstwin = FALSE; /* use first window for arglist */ int split_ret = OK; @@ -4364,6 +4419,8 @@ buf_T *buf; tabpage_T *tpnext; int had_tab = cmdmod.tab; + win_T *old_curwin, *last_curwin; + tabpage_T *old_curtab, *last_curtab; win_T *new_curwin = NULL; tabpage_T *new_curtab = NULL; @@ -4380,6 +4437,15 @@ if (opened == NULL) return; + /* Autocommands may do anything to the argument list. Make sure it's not + * freed while we are working here by "locking" it. We still have to + * watch out for its size to be changed. */ + alist = curwin->w_alist; + ++alist->al_refcount; + + old_curwin = curwin; + old_curtab = curtab; + #ifdef FEAT_GUI need_mouse_correct = TRUE; #endif @@ -4401,36 +4467,51 @@ wpnext = wp->w_next; buf = wp->w_buffer; if (buf->b_ffname == NULL - || buf->b_nwindows > 1 + || (!keep_tabs && buf->b_nwindows > 1) #ifdef FEAT_VERTSPLIT || wp->w_width != Columns #endif ) - i = ARGCOUNT; + i = opened_len; else { /* check if the buffer in this window is in the arglist */ - for (i = 0; i < ARGCOUNT; ++i) + for (i = 0; i < opened_len; ++i) { - if (ARGLIST[i].ae_fnum == buf->b_fnum - || fullpathcmp(alist_name(&ARGLIST[i]), - buf->b_ffname, TRUE) & FPC_SAME) + if (i < alist->al_ga.ga_len + && (AARGLIST(alist)[i].ae_fnum == buf->b_fnum + || fullpathcmp(alist_name(&AARGLIST(alist)[i]), + buf->b_ffname, TRUE) & FPC_SAME)) { - if (i < opened_len) + int weight = 1; + + if (old_curtab == curtab) { - opened[i] = TRUE; + ++weight; + if (old_curwin == wp) + ++weight; + } + + if (weight > (int)opened[i]) + { + opened[i] = (char_u)weight; if (i == 0) { + if (new_curwin != NULL) + new_curwin->w_arg_idx = opened_len; new_curwin = wp; new_curtab = curtab; } } - if (wp->w_alist != curwin->w_alist) + else if (keep_tabs) + i = opened_len; + + if (wp->w_alist != alist) { /* Use the current argument list for all windows * containing a file from it. */ alist_unlink(wp->w_alist); - wp->w_alist = curwin->w_alist; + wp->w_alist = alist; ++wp->w_alist->al_refcount; } break; @@ -4439,7 +4520,7 @@ } wp->w_arg_idx = i; - if (i == ARGCOUNT && !keep_tabs) /* close this window */ + if (i == opened_len && !keep_tabs)/* close this window */ { if (P_HID(buf) || forceit || buf->b_nwindows > 1 || !bufIsChanged(buf)) @@ -4461,7 +4542,8 @@ } #ifdef FEAT_WINDOWS /* don't close last window */ - if (firstwin == lastwin && first_tabpage->tp_next == NULL) + if (firstwin == lastwin + && (first_tabpage->tp_next == NULL || !had_tab)) #endif use_firstwin = TRUE; #ifdef FEAT_WINDOWS @@ -4495,20 +4577,16 @@ * Open a window for files in the argument list that don't have one. * ARGCOUNT may change while doing this, because of autocommands. */ - if (count > ARGCOUNT || count <= 0) - count = ARGCOUNT; - - /* Autocommands may do anything to the argument list. Make sure it's not - * freed while we are working here by "locking" it. We still have to - * watch out for its size to be changed. */ - alist = curwin->w_alist; - ++alist->al_refcount; + if (count > opened_len || count <= 0) + count = opened_len; #ifdef FEAT_AUTOCMD /* Don't execute Win/Buf Enter/Leave autocommands here. */ ++autocmd_no_enter; ++autocmd_no_leave; #endif + last_curwin = curwin; + last_curtab = curtab; win_enter(lastwin, FALSE); #ifdef FEAT_WINDOWS /* ":drop all" should re-use an empty window to avoid "--remote-tab" @@ -4518,11 +4596,11 @@ use_firstwin = TRUE; #endif - for (i = 0; i < count && i < alist->al_ga.ga_len && !got_int; ++i) + for (i = 0; i < count && i < opened_len && !got_int; ++i) { if (alist == &global_alist && i == global_alist.al_ga.ga_len - 1) arg_had_last = TRUE; - if (i < opened_len && opened[i]) + if (opened[i] > 0) { /* Move the already present window to below the current window */ if (curwin->w_arg_idx != i) @@ -4531,7 +4609,13 @@ { if (wpnext->w_arg_idx == i) { - win_move_after(wpnext, curwin); + if (keep_tabs) + { + new_curwin = wpnext; + new_curtab = curtab; + } + else + win_move_after(wpnext, curwin); break; } } @@ -4586,6 +4670,14 @@ #ifdef FEAT_AUTOCMD --autocmd_no_enter; #endif + /* restore last referenced tabpage's curwin */ + if (last_curtab != new_curtab) + { + if (valid_tabpage(last_curtab)) + goto_tabpage_tp(last_curtab); + if (win_valid(last_curwin)) + win_enter(last_curwin, FALSE); + } /* to window with first arg */ if (valid_tabpage(new_curtab)) goto_tabpage_tp(new_curtab); @@ -5465,7 +5557,7 @@ buf = firstbuf; else buf = rbuf; - while (buf != NULL) + while (buf != NULL && !got_int) { if (buf->b_signlist != NULL) { @@ -5473,7 +5565,7 @@ MSG_PUTS_ATTR(lbuf, hl_attr(HLF_D)); msg_putchar('\n'); } - for (p = buf->b_signlist; p != NULL; p = p->next) + for (p = buf->b_signlist; p != NULL && !got_int; p = p->next) { vim_snprintf(lbuf, BUFSIZ, _(" line=%ld id=%d name=%s"), (long)p->lnum, p->id, sign_typenr2name(p->typenr)); @@ -5606,7 +5698,7 @@ if (!aucmd) /* Don't trigger BufDelete autocommands here. */ block_autocmds(); #endif - close_buffer(NULL, buf, DOBUF_WIPE); + close_buffer(NULL, buf, DOBUF_WIPE, FALSE); #ifdef FEAT_AUTOCMD if (!aucmd) unblock_autocmds(); diff -Naur vim73.orig/src/charset.c vim73.patched/src/charset.c --- vim73.orig/src/charset.c 2010-08-12 13:16:04.000000000 -0500 +++ vim73.patched/src/charset.c 2012-05-20 12:55:43.000000000 -0500 @@ -463,41 +463,42 @@ if (enc_utf8) { int c = utf_ptr2char(STR_PTR(i)); - int ol = utf_ptr2len(STR_PTR(i)); + int olen = utf_ptr2len(STR_PTR(i)); int lc = utf_tolower(c); /* Only replace the character when it is not an invalid * sequence (ASCII character or more than one byte) and * utf_tolower() doesn't return the original character. */ - if ((c < 0x80 || ol > 1) && c != lc) + if ((c < 0x80 || olen > 1) && c != lc) { - int nl = utf_char2len(lc); + int nlen = utf_char2len(lc); /* If the byte length changes need to shift the following * characters forward or backward. */ - if (ol != nl) + if (olen != nlen) { - if (nl > ol) + if (nlen > olen) { - if (buf == NULL ? ga_grow(&ga, nl - ol + 1) == FAIL - : len + nl - ol >= buflen) + if (buf == NULL + ? ga_grow(&ga, nlen - olen + 1) == FAIL + : len + nlen - olen >= buflen) { /* out of memory, keep old char */ lc = c; - nl = ol; + nlen = olen; } } - if (ol != nl) + if (olen != nlen) { if (buf == NULL) { - STRMOVE(GA_PTR(i) + nl, GA_PTR(i) + ol); - ga.ga_len += nl - ol; + STRMOVE(GA_PTR(i) + nlen, GA_PTR(i) + olen); + ga.ga_len += nlen - olen; } else { - STRMOVE(buf + i + nl, buf + i + ol); - len += nl - ol; + STRMOVE(buf + i + nlen, buf + i + olen); + len += nlen - olen; } } } @@ -763,7 +764,7 @@ } /* - * Return the number of characters string "s" will take on the screen, + * Return the number of character cells string "s" will take on the screen, * counting TABs as two characters: "^I". */ int @@ -774,8 +775,8 @@ } /* - * Return the number of characters string "s[len]" will take on the screen, - * counting TABs as two characters: "^I". + * Return the number of character cells string "s[len]" will take on the + * screen, counting TABs as two characters: "^I". */ int vim_strnsize(s, len) @@ -1829,7 +1830,7 @@ hex = 0; /* can't be octal */ break; } - if (ptr[n] > '0') + if (ptr[n] >= '0') hex = '0'; /* assume octal */ } } diff -Naur vim73.orig/src/config.h.in vim73.patched/src/config.h.in --- vim73.orig/src/config.h.in 2010-08-13 08:45:27.000000000 -0500 +++ vim73.patched/src/config.h.in 2012-05-20 12:55:43.000000000 -0500 @@ -346,9 +346,15 @@ /* Define if dynamic python does not require RTLD_GLOBAL */ #undef PY_NO_RTLD_GLOBAL +/* Define if dynamic python3 does not require RTLD_GLOBAL */ +#undef PY3_NO_RTLD_GLOBAL + /* Define if you want to include the Ruby interpreter. */ #undef FEAT_RUBY +/* Define for linking via dlopen() or LoadLibrary() */ +#undef DYNAMIC_RUBY + /* Define if you want to include the Tcl interpreter. */ #undef FEAT_TCL @@ -357,6 +363,7 @@ /* Define if you want to add support for ACL */ #undef HAVE_POSIX_ACL +#undef HAVE_SOLARIS_ZFS_ACL #undef HAVE_SOLARIS_ACL #undef HAVE_AIX_ACL diff -Naur vim73.orig/src/config.mk.in vim73.patched/src/config.mk.in --- vim73.orig/src/config.mk.in 2010-07-17 10:28:51.000000000 -0500 +++ vim73.patched/src/config.mk.in 2012-05-20 12:55:06.000000000 -0500 @@ -30,6 +30,7 @@ CPP = @CPP@ CPP_MM = @CPP_MM@ DEPEND_CFLAGS_FILTER = @DEPEND_CFLAGS_FILTER@ +LINK_AS_NEEDED = @LINK_AS_NEEDED@ X_CFLAGS = @X_CFLAGS@ X_LIBS_DIR = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ diff -Naur vim73.orig/src/configure.in vim73.patched/src/configure.in --- vim73.orig/src/configure.in 2010-08-13 09:15:17.000000000 -0500 +++ vim73.patched/src/configure.in 2012-05-20 12:55:43.000000000 -0500 @@ -28,6 +28,16 @@ AC_HEADER_STDC AC_HEADER_SYS_WAIT +dnl Check for the flag that fails if stuff are missing. + +AC_MSG_CHECKING(--enable-fail-if-missing argument) +AC_ARG_ENABLE(fail_if_missing, + [ --enable-fail-if-missing Fail if dependencies on additional features + specified on the command line are missing.], + [fail_if_missing="yes"], + [fail_if_missing="no"]) +AC_MSG_RESULT($fail_if_missing) + dnl Set default value for CFLAGS if none is defined or it's empty if test -z "$CFLAGS"; then CFLAGS="-O" @@ -491,6 +501,9 @@ LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"liblua${vi_cv_version_lua}.so$LUA_SONAME\\\" $LUA_CFLAGS" fi fi + if test "$fail_if_missing" = "yes" -a -z "$LUA_SRC"; then + AC_MSG_ERROR([could not configure lua]) + fi AC_SUBST(LUA_SRC) AC_SUBST(LUA_OBJ) AC_SUBST(LUA_PRO) @@ -568,13 +581,27 @@ SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt else AC_MSG_RESULT(no) - AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/) - if test -f /usr/include/plt/scheme.h; then + AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket) + if test -f $vi_cv_path_mzscheme_pfx/include/racket/scheme.h; then AC_MSG_RESULT(yes) - SCHEME_INC=/usr/include/plt + SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket else AC_MSG_RESULT(no) - vi_cv_path_mzscheme_pfx= + AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/) + if test -f /usr/include/plt/scheme.h; then + AC_MSG_RESULT(yes) + SCHEME_INC=/usr/include/plt + else + AC_MSG_RESULT(no) + AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/) + if test -f /usr/include/racket/scheme.h; then + AC_MSG_RESULT(yes) + SCHEME_INC=/usr/include/racket + else + AC_MSG_RESULT(no) + vi_cv_path_mzscheme_pfx= + fi + fi fi fi fi @@ -586,13 +613,23 @@ elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a" MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" - elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"; then + elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"; then + MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.a"; then + MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a" + elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a"; then MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a" else dnl Using shared objects if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.so"; then MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme3m" MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.so"; then + MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket3m" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.so"; then + MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket -lmzgc" else MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc" fi @@ -607,10 +644,20 @@ fi if test -d $vi_cv_path_mzscheme_pfx/lib/plt/collects; then SCHEME_COLLECTS=lib/plt/ + else + if test -d $vi_cv_path_mzscheme_pfx/lib/racket/collects; then + SCHEME_COLLECTS=lib/racket/ + fi fi if test -f "${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects/scheme/base.ss" ; then - dnl need to generate bytecode for MzScheme base MZSCHEME_EXTRA="mzscheme_base.c" + else + if test -f "${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then + MZSCHEME_EXTRA="mzscheme_base.c" + fi + fi + if test "X$MZSCHEME_EXTRA" != "X" ; then + dnl need to generate bytecode for MzScheme base MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE" MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc" fi @@ -747,6 +794,10 @@ PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS" fi fi + + if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then + AC_MSG_ERROR([could not configure perl]) + fi fi AC_SUBST(shrpenv) AC_SUBST(PERL_SRC) @@ -857,9 +908,9 @@ PYTHON_LIBS="${vi_cv_path_python_plibs}" if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then - PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}" + PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\"" else - PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version}" + PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\"" fi PYTHON_SRC="if_python.c" dnl For Mac OSX 10.2 config.o is included in the Python library. @@ -871,7 +922,7 @@ if test "${vi_cv_var_python_version}" = "1.4"; then PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o" fi - PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'" + PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'" dnl On FreeBSD linking with "-pthread" is required to use threads. dnl _THREAD_SAFE must be used for compiling then. @@ -932,6 +983,10 @@ AC_MSG_RESULT(too old) fi fi + + if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then + AC_MSG_ERROR([could not configure python]) + fi fi AC_SUBST(PYTHON_CONFDIR) @@ -958,6 +1013,17 @@ ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'` ]]) + dnl -- get abiflags for python 3.2 or higher (PEP 3149) + AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags, + [ + vi_cv_var_python3_abiflags= + if ${vi_cv_path_python3} -c \ + "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)" + then + vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \ + "import sys; print(sys.abiflags)"` + fi ]) + dnl -- find where python3 thinks it was installed AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx, [ vi_cv_path_python3_pfx=` @@ -987,9 +1053,13 @@ AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf, [ vi_cv_path_python3_conf= + config_dir="config" + if test "${vi_cv_var_python3_abiflags}" != ""; then + config_dir="${config_dir}-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}" + fi for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do for subdir in lib64 lib share; do - d="${path}/${subdir}/python${vi_cv_var_python3_version}/config" + d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}" if test -d "$d" && test -f "$d/config.c"; then vi_cv_path_python3_conf="$d" fi @@ -1014,14 +1084,13 @@ @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'" @echo "python3_LIBS='$(LIBS)'" @echo "python3_SYSLIBS='$(SYSLIBS)'" - @echo "python3_LINKFORSHARED='$(LINKFORSHARED)'" @echo "python3_INSTSONAME='$(INSTSONAME)'" eof dnl -- delete the lines from make about Entering/Leaving directory eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`" rm -f -- "${tmp_mkf}" - vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}" - vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS} ${python3_LINKFORSHARED}" + vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}" + vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}" dnl remove -ltermcap, it can conflict with an earlier -lncurses vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//` vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//` @@ -1029,9 +1098,9 @@ PYTHON3_LIBS="${vi_cv_path_python3_plibs}" if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then - PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}" + PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" else - PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}" + PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\"" fi PYTHON3_SRC="if_python3.c" dnl For Mac OSX 10.2 config.o is included in the Python library. @@ -1109,11 +1178,12 @@ if test "$python_ok" = yes && test "$python3_ok" = yes; then AC_DEFINE(DYNAMIC_PYTHON) AC_DEFINE(DYNAMIC_PYTHON3) - AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL) + AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python) cflags_save=$CFLAGS - CFLAGS="$CFLAGS $PYTHON3_CFLAGS" + CFLAGS="$CFLAGS $PYTHON_CFLAGS" ldflags_save=$LDFLAGS - LDFLAGS="$LDFLAGS -ldl" + dnl -ldl must go first to make this work on Archlinux (Roland Puntaier) + LDFLAGS="-ldl $LDFLAGS" AC_RUN_IFELSE([ #include /* If this program fails, then RTLD_GLOBAL is needed. @@ -1122,15 +1192,17 @@ * Only the first pyhton version used will be switched on. */ - int no_rtl_global_needed_for(char *python_instsoname) + int no_rtl_global_needed_for(char *python_instsoname, char *prefix) { int needed = 0; void* pylib = dlopen(python_instsoname, RTLD_LAZY); if (pylib != 0) { + void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome"); void (*init)(void) = dlsym(pylib, "Py_Initialize"); int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString"); void (*final)(void) = dlsym(pylib, "Py_Finalize"); + (*pfx)(prefix); (*init)(); needed = (*simple)("import termios") == -1; (*final)(); @@ -1142,13 +1214,61 @@ int main(int argc, char** argv) { int not_needed = 0; - if (no_rtl_global_needed_for("libpython2.7.so.1.0") && no_rtl_global_needed_for("libpython3.1.so.1.0")) + if (no_rtl_global_needed_for("${python_INSTSONAME}", "${vi_cv_path_python_pfx}")) not_needed = 1; return !not_needed; }], [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)]) + CFLAGS=$cflags_save LDFLAGS=$ldflags_save + + AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3) + cflags_save=$CFLAGS + CFLAGS="$CFLAGS $PYTHON3_CFLAGS" + ldflags_save=$LDFLAGS + dnl -ldl must go first to make this work on Archlinux (Roland Puntaier) + LDFLAGS="-ldl $LDFLAGS" + AC_RUN_IFELSE([ + #include + #include + /* If this program fails, then RTLD_GLOBAL is needed. + * RTLD_GLOBAL will be used and then it is not possible to + * have both python versions enabled in the same vim instance. + * Only the first pyhton version used will be switched on. + */ + + int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix) + { + int needed = 0; + void* pylib = dlopen(python_instsoname, RTLD_LAZY); + if (pylib != 0) + { + void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome"); + void (*init)(void) = dlsym(pylib, "Py_Initialize"); + int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString"); + void (*final)(void) = dlsym(pylib, "Py_Finalize"); + (*pfx)(prefix); + (*init)(); + needed = (*simple)("import termios") == -1; + (*final)(); + dlclose(pylib); + } + return !needed; + } + + int main(int argc, char** argv) + { + int not_needed = 0; + if (no_rtl_global_needed_for("${python3_INSTSONAME}", L"${vi_cv_path_python3_pfx}")) + not_needed = 1; + return !not_needed; + }], + [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)]) + + CFLAGS=$cflags_save + LDFLAGS=$ldflags_save + PYTHON_SRC="if_python.c" PYTHON_OBJ="objects/if_python.o" PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\"" @@ -1290,6 +1410,9 @@ AC_MSG_RESULT(too old; need Tcl version 8.0 or later) fi fi + if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then + AC_MSG_ERROR([could not configure Tcl]) + fi fi AC_SUBST(TCL_SRC) AC_SUBST(TCL_OBJ) @@ -1299,15 +1422,15 @@ AC_MSG_CHECKING(--enable-rubyinterp argument) AC_ARG_ENABLE(rubyinterp, - [ --enable-rubyinterp Include Ruby interpreter.], , + [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], , [enable_rubyinterp="no"]) AC_MSG_RESULT($enable_rubyinterp) -if test "$enable_rubyinterp" = "yes"; then +if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then AC_MSG_CHECKING(--with-ruby-command argument) + AC_SUBST(vi_cv_path_ruby) AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)], - RUBY_CMD="$withval"; AC_MSG_RESULT($RUBY_CMD), + RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD), RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD)) - AC_SUBST(vi_cv_path_ruby) AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD) if test "X$vi_cv_path_ruby" != "X"; then AC_MSG_CHECKING(Ruby version) @@ -1329,18 +1452,15 @@ RUBY_LIBS="$rubylibs" fi librubyarg=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG[["LIBRUBYARG"]])'` - if test -f "$rubyhdrdir/$librubyarg"; then - librubyarg="$rubyhdrdir/$librubyarg" - else - rubylibdir=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG[["libdir"]])'` - if test -f "$rubylibdir/$librubyarg"; then - librubyarg="$rubylibdir/$librubyarg" - elif test "$librubyarg" = "libruby.a"; then - dnl required on Mac OS 10.3 where libruby.a doesn't exist - librubyarg="-lruby" - else - librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print '$librubyarg'.gsub(/-L\./, %'-L#{Config.expand(Config::CONFIG[\"libdir\"])}')"` - fi + librubya=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG[["LIBRUBY_A"]])'` + rubylibdir=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG[["libdir"]])'` + if test -f "$rubylibdir/$librubya"; then + librubyarg="$librubyarg" + RUBY_LIBS="$RUBY_LIBS -L$rubylibdir" + elif test "$librubyarg" = "libruby.a"; then + dnl required on Mac OS 10.3 where libruby.a doesn't exist + librubyarg="-lruby" + RUBY_LIBS="$RUBY_LIBS -L$rubylibdir" fi if test "X$librubyarg" != "X"; then @@ -1360,6 +1480,12 @@ RUBY_OBJ="objects/if_ruby.o" RUBY_PRO="if_ruby.pro" AC_DEFINE(FEAT_RUBY) + if test "$enable_rubyinterp" = "dynamic"; then + libruby=`$vi_cv_path_ruby -r rbconfig -e 'printf "lib%s.%s\n", Config::CONFIG[["RUBY_SO_NAME"]], Config::CONFIG[["DLEXT"]]'` + AC_DEFINE(DYNAMIC_RUBY) + RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS" + RUBY_LIBS= + fi else AC_MSG_RESULT(not found; disabling Ruby) fi @@ -1367,6 +1493,10 @@ AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later) fi fi + + if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then + AC_MSG_ERROR([could not configure Ruby]) + fi fi AC_SUBST(RUBY_SRC) AC_SUBST(RUBY_OBJ) @@ -2529,13 +2659,14 @@ AC_MSG_RESULT([empty: automatic terminal library selection]) dnl On HP-UX 10.10 termcap or termlib should be used instead of dnl curses, because curses is much slower. - dnl Newer versions of ncurses are preferred over anything. + dnl Newer versions of ncurses are preferred over anything, except + dnl when tinfo has been split off, it contains all we need. dnl Older versions of ncurses have bugs, get a new one! dnl Digital Unix (OSF1) should use curses (Ronald Schild). dnl On SCO Openserver should prefer termlib (Roger Cornelius). case "`uname -s 2>/dev/null`" in - OSF1|SCO_SV) tlibs="ncurses curses termlib termcap";; - *) tlibs="ncurses termlib termcap curses";; + OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";; + *) tlibs="tinfo ncurses termlib termcap curses";; esac for libname in $tlibs; do AC_CHECK_LIB(${libname}, tgetent,,) @@ -2975,6 +3106,7 @@ dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI dnl when -lacl works, also try to use -lattr (required for Debian). +dnl On Solaris, use the acl_get/set functions in libsec, if present. AC_MSG_CHECKING(--disable-acl argument) AC_ARG_ENABLE(acl, [ --disable-acl Don't check for ACL support.], @@ -2997,6 +3129,7 @@ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL), AC_MSG_RESULT(no)) +AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)], AC_MSG_CHECKING(for Solaris ACL support) AC_TRY_LINK([ #ifdef HAVE_SYS_ACL_H @@ -3004,7 +3137,7 @@ #endif], [acl("foo", GETACLCNT, 0, NULL); ], AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL), - AC_MSG_RESULT(no)) + AC_MSG_RESULT(no))) AC_MSG_CHECKING(for AIX ACL support) AC_TRY_LINK([ @@ -3180,7 +3313,7 @@ }], AC_MSG_RESULT(ok), AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]), -AC_MSG_ERROR([could not compile program using uint32_t.])) +AC_MSG_WARN([cannot check uint32_t when cross-compiling.])) dnl Check for memmove() before bcopy(), makes memmove() be used when both are dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5. @@ -3280,7 +3413,7 @@ AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,) dnl Check how we can run ctags. Default to "ctags" when nothing works. -dnl --version for Exuberant ctags (preferred) +dnl Use --version to detect Exuberant ctags (preferred) dnl Add --fields=+S to get function signatures for omni completion. dnl -t for typedefs (many ctags have this) dnl -s for static functions (Elvis ctags only?) @@ -3290,6 +3423,10 @@ test -f tags && mv tags tags.save if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then TAGPRG="ctags -I INIT+ --fields=+S" +elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then + TAGPRG="exctags -I INIT+ --fields=+S" +elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then + TAGPRG="exuberant-ctags -I INIT+ --fields=+S" else TAGPRG="ctags" (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags" @@ -3477,9 +3614,10 @@ dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is dnl declared as char x[1] but actually longer. Introduced in gcc 4.0. dnl Also remove duplicate _FORTIFY_SOURCE arguments. + dnl And undefine it first to avoid a warning. AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1) if test "$gccmajor" -gt "3"; then - CFLAGS=`echo "$CFLAGS" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/-D_FORTIFY_SOURCE=.//g' -e 's/$/ -D_FORTIFY_SOURCE=1/'` + CFLAGS=`echo "$CFLAGS" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/-D_FORTIFY_SOURCE=.//g' -e 's/$/ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1/'` AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) @@ -3487,6 +3625,23 @@ fi AC_SUBST(DEPEND_CFLAGS_FILTER) +dnl link.sh tries to avoid overlinking in a hackish way. +dnl At least GNU ld supports --as-needed which provides the same functionality +dnl at linker level. Let's use it. +AC_MSG_CHECKING(linker --as-needed support) +LINK_AS_NEEDED= +# Check if linker supports --as-needed and --no-as-needed options +if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then + LDFLAGS="$LDFLAGS -Wl,--as-needed" + LINK_AS_NEEDED=yes +fi +if test "$LINK_AS_NEEDED" = yes; then + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi +AC_SUBST(LINK_AS_NEEDED) + dnl write output files AC_OUTPUT(auto/config.mk:config.mk.in) diff -Naur vim73.orig/src/diff.c vim73.patched/src/diff.c --- vim73.orig/src/diff.c 2010-07-31 08:35:21.000000000 -0500 +++ vim73.patched/src/diff.c 2012-05-20 12:55:43.000000000 -0500 @@ -783,6 +783,15 @@ goto theend; } + /* :diffupdate! */ + if (eap != NULL && eap->forceit) + for (idx_new = idx_orig; idx_new < DB_COUNT; ++idx_new) + { + buf = curtab->tp_diffbuf[idx_new]; + if (buf_valid(buf)) + buf_check_timestamp(buf, FALSE); + } + /* Write the first buffer to a tempfile. */ buf = curtab->tp_diffbuf[idx_orig]; if (diff_write(buf, tmp_orig) == FAIL) @@ -1127,11 +1136,13 @@ # endif wp->w_p_diff = TRUE; + /* Use 'scrollbind' and 'cursorbind' when available */ +#ifdef FEAT_SCROLLBIND + wp->w_p_scb = TRUE; +#endif #ifdef FEAT_CURSORBIND - /* Use cursorbind if it's available */ wp->w_p_crb = TRUE; #endif - wp->w_p_scb = TRUE; wp->w_p_wrap = FALSE; # ifdef FEAT_FOLDING curwin = wp; @@ -1177,10 +1188,7 @@ { /* Set 'diff', 'scrollbind' off and 'wrap' on. */ wp->w_p_diff = FALSE; -#ifdef FEAT_CURSORBIND - wp->w_p_crb = FALSE; -#endif - wp->w_p_scb = FALSE; + RESET_BINDING(wp); wp->w_p_wrap = TRUE; #ifdef FEAT_FOLDING curwin = wp; diff -Naur vim73.orig/src/digraph.c vim73.patched/src/digraph.c --- vim73.orig/src/digraph.c 2010-05-15 06:04:09.000000000 -0500 +++ vim73.patched/src/digraph.c 2012-05-20 12:55:42.000000000 -0500 @@ -2080,13 +2080,13 @@ /* * Lookup the pair "char1", "char2" in the digraph tables. * If no match, return "char2". - * If "meta" is TRUE and "char1" is a space, return "char2" | 0x80. + * If "meta_char" is TRUE and "char1" is a space, return "char2" | 0x80. */ static int -getexactdigraph(char1, char2, meta) +getexactdigraph(char1, char2, meta_char) int char1; int char2; - int meta; + int meta_char; { int i; int retval = 0; @@ -2159,7 +2159,7 @@ if (retval == 0) /* digraph deleted or not found */ { - if (char1 == ' ' && meta) /* --> meta-char */ + if (char1 == ' ' && meta_char) /* --> meta-char */ return (char2 | 0x80); return char2; } @@ -2171,16 +2171,16 @@ * Allow for both char1-char2 and char2-char1 */ int -getdigraph(char1, char2, meta) +getdigraph(char1, char2, meta_char) int char1; int char2; - int meta; + int meta_char; { int retval; - if (((retval = getexactdigraph(char1, char2, meta)) == char2) + if (((retval = getexactdigraph(char1, char2, meta_char)) == char2) && (char1 != char2) - && ((retval = getexactdigraph(char2, char1, meta)) == char1)) + && ((retval = getexactdigraph(char2, char1, meta_char)) == char1)) return char2; return retval; } diff -Naur vim73.orig/src/edit.c vim73.patched/src/edit.c --- vim73.orig/src/edit.c 2010-08-08 07:55:05.000000000 -0500 +++ vim73.patched/src/edit.c 2012-05-20 12:55:43.000000000 -0500 @@ -58,6 +58,10 @@ }; static char e_hitend[] = N_("Hit end of paragraph"); +#ifdef FEAT_COMPL_FUNC +static char e_complwin[] = N_("E839: Completion function changed window"); +static char e_compldel[] = N_("E840: Completion function deleted text"); +#endif /* * Structure used to store one match for insert completion. @@ -131,6 +135,8 @@ static int compl_cont_mode = 0; static expand_T compl_xp; +static int compl_opt_refresh_always = FALSE; + static void ins_ctrl_x __ARGS((void)); static int has_compl_option __ARGS((int dict_opt)); static int ins_compl_accept_char __ARGS((int c)); @@ -149,16 +155,19 @@ static void ins_compl_free __ARGS((void)); static void ins_compl_clear __ARGS((void)); static int ins_compl_bs __ARGS((void)); +static int ins_compl_need_restart __ARGS((void)); static void ins_compl_new_leader __ARGS((void)); static void ins_compl_addleader __ARGS((int c)); -static int ins_compl_len __ARGS((void)); +static int ins_compl_len __ARGS((void)); static void ins_compl_restart __ARGS((void)); static void ins_compl_set_original_text __ARGS((char_u *str)); static void ins_compl_addfrommatch __ARGS((void)); static int ins_compl_prep __ARGS((int c)); +static void ins_compl_fixRedoBufForLeader __ARGS((char_u *ptr_arg)); static buf_T *ins_compl_next_buf __ARGS((buf_T *buf, int flag)); #if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL) static void ins_compl_add_list __ARGS((list_T *list)); +static void ins_compl_add_dict __ARGS((dict_T *dict)); #endif static int ins_compl_get_exp __ARGS((pos_T *ini)); static void ins_compl_delete __ARGS((void)); @@ -244,12 +253,14 @@ #ifdef FEAT_DIGRAPHS static int ins_digraph __ARGS((void)); #endif -static int ins_copychar __ARGS((linenr_T lnum)); static int ins_ctrl_ey __ARGS((int tc)); #ifdef FEAT_SMARTINDENT static void ins_try_si __ARGS((int c)); #endif static colnr_T get_nolist_virtcol __ARGS((void)); +#ifdef FEAT_AUTOCMD +static char_u *do_insert_char_pre __ARGS((int c)); +#endif static colnr_T Insstart_textlen; /* length of line when insert started */ static colnr_T Insstart_blank_vcol; /* vcol for first inserted blank */ @@ -775,7 +786,20 @@ * completion: Add to "compl_leader". */ if (ins_compl_accept_char(c)) { - ins_compl_addleader(c); +#ifdef FEAT_AUTOCMD + /* Trigger InsertCharPre. */ + char_u *str = do_insert_char_pre(c); + char_u *p; + + if (str != NULL) + { + for (p = str; *p != NUL; mb_ptr_adv(p)) + ins_compl_addleader(PTR2CHAR(p)); + vim_free(str); + } + else +#endif + ins_compl_addleader(c); continue; } @@ -1377,10 +1401,42 @@ goto do_intr; #endif +normalchar: /* * Insert a nomal character. */ -normalchar: +#ifdef FEAT_AUTOCMD + if (!p_paste) + { + /* Trigger InsertCharPre. */ + char_u *str = do_insert_char_pre(c); + char_u *p; + + if (str != NULL) + { + if (*str != NUL && stop_arrow() != FAIL) + { + /* Insert the new value of v:char literally. */ + for (p = str; *p != NUL; mb_ptr_adv(p)) + { + c = PTR2CHAR(p); + if (c == CAR || c == K_KENTER || c == NL) + ins_eol(c); + else + ins_char(c); + } + AppendToRedobuffLit(str, -1); + } + vim_free(str); + c = NUL; + } + + /* If the new value is already inserted or an empty string + * then don't insert any character. */ + if (c == NUL) + break; + } +#endif #ifdef FEAT_SMARTINDENT /* Try to perform smart-indenting. */ ins_try_si(c); @@ -1398,13 +1454,16 @@ Insstart_blank_vcol = get_nolist_virtcol(); } - if (vim_iswordc(c) || !echeck_abbr( + /* Insert a normal character and check for abbreviations on a + * special character. Let CTRL-] expand abbreviations without + * inserting it. */ + if (vim_iswordc(c) || (!echeck_abbr( #ifdef FEAT_MBYTE /* Add ABBR_OFF for characters above 0x100, this is * what check_abbr() expects. */ (has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : #endif - c)) + c) && c != Ctrl_RSB)) { insert_special(c, FALSE, FALSE); #ifdef FEAT_RIGHTLEFT @@ -1549,12 +1608,16 @@ ins_ctrl_v() { int c; + int did_putchar = FALSE; /* may need to redraw when no more chars available now */ ins_redraw(FALSE); if (redrawing() && !char_avail()) + { edit_putchar('^', TRUE); + did_putchar = TRUE; + } AppendToRedobuff((char_u *)CTRL_V_STR); /* CTRL-V */ #ifdef FEAT_CMDL_INFO @@ -1562,8 +1625,10 @@ #endif c = get_literal(); - edit_unputchar(); /* when line fits in 'columns' the '^' is at the start - of the next line and will not be redrawn */ + if (did_putchar) + /* when the line fits in 'columns' the '^' is at the start of the next + * line and will not removed by the redraw */ + edit_unputchar(); #ifdef FEAT_CMDL_INFO clear_showcmd(); #endif @@ -1713,9 +1778,9 @@ static void undisplay_dollar() { - if (dollar_vcol) + if (dollar_vcol >= 0) { - dollar_vcol = 0; + dollar_vcol = -1; redrawWinline(curwin->w_cursor.lnum, FALSE); } } @@ -2133,7 +2198,7 @@ || c == Ctrl_I || c == Ctrl_D || c == Ctrl_P || c == Ctrl_N || c == Ctrl_T || c == Ctrl_V || c == Ctrl_Q || c == Ctrl_U || c == Ctrl_O - || c == Ctrl_S || c == 's'); + || c == Ctrl_S || c == Ctrl_K || c == 's'); case CTRL_X_SCROLL: return (c == Ctrl_Y || c == Ctrl_E); case CTRL_X_WHOLE_LINE: @@ -2658,6 +2723,7 @@ if (stop_arrow() == FAIL) return; + compl_direction = FORWARD; if (startcol > curwin->w_cursor.col) startcol = curwin->w_cursor.col; compl_col = startcol; @@ -3295,7 +3361,7 @@ /* Deleted more than what was used to find matches or didn't finish * finding all matches: need to look for matches all over again. */ if (curwin->w_cursor.col <= compl_col + compl_length - || compl_was_interrupted) + || ins_compl_need_restart()) ins_compl_restart(); vim_free(compl_leader); @@ -3309,6 +3375,20 @@ } /* + * Return TRUE when we need to find matches again, ins_compl_restart() is to + * be called. + */ + static int +ins_compl_need_restart() +{ + /* Return TRUE if we didn't complete finding matches or when the + * 'completefunc' returned "always" in the "refresh" dictionary item. */ + return compl_was_interrupted + || ((ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OMNI) + && compl_opt_refresh_always); +} + +/* * Called after changing "compl_leader". * Show the popup menu with a different set of matches. * May also search for matches again if the previous search was interrupted. @@ -3397,14 +3477,20 @@ ins_char(c); /* If we didn't complete finding matches we must search again. */ - if (compl_was_interrupted) + if (ins_compl_need_restart()) ins_compl_restart(); - vim_free(compl_leader); - compl_leader = vim_strnsave(ml_get_curline() + compl_col, + /* When 'always' is set, don't reset compl_leader. While completing, + * cursor don't point original position, changing compl_leader would + * break redo. */ + if (!compl_opt_refresh_always) + { + vim_free(compl_leader); + compl_leader = vim_strnsave(ml_get_curline() + compl_col, (int)(curwin->w_cursor.col - compl_col)); - if (compl_leader != NULL) - ins_compl_new_leader(); + if (compl_leader != NULL) + ins_compl_new_leader(); + } } /* @@ -3480,11 +3566,7 @@ return; } p += len; -#ifdef FEAT_MBYTE - c = mb_ptr2char(p); -#else - c = *p; -#endif + c = PTR2CHAR(p); ins_compl_addleader(c); } @@ -3653,9 +3735,6 @@ * memory that was used, and make sure we can redo the insert. */ if (compl_curr_match != NULL || compl_leader != NULL || c == Ctrl_E) { - char_u *p; - int temp = 0; - /* * If any of the original typed text has been changed, eg when * ignorecase is set, we must add back-spaces to the redo @@ -3666,25 +3745,9 @@ */ if (compl_curr_match != NULL && compl_used_match && c != Ctrl_E) ptr = compl_curr_match->cp_str; - else if (compl_leader != NULL) - ptr = compl_leader; else - ptr = compl_orig_text; - if (compl_orig_text != NULL) - { - p = compl_orig_text; - for (temp = 0; p[temp] != NUL && p[temp] == ptr[temp]; - ++temp) - ; -#ifdef FEAT_MBYTE - if (temp > 0) - temp -= (*mb_head_off)(compl_orig_text, p + temp); -#endif - for (p += temp; *p != NUL; mb_ptr_adv(p)) - AppendCharToRedobuff(K_BS); - } - if (ptr != NULL) - AppendToRedobuffLit(ptr + temp, -1); + ptr = NULL; + ins_compl_fixRedoBufForLeader(ptr); } #ifdef FEAT_CINDENT @@ -3774,6 +3837,44 @@ } /* + * Fix the redo buffer for the completion leader replacing some of the typed + * text. This inserts backspaces and appends the changed text. + * "ptr" is the known leader text or NUL. + */ + static void +ins_compl_fixRedoBufForLeader(ptr_arg) + char_u *ptr_arg; +{ + int len; + char_u *p; + char_u *ptr = ptr_arg; + + if (ptr == NULL) + { + if (compl_leader != NULL) + ptr = compl_leader; + else + return; /* nothing to do */ + } + if (compl_orig_text != NULL) + { + p = compl_orig_text; + for (len = 0; p[len] != NUL && p[len] == ptr[len]; ++len) + ; +#ifdef FEAT_MBYTE + if (len > 0) + len -= (*mb_head_off)(p, p + len); +#endif + for (p += len; *p != NUL; mb_ptr_adv(p)) + AppendCharToRedobuff(K_BS); + } + else + len = 0; + if (ptr != NULL) + AppendToRedobuffLit(ptr + len, -1); +} + +/* * Loops through the list of windows, loaded-buffers or non-loaded-buffers * (depending on flag) starting from buf and looking for a non-scanned * buffer (other than curbuf). curbuf is special, if it is called with @@ -3829,10 +3930,14 @@ int type; /* CTRL_X_OMNI or CTRL_X_FUNCTION */ char_u *base; { - list_T *matchlist; + list_T *matchlist = NULL; + dict_T *matchdict = NULL; char_u *args[2]; char_u *funcname; pos_T pos; + win_T *curwin_save; + buf_T *curbuf_save; + typval_T rettv; funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu; if (*funcname == NUL) @@ -3843,13 +3948,50 @@ args[1] = base; pos = curwin->w_cursor; - matchlist = call_func_retlist(funcname, 2, args, FALSE); + curwin_save = curwin; + curbuf_save = curbuf; + + /* Call a function, which returns a list or dict. */ + if (call_vim_function(funcname, 2, args, FALSE, &rettv) == OK) + { + switch (rettv.v_type) + { + case VAR_LIST: + matchlist = rettv.vval.v_list; + break; + case VAR_DICT: + matchdict = rettv.vval.v_dict; + break; + default: + /* TODO: Give error message? */ + clear_tv(&rettv); + break; + } + } + + if (curwin_save != curwin || curbuf_save != curbuf) + { + EMSG(_(e_complwin)); + goto theend; + } curwin->w_cursor = pos; /* restore the cursor position */ - if (matchlist == NULL) - return; + check_cursor(); + if (!equalpos(curwin->w_cursor, pos)) + { + EMSG(_(e_compldel)); + goto theend; + } + + if (matchlist != NULL) + ins_compl_add_list(matchlist); + else if (matchdict != NULL) + ins_compl_add_dict(matchdict); - ins_compl_add_list(matchlist); - list_unref(matchlist); +theend: + if (matchdict != NULL) + dict_unref(matchdict); + if (matchlist != NULL) + list_unref(matchlist); } #endif /* FEAT_COMPL_FUNC */ @@ -3876,6 +4018,33 @@ } /* + * Add completions from a dict. + */ + static void +ins_compl_add_dict(dict) + dict_T *dict; +{ + dictitem_T *di_refresh; + dictitem_T *di_words; + + /* Check for optional "refresh" item. */ + compl_opt_refresh_always = FALSE; + di_refresh = dict_find(dict, (char_u *)"refresh", 7); + if (di_refresh != NULL && di_refresh->di_tv.v_type == VAR_STRING) + { + char_u *v = di_refresh->di_tv.vval.v_string; + + if (v != NULL && STRCMP(v, (char_u *)"always") == 0) + compl_opt_refresh_always = TRUE; + } + + /* Add completions from a "words" list. */ + di_words = dict_find(dict, (char_u *)"words", 5); + if (di_words != NULL && di_words->di_tv.v_type == VAR_LIST) + ins_compl_add_list(di_words->di_tv.vval.v_list); +} + +/* * Add a match to the list of matches from a typeval_T. * If the given string is already in the list of completions, then return * NOTDONE, otherwise add it to the list and return OK. If there is an error, @@ -3889,6 +4058,7 @@ char_u *word; int icase = FALSE; int adup = FALSE; + int aempty = FALSE; char_u *(cptext[CPT_COUNT]); if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL) @@ -3906,13 +4076,15 @@ icase = get_dict_number(tv->vval.v_dict, (char_u *)"icase"); if (get_dict_string(tv->vval.v_dict, (char_u *)"dup", FALSE) != NULL) adup = get_dict_number(tv->vval.v_dict, (char_u *)"dup"); + if (get_dict_string(tv->vval.v_dict, (char_u *)"empty", FALSE) != NULL) + aempty = get_dict_number(tv->vval.v_dict, (char_u *)"empty"); } else { word = get_tv_string_chk(tv); vim_memset(cptext, 0, sizeof(cptext)); } - if (word == NULL || *word == NUL) + if (word == NULL || (!aempty && *word == NUL)) return FAIL; return ins_compl_add(word, -1, icase, NULL, cptext, dir, 0, adup); } @@ -4403,6 +4575,11 @@ int found_end = FALSE; int advance; + /* When user complete function return -1 for findstart which is next + * time of 'always', compl_shown_match become NULL. */ + if (compl_shown_match == NULL) + return -1; + if (compl_leader != NULL && (compl_shown_match->cp_flags & ORIGINAL_TEXT) == 0) { @@ -4994,6 +5171,8 @@ int col; char_u *funcname; pos_T pos; + win_T *curwin_save; + buf_T *curbuf_save; /* Call 'completefunc' or 'omnifunc' and get pattern length as a * string */ @@ -5009,8 +5188,40 @@ args[0] = (char_u *)"1"; args[1] = NULL; pos = curwin->w_cursor; + curwin_save = curwin; + curbuf_save = curbuf; col = call_func_retnr(funcname, 2, args, FALSE); + if (curwin_save != curwin || curbuf_save != curbuf) + { + EMSG(_(e_complwin)); + return FAIL; + } curwin->w_cursor = pos; /* restore the cursor position */ + check_cursor(); + if (!equalpos(curwin->w_cursor, pos)) + { + EMSG(_(e_compldel)); + return FAIL; + } + + /* Return value -2 means the user complete function wants to + * cancel the complete without an error. + * Return value -3 does the same as -2 and leaves CTRL-X mode.*/ + if (col == -2) + return FAIL; + if (col == -3) + { + ctrl_x_mode = 0; + edit_submode = NULL; + msg_clr_cmdline(); + return FAIL; + } + + /* + * Reset extended parameters of completion, when start new + * completion. + */ + compl_opt_refresh_always = FALSE; if (col < 0) col = curs_col; @@ -5089,6 +5300,10 @@ else edit_submode = (char_u *)_(CTRL_X_MSG(ctrl_x_mode)); + /* If any of the original typed text has been changed we need to fix + * the redo buffer. */ + ins_compl_fixRedoBufForLeader(NULL); + /* Always add completion for the original text. */ vim_free(compl_orig_text); compl_orig_text = vim_strnsave(line + compl_col, compl_length); @@ -5249,7 +5464,7 @@ compl_curr_match->cp_number); edit_submode_extra = match_ref; edit_submode_highl = HLF_R; - if (dollar_vcol) + if (dollar_vcol >= 0) curs_columns(FALSE); } } @@ -5691,6 +5906,8 @@ * Don't do this when 'cindent' or 'indentexpr' is set, because we might * need to re-indent at a ':', or any other character (but not what * 'paste' is set).. + * Don't do this when there an InsertCharPre autocommand is defined, + * because we need to fire the event for every character. */ #ifdef USE_ON_FLY_SCROLL dont_scroll = FALSE; /* allow scrolling here */ @@ -5708,6 +5925,9 @@ #ifdef FEAT_RIGHTLEFT && !p_ri #endif +#ifdef FEAT_AUTOCMD + && !has_insertcharpre() +#endif ) { #define INPUT_BUFLEN 100 @@ -5902,6 +6122,7 @@ * Stop at first entered white when 'formatoptions' has 'v' */ while ((!fo_ins_blank && !has_format_option(FO_INS_VI)) + || (flags & INSCHAR_FORMAT) || curwin->w_cursor.lnum != Insstart.lnum || curwin->w_cursor.col >= Insstart.col) { @@ -8768,7 +8989,7 @@ * We can emulate the vi behaviour by pretending there is a dollar * displayed even when there isn't. * --pkv Sun Jan 19 01:56:40 EST 2003 */ - if (vim_strchr(p_cpo, CPO_BACKSPACE) != NULL && dollar_vcol == 0) + if (vim_strchr(p_cpo, CPO_BACKSPACE) != NULL && dollar_vcol == -1) dollar_vcol = curwin->w_virtcol; #ifdef FEAT_FOLDING @@ -9598,6 +9819,7 @@ { int c; int cc; + int did_putchar = FALSE; pc_status = PC_STATUS_UNSET; if (redrawing() && !char_avail()) @@ -9606,6 +9828,7 @@ ins_redraw(FALSE); edit_putchar('?', TRUE); + did_putchar = TRUE; #ifdef FEAT_CMDL_INFO add_to_showcmd_c(Ctrl_K); #endif @@ -9622,8 +9845,10 @@ c = plain_vgetc(); --no_mapping; --allow_keys; - edit_unputchar(); /* when line fits in 'columns' the '?' is at the start - of the next line and will not be redrawn */ + if (did_putchar) + /* when the line fits in 'columns' the '?' is at the start of the next + * line and will not be removed by the redraw */ + edit_unputchar(); if (IS_SPECIAL(c) || mod_mask) /* special key */ { @@ -9635,6 +9860,7 @@ } if (c != ESC) { + did_putchar = FALSE; if (redrawing() && !char_avail()) { /* may need to redraw when no more chars available now */ @@ -9642,11 +9868,9 @@ if (char2cells(c) == 1) { - /* first remove the '?', otherwise it's restored when typing - * an ESC next */ - edit_unputchar(); ins_redraw(FALSE); edit_putchar(c, TRUE); + did_putchar = TRUE; } #ifdef FEAT_CMDL_INFO add_to_showcmd_c(c); @@ -9657,8 +9881,10 @@ cc = plain_vgetc(); --no_mapping; --allow_keys; - edit_unputchar(); /* when line fits in 'columns' the '?' is at the - start of the next line and will not be redrawn */ + if (did_putchar) + /* when the line fits in 'columns' the '?' is at the start of the + * next line and will not be removed by a redraw */ + edit_unputchar(); if (cc != ESC) { AppendToRedobuff((char_u *)CTRL_V_STR); @@ -9680,7 +9906,7 @@ * Handle CTRL-E and CTRL-Y in Insert mode: copy char from other line. * Returns the char to be inserted, or NUL if none found. */ - static int + int ins_copychar(lnum) linenr_T lnum; { @@ -9870,3 +10096,38 @@ validate_virtcol(); return curwin->w_virtcol; } + +#ifdef FEAT_AUTOCMD +/* + * Handle the InsertCharPre autocommand. + * "c" is the character that was typed. + * Return a pointer to allocated memory with the replacement string. + * Return NULL to continue inserting "c". + */ + static char_u * +do_insert_char_pre(c) + int c; +{ + char_u *res; + + /* Return quickly when there is nothing to do. */ + if (!has_insertcharpre()) + return NULL; + + /* Lock the text to avoid weird things from happening. */ + ++textlock; + set_vim_var_char(c); /* set v:char */ + + if (apply_autocmds(EVENT_INSERTCHARPRE, NULL, NULL, FALSE, curbuf)) + /* Get the new value of v:char. It may be empty or more than one + * character. */ + res = vim_strsave(get_vim_var_str(VV_CHAR)); + else + res = NULL; + + set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */ + --textlock; + + return res; +} +#endif diff -Naur vim73.orig/src/eval.c vim73.patched/src/eval.c --- vim73.orig/src/eval.c 2010-08-09 15:12:14.000000000 -0500 +++ vim73.patched/src/eval.c 2012-05-20 12:55:43.000000000 -0500 @@ -10,9 +10,6 @@ /* * eval.c: Expression evaluation. */ -#if defined(MSDOS) || defined(WIN16) || defined(WIN32) || defined(_WIN64) -# include "vimio.h" /* for mch_open(), must be before vim.h */ -#endif #include "vim.h" @@ -355,13 +352,14 @@ {VV_NAME("swapname", VAR_STRING), VV_RO}, {VV_NAME("swapchoice", VAR_STRING), 0}, {VV_NAME("swapcommand", VAR_STRING), VV_RO}, - {VV_NAME("char", VAR_STRING), VV_RO}, + {VV_NAME("char", VAR_STRING), 0}, {VV_NAME("mouse_win", VAR_NUMBER), 0}, {VV_NAME("mouse_lnum", VAR_NUMBER), 0}, {VV_NAME("mouse_col", VAR_NUMBER), 0}, {VV_NAME("operator", VAR_STRING), VV_RO}, {VV_NAME("searchforward", VAR_NUMBER), 0}, {VV_NAME("oldfiles", VAR_LIST), 0}, + {VV_NAME("windowid", VAR_NUMBER), VV_RO}, }; /* shorthand */ @@ -382,9 +380,6 @@ static void prepare_vimvar __ARGS((int idx, typval_T *save_tv)); static void restore_vimvar __ARGS((int idx, typval_T *save_tv)); -#if defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL) -static int call_vim_function __ARGS((char_u *func, int argc, char_u **argv, int safe, typval_T *rettv)); -#endif static int ex_let_vars __ARGS((char_u *arg, typval_T *tv, int copy, int semicolon, int var_count, char_u *nextchars)); static char_u *skip_var_list __ARGS((char_u *arg, int *var_count, int *semicolon)); static char_u *skip_var_one __ARGS((char_u *arg)); @@ -433,9 +428,9 @@ static void listitem_free __ARGS((listitem_T *item)); static void listitem_remove __ARGS((list_T *l, listitem_T *item)); static long list_len __ARGS((list_T *l)); -static int list_equal __ARGS((list_T *l1, list_T *l2, int ic)); -static int dict_equal __ARGS((dict_T *d1, dict_T *d2, int ic)); -static int tv_equal __ARGS((typval_T *tv1, typval_T *tv2, int ic)); +static int list_equal __ARGS((list_T *l1, list_T *l2, int ic, int recursive)); +static int dict_equal __ARGS((dict_T *d1, dict_T *d2, int ic, int recursive)); +static int tv_equal __ARGS((typval_T *tv1, typval_T *tv2, int ic, int recursive)); static listitem_T *list_find __ARGS((list_T *l, long n)); static long list_find_nr __ARGS((list_T *l, long idx, int *errorp)); static long list_idx_of_item __ARGS((list_T *l, listitem_T *item)); @@ -447,13 +442,13 @@ static list_T *list_copy __ARGS((list_T *orig, int deep, int copyID)); static void list_remove __ARGS((list_T *l, listitem_T *item, listitem_T *item2)); static char_u *list2string __ARGS((typval_T *tv, int copyID)); +static int list_join_inner __ARGS((garray_T *gap, list_T *l, char_u *sep, int echo_style, int copyID, garray_T *join_gap)); static int list_join __ARGS((garray_T *gap, list_T *l, char_u *sep, int echo, int copyID)); static int free_unref_items __ARGS((int copyID)); static void set_ref_in_ht __ARGS((hashtab_T *ht, int copyID)); static void set_ref_in_list __ARGS((list_T *l, int copyID)); static void set_ref_in_item __ARGS((typval_T *tv, int copyID)); static int rettv_dict_alloc __ARGS((typval_T *rettv)); -static void dict_unref __ARGS((dict_T *d)); static void dict_free __ARGS((dict_T *d, int recurse)); static dictitem_T *dictitem_copy __ARGS((dictitem_T *org)); static void dictitem_remove __ARGS((dict_T *dict, dictitem_T *item)); @@ -480,6 +475,7 @@ static void f_acos __ARGS((typval_T *argvars, typval_T *rettv)); #endif static void f_add __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_and __ARGS((typval_T *argvars, typval_T *rettv)); static void f_append __ARGS((typval_T *argvars, typval_T *rettv)); static void f_argc __ARGS((typval_T *argvars, typval_T *rettv)); static void f_argidx __ARGS((typval_T *argvars, typval_T *rettv)); @@ -608,6 +604,7 @@ static void f_inputsave __ARGS((typval_T *argvars, typval_T *rettv)); static void f_inputsecret __ARGS((typval_T *argvars, typval_T *rettv)); static void f_insert __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_invert __ARGS((typval_T *argvars, typval_T *rettv)); static void f_isdirectory __ARGS((typval_T *argvars, typval_T *rettv)); static void f_islocked __ARGS((typval_T *argvars, typval_T *rettv)); static void f_items __ARGS((typval_T *argvars, typval_T *rettv)); @@ -625,6 +622,9 @@ static void f_log __ARGS((typval_T *argvars, typval_T *rettv)); static void f_log10 __ARGS((typval_T *argvars, typval_T *rettv)); #endif +#ifdef FEAT_LUA +static void f_luaeval __ARGS((typval_T *argvars, typval_T *rettv)); +#endif static void f_map __ARGS((typval_T *argvars, typval_T *rettv)); static void f_maparg __ARGS((typval_T *argvars, typval_T *rettv)); static void f_mapcheck __ARGS((typval_T *argvars, typval_T *rettv)); @@ -646,6 +646,7 @@ #endif static void f_nextnonblank __ARGS((typval_T *argvars, typval_T *rettv)); static void f_nr2char __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_or __ARGS((typval_T *argvars, typval_T *rettv)); static void f_pathshorten __ARGS((typval_T *argvars, typval_T *rettv)); #ifdef FEAT_FLOAT static void f_pow __ARGS((typval_T *argvars, typval_T *rettv)); @@ -757,6 +758,7 @@ static void f_winsaveview __ARGS((typval_T *argvars, typval_T *rettv)); static void f_winwidth __ARGS((typval_T *argvars, typval_T *rettv)); static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_xor __ARGS((typval_T *argvars, typval_T *rettv)); static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump)); static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum)); @@ -791,6 +793,8 @@ static void set_var __ARGS((char_u *name, typval_T *varp, int copy)); static int var_check_ro __ARGS((int flags, char_u *name)); static int var_check_fixed __ARGS((int flags, char_u *name)); +static int var_check_func_name __ARGS((char_u *name, int new_var)); +static int valid_varname __ARGS((char_u *varname)); static int tv_check_lock __ARGS((int lock, char_u *name)); static int item_copy __ARGS((typval_T *from, typval_T *to, int deep, int copyID)); static char_u *find_option_end __ARGS((char_u **arg, int *opt_flags)); @@ -853,6 +857,7 @@ init_var_dict(&globvardict, &globvars_var); init_var_dict(&vimvardict, &vimvars_var); + vimvardict.dv_lock = VAR_FIXED; hash_init(&compat_hashtab); hash_init(&func_hashtab); @@ -875,10 +880,11 @@ hash_add(&compat_hashtab, p->vv_di.di_key); } set_vim_var_nr(VV_SEARCHFORWARD, 1L); + set_reg_var(0); /* default for v:register is not 0 but '"' */ #ifdef EBCDIC /* - * Sort the function table, to enable binary sort. + * Sort the function table, to enable binary search. */ sortFunctions(); #endif @@ -910,6 +916,7 @@ hash_clear(&compat_hashtab); free_scriptnames(); + free_locales(); /* global variables */ vars_clear(&globvarht); @@ -1355,7 +1362,11 @@ { ga_init2(&ga, (int)sizeof(char), 80); if (tv.vval.v_list != NULL) + { list_join(&ga, tv.vval.v_list, (char_u *)"\n", TRUE, 0); + if (tv.vval.v_list->lv_len > 0) + ga_append(&ga, NL); + } ga_append(&ga, NUL); retval = (char_u *)ga.ga_data; } @@ -1557,7 +1568,7 @@ * arguments are currently supported. * Returns OK or FAIL. */ - static int + int call_vim_function(func, argc, argv, safe, rettv) char_u *func; int argc; @@ -2325,7 +2336,7 @@ else if (endchars != NULL && vim_strchr(endchars, *skipwhite(arg)) == NULL) EMSG(_(e_letunexp)); - else + else if (!check_secure()) { c1 = name[len]; name[len] = NUL; @@ -2718,8 +2729,27 @@ lp->ll_list = NULL; lp->ll_dict = lp->ll_tv->vval.v_dict; lp->ll_di = dict_find(lp->ll_dict, key, len); + + /* When assigning to g: check that a function and variable name is + * valid. */ + if (rettv != NULL && lp->ll_dict == &globvardict) + { + if (rettv->v_type == VAR_FUNC + && var_check_func_name(key, lp->ll_di == NULL)) + return NULL; + if (!valid_varname(key)) + return NULL; + } + if (lp->ll_di == NULL) { + /* Can't add "v:" variable. */ + if (lp->ll_dict == &vimvardict) + { + EMSG2(_(e_illvar), name); + return NULL; + } + /* Key does not exist in dict: may need to add it. */ if (*p == '[' || *p == '.' || unlet) { @@ -2739,6 +2769,10 @@ p = NULL; break; } + /* existing variable, need to check if it can be changed */ + else if (var_check_ro(lp->ll_di->di_flags, name)) + return NULL; + if (len == -1) clear_tv(&var1); lp->ll_tv = &lp->ll_di->di_tv; @@ -2770,6 +2804,8 @@ { if (lp->ll_range && !lp->ll_empty2) clear_tv(&var2); + if (!quiet) + EMSGN(_(e_listidx), lp->ll_n1); return NULL; } @@ -2787,7 +2823,11 @@ { ni = list_find(lp->ll_list, lp->ll_n2); if (ni == NULL) + { + if (!quiet) + EMSGN(_(e_listidx), lp->ll_n2); return NULL; + } lp->ll_n2 = list_idx_of_item(lp->ll_list, ni); } @@ -2795,7 +2835,11 @@ if (lp->ll_n1 < 0) lp->ll_n1 = list_idx_of_item(lp->ll_list, lp->ll_li); if (lp->ll_n2 < lp->ll_n1) + { + if (!quiet) + EMSGN(_(e_listidx), lp->ll_n2); return NULL; + } } lp->ll_tv = &lp->ll_li->li_tv; @@ -3337,6 +3381,18 @@ int failed = FALSE; funcdict_T fudi; + if (eap->skip) + { + /* trans_function_name() doesn't work well when skipping, use eval0() + * instead to skip to any following command, e.g. for: + * :if 0 | call dict.foo().bar() | endif */ + ++emsg_skip; + if (eval0(eap->arg, &rettv, &eap->nextcmd, FALSE) != FAIL) + clear_tv(&rettv); + --emsg_skip; + return; + } + tofree = trans_function_name(&arg, eap->skip, TFN_INT, &fudi); if (fudi.fd_newkey != NULL) { @@ -3386,6 +3442,9 @@ { curwin->w_cursor.lnum = lnum; curwin->w_cursor.col = 0; +#ifdef FEAT_VIRTUALEDIT + curwin->w_cursor.coladd = 0; +#endif } arg = startarg; if (get_func_tv(name, (int)STRLEN(name), &rettv, &arg, @@ -4349,7 +4408,8 @@ else { /* Compare two Lists for being equal or unequal. */ - n1 = list_equal(rettv->vval.v_list, var2.vval.v_list, ic); + n1 = list_equal(rettv->vval.v_list, var2.vval.v_list, + ic, FALSE); if (type == TYPE_NEQUAL) n1 = !n1; } @@ -4378,7 +4438,8 @@ else { /* Compare two Dictionaries for being equal or unequal. */ - n1 = dict_equal(rettv->vval.v_dict, var2.vval.v_dict, ic); + n1 = dict_equal(rettv->vval.v_dict, var2.vval.v_dict, + ic, FALSE); if (type == TYPE_NEQUAL) n1 = !n1; } @@ -5097,9 +5158,7 @@ else ret = OK; } - - if (alias != NULL) - vim_free(alias); + vim_free(alias); } *arg = skipwhite(*arg); @@ -5913,10 +5972,11 @@ * Return TRUE when two lists have exactly the same values. */ static int -list_equal(l1, l2, ic) +list_equal(l1, l2, ic, recursive) list_T *l1; list_T *l2; int ic; /* ignore case for strings */ + int recursive; /* TRUE when used recursively */ { listitem_T *item1, *item2; @@ -5930,7 +5990,7 @@ for (item1 = l1->lv_first, item2 = l2->lv_first; item1 != NULL && item2 != NULL; item1 = item1->li_next, item2 = item2->li_next) - if (!tv_equal(&item1->li_tv, &item2->li_tv, ic)) + if (!tv_equal(&item1->li_tv, &item2->li_tv, ic, recursive)) return FALSE; return item1 == NULL && item2 == NULL; } @@ -5952,10 +6012,11 @@ * Return TRUE when two dictionaries have exactly the same key/values. */ static int -dict_equal(d1, d2, ic) +dict_equal(d1, d2, ic, recursive) dict_T *d1; dict_T *d2; int ic; /* ignore case for strings */ + int recursive; /* TRUE when used recursively */ { hashitem_T *hi; dictitem_T *item2; @@ -5976,7 +6037,7 @@ item2 = dict_find(d2, hi->hi_key, -1); if (item2 == NULL) return FALSE; - if (!tv_equal(&HI2DI(hi)->di_tv, &item2->di_tv, ic)) + if (!tv_equal(&HI2DI(hi)->di_tv, &item2->di_tv, ic, recursive)) return FALSE; --todo; } @@ -5984,41 +6045,54 @@ return TRUE; } +static int tv_equal_recurse_limit; + /* * Return TRUE if "tv1" and "tv2" have the same value. * Compares the items just like "==" would compare them, but strings and * numbers are different. Floats and numbers are also different. */ static int -tv_equal(tv1, tv2, ic) +tv_equal(tv1, tv2, ic, recursive) typval_T *tv1; typval_T *tv2; - int ic; /* ignore case */ + int ic; /* ignore case */ + int recursive; /* TRUE when used recursively */ { char_u buf1[NUMBUFLEN], buf2[NUMBUFLEN]; char_u *s1, *s2; - static int recursive = 0; /* cach recursive loops */ + static int recursive_cnt = 0; /* catch recursive loops */ int r; if (tv1->v_type != tv2->v_type) return FALSE; + /* Catch lists and dicts that have an endless loop by limiting - * recursiveness to 1000. We guess they are equal then. */ - if (recursive >= 1000) + * recursiveness to a limit. We guess they are equal then. + * A fixed limit has the problem of still taking an awful long time. + * Reduce the limit every time running into it. That should work fine for + * deeply linked structures that are not recursively linked and catch + * recursiveness quickly. */ + if (!recursive) + tv_equal_recurse_limit = 1000; + if (recursive_cnt >= tv_equal_recurse_limit) + { + --tv_equal_recurse_limit; return TRUE; + } switch (tv1->v_type) { case VAR_LIST: - ++recursive; - r = list_equal(tv1->vval.v_list, tv2->vval.v_list, ic); - --recursive; + ++recursive_cnt; + r = list_equal(tv1->vval.v_list, tv2->vval.v_list, ic, TRUE); + --recursive_cnt; return r; case VAR_DICT: - ++recursive; - r = dict_equal(tv1->vval.v_dict, tv2->vval.v_dict, ic); - --recursive; + ++recursive_cnt; + r = dict_equal(tv1->vval.v_dict, tv2->vval.v_dict, ic, TRUE); + --recursive_cnt; return r; case VAR_FUNC: @@ -6502,47 +6576,119 @@ return (char_u *)ga.ga_data; } -/* - * Join list "l" into a string in "*gap", using separator "sep". - * When "echo" is TRUE use String as echoed, otherwise as inside a List. - * Return FAIL or OK. - */ +typedef struct join_S { + char_u *s; + char_u *tofree; +} join_T; + static int -list_join(gap, l, sep, echo, copyID) - garray_T *gap; +list_join_inner(gap, l, sep, echo_style, copyID, join_gap) + garray_T *gap; /* to store the result in */ list_T *l; char_u *sep; - int echo; + int echo_style; int copyID; + garray_T *join_gap; /* to keep each list item string */ { + int i; + join_T *p; + int len; + int sumlen = 0; int first = TRUE; char_u *tofree; char_u numbuf[NUMBUFLEN]; listitem_T *item; char_u *s; + /* Stringify each item in the list. */ for (item = l->lv_first; item != NULL && !got_int; item = item->li_next) { - if (first) - first = FALSE; - else - ga_concat(gap, sep); - - if (echo) + if (echo_style) s = echo_string(&item->li_tv, &tofree, numbuf, copyID); else s = tv2string(&item->li_tv, &tofree, numbuf, copyID); - if (s != NULL) - ga_concat(gap, s); - vim_free(tofree); if (s == NULL) return FAIL; + + len = (int)STRLEN(s); + sumlen += len; + + ga_grow(join_gap, 1); + p = ((join_T *)join_gap->ga_data) + (join_gap->ga_len++); + if (tofree != NULL || s != numbuf) + { + p->s = s; + p->tofree = tofree; + } + else + { + p->s = vim_strnsave(s, len); + p->tofree = p->s; + } + line_breakcheck(); } + + /* Allocate result buffer with its total size, avoid re-allocation and + * multiple copy operations. Add 2 for a tailing ']' and NUL. */ + if (join_gap->ga_len >= 2) + sumlen += (int)STRLEN(sep) * (join_gap->ga_len - 1); + if (ga_grow(gap, sumlen + 2) == FAIL) + return FAIL; + + for (i = 0; i < join_gap->ga_len && !got_int; ++i) + { + if (first) + first = FALSE; + else + ga_concat(gap, sep); + p = ((join_T *)join_gap->ga_data) + i; + + if (p->s != NULL) + ga_concat(gap, p->s); + line_breakcheck(); + } + return OK; } /* + * Join list "l" into a string in "*gap", using separator "sep". + * When "echo_style" is TRUE use String as echoed, otherwise as inside a List. + * Return FAIL or OK. + */ + static int +list_join(gap, l, sep, echo_style, copyID) + garray_T *gap; + list_T *l; + char_u *sep; + int echo_style; + int copyID; +{ + garray_T join_ga; + int retval; + join_T *p; + int i; + + ga_init2(&join_ga, (int)sizeof(join_T), l->lv_len); + retval = list_join_inner(gap, l, sep, echo_style, copyID, &join_ga); + + /* Dispose each item in join_ga. */ + if (join_ga.ga_data != NULL) + { + p = (join_T *)join_ga.ga_data; + for (i = 0; i < join_ga.ga_len; ++i) + { + vim_free(p->tofree); + ++p; + } + ga_clear(&join_ga); + } + + return retval; +} + +/* * Garbage collection for lists and dictionaries. * * We use reference counts to be able to free most items right away when they @@ -6635,6 +6781,10 @@ /* v: vars */ set_ref_in_ht(&vimvarht, copyID); +#ifdef FEAT_LUA + set_ref_in_lua(copyID); +#endif + /* * 2. Free lists and dictionaries that are not referenced. */ @@ -6837,7 +6987,7 @@ * Unreference a Dictionary: decrement the reference count and free it when it * becomes zero. */ - static void + void dict_unref(d) dict_T *d; { @@ -7075,7 +7225,7 @@ } /* - * Add a list entry to dictionary "d". + * Add a list entry to dictionary "d". * Returns FAIL when out of memory and when key already exists. */ int @@ -7097,6 +7247,7 @@ dictitem_free(item); return FAIL; } + ++list->lv_refcount; return OK; } @@ -7649,6 +7800,7 @@ {"acos", 1, 1, f_acos}, /* WJMc */ #endif {"add", 2, 2, f_add}, + {"and", 2, 2, f_and}, {"append", 2, 2, f_append}, {"argc", 0, 0, f_argc}, {"argidx", 0, 0, f_argidx}, @@ -7708,7 +7860,7 @@ #ifdef FEAT_FLOAT {"exp", 1, 1, f_exp}, #endif - {"expand", 1, 2, f_expand}, + {"expand", 1, 3, f_expand}, {"extend", 2, 3, f_extend}, {"feedkeys", 1, 2, f_feedkeys}, {"file_readable", 1, 1, f_filereadable}, /* obsolete */ @@ -7759,7 +7911,7 @@ {"getwinposx", 0, 0, f_getwinposx}, {"getwinposy", 0, 0, f_getwinposy}, {"getwinvar", 2, 2, f_getwinvar}, - {"glob", 1, 2, f_glob}, + {"glob", 1, 3, f_glob}, {"globpath", 2, 3, f_globpath}, {"has", 1, 1, f_has}, {"has_key", 2, 2, f_has_key}, @@ -7784,6 +7936,7 @@ {"inputsave", 0, 0, f_inputsave}, {"inputsecret", 1, 2, f_inputsecret}, {"insert", 2, 3, f_insert}, + {"invert", 1, 1, f_invert}, {"isdirectory", 1, 1, f_isdirectory}, {"islocked", 1, 1, f_islocked}, {"items", 1, 1, f_items}, @@ -7801,8 +7954,11 @@ {"log", 1, 1, f_log}, {"log10", 1, 1, f_log10}, #endif +#ifdef FEAT_LUA + {"luaeval", 1, 2, f_luaeval}, +#endif {"map", 2, 2, f_map}, - {"maparg", 1, 3, f_maparg}, + {"maparg", 1, 4, f_maparg}, {"mapcheck", 1, 3, f_mapcheck}, {"match", 2, 4, f_match}, {"matchadd", 2, 4, f_matchadd}, @@ -7822,6 +7978,7 @@ #endif {"nextnonblank", 1, 1, f_nextnonblank}, {"nr2char", 1, 1, f_nr2char}, + {"or", 2, 2, f_or}, {"pathshorten", 1, 1, f_pathshorten}, #ifdef FEAT_FLOAT {"pow", 2, 2, f_pow}, @@ -7870,7 +8027,7 @@ {"sin", 1, 1, f_sin}, {"sinh", 1, 1, f_sinh}, #endif - {"sort", 1, 2, f_sort}, + {"sort", 1, 3, f_sort}, {"soundfold", 1, 1, f_soundfold}, {"spellbadword", 0, 1, f_spellbadword}, {"spellsuggest", 1, 3, f_spellsuggest}, @@ -7933,6 +8090,7 @@ {"winsaveview", 0, 0, f_winsaveview}, {"winwidth", 1, 1, f_winwidth}, {"writefile", 2, 3, f_writefile}, + {"xor", 2, 2, f_xor}, }; #if defined(FEAT_CMDL_COMPL) || defined(PROTO) @@ -8497,7 +8655,7 @@ if (argvars[0].v_type == VAR_LIST) { if ((l = argvars[0].vval.v_list) != NULL - && !tv_check_lock(l->lv_lock, (char_u *)"add()") + && !tv_check_lock(l->lv_lock, (char_u *)_("add() argument")) && list_append_tv(l, &argvars[1]) == OK) copy_tv(&argvars[0], rettv); } @@ -8506,6 +8664,18 @@ } /* + * "and(expr, expr)" function + */ + static void +f_and(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + rettv->vval.v_number = get_tv_number_chk(&argvars[0], NULL) + & get_tv_number_chk(&argvars[1], NULL); +} + +/* * "append(lnum, string/list)" function */ static void @@ -9298,7 +9468,7 @@ if (!error) rettv->vval.v_number = do_dialog(type, NULL, message, buttons, - def, NULL); + def, NULL, FALSE); #endif } @@ -9389,7 +9559,7 @@ } for ( ; li != NULL; li = li->li_next) - if (tv_equal(&li->li_tv, &argvars[1], ic)) + if (tv_equal(&li->li_tv, &argvars[1], ic, FALSE)) ++n; } } @@ -9416,7 +9586,7 @@ if (!HASHITEM_EMPTY(hi)) { --todo; - if (tv_equal(&HI2DI(hi)->di_tv, &argvars[1], ic)) + if (tv_equal(&HI2DI(hi)->di_tv, &argvars[1], ic, FALSE)) ++n; } } @@ -9857,17 +10027,36 @@ char_u *s; int len; char_u *errormsg; - int flags = WILD_SILENT|WILD_USE_NL|WILD_LIST_NOTFOUND; + int options = WILD_SILENT|WILD_USE_NL|WILD_LIST_NOTFOUND; expand_T xpc; int error = FALSE; + char_u *result; rettv->v_type = VAR_STRING; + if (argvars[1].v_type != VAR_UNKNOWN + && argvars[2].v_type != VAR_UNKNOWN + && get_tv_number_chk(&argvars[2], &error) + && !error) + { + rettv->v_type = VAR_LIST; + rettv->vval.v_list = NULL; + } + s = get_tv_string(&argvars[0]); if (*s == '%' || *s == '#' || *s == '<') { ++emsg_off; - rettv->vval.v_string = eval_vars(s, s, &len, NULL, &errormsg, NULL); + result = eval_vars(s, s, &len, NULL, &errormsg, NULL); --emsg_off; + if (rettv->v_type == VAR_LIST) + { + if (rettv_list_alloc(rettv) != FAIL && result != NULL) + list_append_string(rettv->vval.v_list, result, -1); + else + vim_free(result); + } + else + rettv->vval.v_string = result; } else { @@ -9875,12 +10064,25 @@ * for 'wildignore' and don't put matches for 'suffixes' at the end. */ if (argvars[1].v_type != VAR_UNKNOWN && get_tv_number_chk(&argvars[1], &error)) - flags |= WILD_KEEP_ALL; + options |= WILD_KEEP_ALL; if (!error) { ExpandInit(&xpc); xpc.xp_context = EXPAND_FILES; - rettv->vval.v_string = ExpandOne(&xpc, s, NULL, flags, WILD_ALL); + if (p_wic) + options += WILD_ICASE; + if (rettv->v_type == VAR_STRING) + rettv->vval.v_string = ExpandOne(&xpc, s, NULL, + options, WILD_ALL); + else if (rettv_list_alloc(rettv) != FAIL) + { + int i; + + ExpandOne(&xpc, s, NULL, options, WILD_ALL_KEEP); + for (i = 0; i < xpc.xp_numfiles; i++) + list_append_string(rettv->vval.v_list, xpc.xp_files[i], -1); + ExpandCleanup(&xpc); + } } else rettv->vval.v_string = NULL; @@ -9896,6 +10098,8 @@ typval_T *argvars; typval_T *rettv; { + char *arg_errmsg = N_("extend() argument"); + if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_LIST) { list_T *l1, *l2; @@ -9905,7 +10109,7 @@ l1 = argvars[0].vval.v_list; l2 = argvars[1].vval.v_list; - if (l1 != NULL && !tv_check_lock(l1->lv_lock, (char_u *)"extend()") + if (l1 != NULL && !tv_check_lock(l1->lv_lock, (char_u *)_(arg_errmsg)) && l2 != NULL) { if (argvars[2].v_type != VAR_UNKNOWN) @@ -9944,7 +10148,7 @@ d1 = argvars[0].vval.v_dict; d2 = argvars[1].vval.v_dict; - if (d1 != NULL && !tv_check_lock(d1->dv_lock, (char_u *)"extend()") + if (d1 != NULL && !tv_check_lock(d1->dv_lock, (char_u *)_(arg_errmsg)) && d2 != NULL) { /* Check the third argument. */ @@ -9987,7 +10191,7 @@ EMSG2(_("E737: Key already exists: %s"), hi2->hi_key); break; } - else if (*action == 'f') + else if (*action == 'f' && HI2DI(hi2) != di1) { clear_tv(&di1->di_tv); copy_tv(&HI2DI(hi2)->di_tv, &di1->di_tv); @@ -10186,20 +10390,22 @@ typval_T save_key; int rem; int todo; - char_u *ermsg = map ? (char_u *)"map()" : (char_u *)"filter()"; + char_u *ermsg = (char_u *)(map ? "map()" : "filter()"); + char *arg_errmsg = (map ? N_("map() argument") + : N_("filter() argument")); int save_did_emsg; int idx = 0; if (argvars[0].v_type == VAR_LIST) { if ((l = argvars[0].vval.v_list) == NULL - || (map && tv_check_lock(l->lv_lock, ermsg))) + || tv_check_lock(l->lv_lock, (char_u *)_(arg_errmsg))) return; } else if (argvars[0].v_type == VAR_DICT) { if ((d = argvars[0].vval.v_dict) == NULL - || (map && tv_check_lock(d->dv_lock, ermsg))) + || tv_check_lock(d->dv_lock, (char_u *)_(arg_errmsg))) return; } else @@ -10236,7 +10442,8 @@ { --todo; di = HI2DI(hi); - if (tv_check_lock(di->di_tv.v_lock, ermsg)) + if (tv_check_lock(di->di_tv.v_lock, + (char_u *)_(arg_errmsg))) break; vimvars[VV_KEY].vv_str = vim_strsave(di->di_key); if (filter_map_one(&di->di_tv, expr, map, &rem) == FAIL @@ -10255,7 +10462,7 @@ for (li = l->lv_first; li != NULL; li = nli) { - if (tv_check_lock(li->li_tv.v_lock, ermsg)) + if (tv_check_lock(li->li_tv.v_lock, (char_u *)_(arg_errmsg))) break; nli = li->li_next; vimvars[VV_KEY].vv_nr = idx; @@ -10839,6 +11046,11 @@ if (*varname == '&') /* buffer-local-option */ get_option_tv(&varname, rettv, TRUE); + else if (STRCMP(varname, "changedtick") == 0) + { + rettv->v_type = VAR_NUMBER; + rettv->vval.v_number = curbuf->b_changedtick; + } else { if (*varname == NUL) @@ -11039,18 +11251,22 @@ typval_T *argvars UNUSED; typval_T *rettv; { - char_u cwd[MAXPATHL]; + char_u *cwd; rettv->v_type = VAR_STRING; - if (mch_dirname(cwd, MAXPATHL) == FAIL) - rettv->vval.v_string = NULL; - else + rettv->vval.v_string = NULL; + cwd = alloc(MAXPATHL); + if (cwd != NULL) { - rettv->vval.v_string = vim_strsave(cwd); + if (mch_dirname(cwd, MAXPATHL) != FAIL) + { + rettv->vval.v_string = vim_strsave(cwd); #ifdef BACKSLASH_IN_FILENAME - if (rettv->vval.v_string != NULL) - slash_adjust(rettv->vval.v_string); + if (rettv->vval.v_string != NULL) + slash_adjust(rettv->vval.v_string); #endif + } + vim_free(cwd); } } @@ -11653,22 +11869,44 @@ typval_T *argvars; typval_T *rettv; { - int flags = WILD_SILENT|WILD_USE_NL; + int options = WILD_SILENT|WILD_USE_NL; expand_T xpc; int error = FALSE; /* When the optional second argument is non-zero, don't remove matches - * for 'wildignore' and don't put matches for 'suffixes' at the end. */ - if (argvars[1].v_type != VAR_UNKNOWN - && get_tv_number_chk(&argvars[1], &error)) - flags |= WILD_KEEP_ALL; + * for 'wildignore' and don't put matches for 'suffixes' at the end. */ rettv->v_type = VAR_STRING; + if (argvars[1].v_type != VAR_UNKNOWN) + { + if (get_tv_number_chk(&argvars[1], &error)) + options |= WILD_KEEP_ALL; + if (argvars[2].v_type != VAR_UNKNOWN + && get_tv_number_chk(&argvars[2], &error)) + { + rettv->v_type = VAR_LIST; + rettv->vval.v_list = NULL; + } + } if (!error) { ExpandInit(&xpc); xpc.xp_context = EXPAND_FILES; - rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]), - NULL, flags, WILD_ALL); + if (p_wic) + options += WILD_ICASE; + if (rettv->v_type == VAR_STRING) + rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]), + NULL, options, WILD_ALL); + else if (rettv_list_alloc(rettv) != FAIL) + { + int i; + + ExpandOne(&xpc, get_tv_string(&argvars[0]), + NULL, options, WILD_ALL_KEEP); + for (i = 0; i < xpc.xp_numfiles; i++) + list_append_string(rettv->vval.v_list, xpc.xp_files[i], -1); + + ExpandCleanup(&xpc); + } } else rettv->vval.v_string = NULL; @@ -11741,9 +11979,6 @@ #ifdef __QNX__ "qnx", #endif -#ifdef RISCOS - "riscos", -#endif #ifdef UNIX "unix", #endif @@ -11856,7 +12091,7 @@ #ifdef FEAT_SEARCHPATH "file_in_path", #endif -#if defined(UNIX) && !defined(USE_SYSTEM) +#ifdef FEAT_FILTERPIPE "filterpipe", #endif #ifdef FEAT_FIND_ID @@ -12002,9 +12237,6 @@ #ifdef FEAT_OLE "ole", #endif -#ifdef FEAT_OSFILETYPE - "osfiletype", -#endif #ifdef FEAT_PATH_EXTRA "path_extra", #endif @@ -12116,6 +12348,9 @@ #ifdef FEAT_TOOLBAR "toolbar", #endif +#if defined(FEAT_CLIPBOARD) && defined(FEAT_X11) + "unnamedplus", +#endif #ifdef FEAT_USR_CMDS "user-commands", /* was accidentally included in 5.4 */ "user_commands", @@ -12159,6 +12394,9 @@ #ifdef FEAT_XFONTSET "xfontset", #endif +#ifdef FEAT_XPM_W32 + "xpm_w32", +#endif #ifdef USE_XSMP "xsmp", #endif @@ -12572,7 +12810,7 @@ } for ( ; item != NULL; item = item->li_next, ++idx) - if (tv_equal(&item->li_tv, &argvars[1], ic)) + if (tv_equal(&item->li_tv, &argvars[1], ic, FALSE)) { rettv->vval.v_number = idx; break; @@ -12712,7 +12950,7 @@ IObuff[0] = NUL; if (message != NULL && defstr != NULL && do_dialog(VIM_QUESTION, NULL, message, - (char_u *)_("&OK\n&Cancel"), 1, IObuff) == 1) + (char_u *)_("&OK\n&Cancel"), 1, IObuff, FALSE) == 1) rettv->vval.v_string = vim_strsave(IObuff); else { @@ -12850,7 +13088,7 @@ if (argvars[0].v_type != VAR_LIST) EMSG2(_(e_listarg), "insert()"); else if ((l = argvars[0].vval.v_list) != NULL - && !tv_check_lock(l->lv_lock, (char_u *)"insert()")) + && !tv_check_lock(l->lv_lock, (char_u *)_("insert() argument"))) { if (argvars[2].v_type != VAR_UNKNOWN) before = get_tv_number_chk(&argvars[2], &error); @@ -12877,6 +13115,17 @@ } /* + * "invert(expr)" function + */ + static void +f_invert(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + rettv->vval.v_number = ~get_tv_number_chk(&argvars[0], NULL); +} + +/* * "isdirectory()" function */ static void @@ -13290,8 +13539,10 @@ char_u *keys_buf = NULL; char_u *rhs; int mode; - garray_T ga; int abbr = FALSE; + int get_dict = FALSE; + mapblock_T *mp; + int buffer_local; /* return empty string for failure */ rettv->v_type = VAR_STRING; @@ -13305,7 +13556,11 @@ { which = get_tv_string_buf_chk(&argvars[1], buf); if (argvars[2].v_type != VAR_UNKNOWN) + { abbr = get_tv_number(&argvars[2]); + if (argvars[3].v_type != VAR_UNKNOWN) + get_dict = get_tv_number(&argvars[3]); + } } else which = (char_u *)""; @@ -13315,19 +13570,34 @@ mode = get_map_mode(&which, 0); keys = replace_termcodes(keys, &keys_buf, TRUE, TRUE, FALSE); - rhs = check_map(keys, mode, exact, FALSE, abbr); + rhs = check_map(keys, mode, exact, FALSE, abbr, &mp, &buffer_local); vim_free(keys_buf); - if (rhs != NULL) - { - ga_init(&ga); - ga.ga_itemsize = 1; - ga.ga_growsize = 40; - while (*rhs != NUL) - ga_concat(&ga, str2special(&rhs, FALSE)); + if (!get_dict) + { + /* Return a string. */ + if (rhs != NULL) + rettv->vval.v_string = str2special_save(rhs, FALSE); + + } + else if (rettv_dict_alloc(rettv) != FAIL && rhs != NULL) + { + /* Return a dictionary. */ + char_u *lhs = str2special_save(mp->m_keys, TRUE); + char_u *mapmode = map_mode_to_chars(mp->m_mode); + dict_T *dict = rettv->vval.v_dict; + + dict_add_nr_str(dict, "lhs", 0L, lhs); + dict_add_nr_str(dict, "rhs", 0L, mp->m_orig_str); + dict_add_nr_str(dict, "noremap", mp->m_noremap ? 1L : 0L , NULL); + dict_add_nr_str(dict, "expr", mp->m_expr ? 1L : 0L, NULL); + dict_add_nr_str(dict, "silent", mp->m_silent ? 1L : 0L, NULL); + dict_add_nr_str(dict, "sid", (long)mp->m_script_ID, NULL); + dict_add_nr_str(dict, "buffer", (long)buffer_local, NULL); + dict_add_nr_str(dict, "mode", 0L, mapmode); - ga_append(&ga, NUL); - rettv->vval.v_string = (char_u *)ga.ga_data; + vim_free(lhs); + vim_free(mapmode); } } @@ -13367,6 +13637,23 @@ } #endif +#ifdef FEAT_LUA +/* + * "luaeval()" function + */ + static void +f_luaeval(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + char_u *str; + char_u buf[NUMBUFLEN]; + + str = get_tv_string_buf(&argvars[0], buf); + do_luaeval(str, argvars + 1, rettv); +} +#endif + /* * "map()" function */ @@ -14006,6 +14293,18 @@ } /* + * "or(expr, expr)" function + */ + static void +f_or(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + rettv->vval.v_number = get_tv_number_chk(&argvars[0], NULL) + | get_tv_number_chk(&argvars[1], NULL); +} + +/* * "pathshorten()" function */ static void @@ -14177,22 +14476,19 @@ typval_T *rettv; { int binary = FALSE; + int failed = FALSE; char_u *fname; FILE *fd; - listitem_T *li; -#define FREAD_SIZE 200 /* optimized for text lines */ - char_u buf[FREAD_SIZE]; - int readlen; /* size of last fread() */ - int buflen; /* nr of valid chars in buf[] */ - int filtd; /* how much in buf[] was NUL -> '\n' filtered */ - int tolist; /* first byte in buf[] still to be put in list */ - int chop; /* how many CR to chop off */ - char_u *prev = NULL; /* previously read bytes, if any */ - int prevlen = 0; /* length of "prev" if not NULL */ - char_u *s; - int len; - long maxline = MAXLNUM; - long cnt = 0; + char_u buf[(IOSIZE/256)*256]; /* rounded to avoid odd + 1 */ + int io_size = sizeof(buf); + int readlen; /* size of last fread() */ + char_u *prev = NULL; /* previously read bytes, if any */ + long prevlen = 0; /* length of data in prev */ + long prevsize = 0; /* size of prev buffer */ + long maxline = MAXLNUM; + long cnt = 0; + char_u *p; /* position in buf */ + char_u *start; /* start of current line */ if (argvars[1].v_type != VAR_UNKNOWN) { @@ -14214,49 +14510,61 @@ return; } - filtd = 0; while (cnt < maxline || maxline < 0) { - readlen = (int)fread(buf + filtd, 1, FREAD_SIZE - filtd, fd); - buflen = filtd + readlen; - tolist = 0; - for ( ; filtd < buflen || readlen <= 0; ++filtd) - { - if (buf[filtd] == '\n' || readlen <= 0) - { - /* Only when in binary mode add an empty list item when the - * last line ends in a '\n'. */ - if (!binary && readlen == 0 && filtd == 0) - break; + readlen = (int)fread(buf, 1, io_size, fd); - /* Found end-of-line or end-of-file: add a text line to the - * list. */ - chop = 0; - if (!binary) - while (filtd - chop - 1 >= tolist - && buf[filtd - chop - 1] == '\r') - ++chop; - len = filtd - tolist - chop; - if (prev == NULL) - s = vim_strnsave(buf + tolist, len); + /* This for loop processes what was read, but is also entered at end + * of file so that either: + * - an incomplete line gets written + * - a "binary" file gets an empty line at the end if it ends in a + * newline. */ + for (p = buf, start = buf; + p < buf + readlen || (readlen <= 0 && (prevlen > 0 || binary)); + ++p) + { + if (*p == '\n' || readlen <= 0) + { + listitem_T *li; + char_u *s = NULL; + long_u len = p - start; + + /* Finished a line. Remove CRs before NL. */ + if (readlen > 0 && !binary) + { + while (len > 0 && start[len - 1] == '\r') + --len; + /* removal may cross back to the "prev" string */ + if (len == 0) + while (prevlen > 0 && prev[prevlen - 1] == '\r') + --prevlen; + } + if (prevlen == 0) + s = vim_strnsave(start, (int)len); else { - s = alloc((unsigned)(prevlen + len + 1)); - if (s != NULL) + /* Change "prev" buffer to be the right size. This way + * the bytes are only copied once, and very long lines are + * allocated only once. */ + if ((s = vim_realloc(prev, prevlen + len + 1)) != NULL) { - mch_memmove(s, prev, prevlen); - vim_free(prev); - prev = NULL; - mch_memmove(s + prevlen, buf + tolist, len); + mch_memmove(s + prevlen, start, len); s[prevlen + len] = NUL; + prev = NULL; /* the list will own the string */ + prevlen = prevsize = 0; } } - tolist = filtd + 1; + if (s == NULL) + { + do_outofmem_msg((long_u) prevlen + len + 1); + failed = TRUE; + break; + } - li = listitem_alloc(); - if (li == NULL) + if ((li = listitem_alloc()) == NULL) { vim_free(s); + failed = TRUE; break; } li->li_tv.v_type = VAR_STRING; @@ -14264,71 +14572,111 @@ li->li_tv.vval.v_string = s; list_append(rettv->vval.v_list, li); - if (++cnt >= maxline && maxline >= 0) - break; - if (readlen <= 0) + start = p + 1; /* step over newline */ + if ((++cnt >= maxline && maxline >= 0) || readlen <= 0) break; } - else if (buf[filtd] == NUL) - buf[filtd] = '\n'; + else if (*p == NUL) + *p = '\n'; #ifdef FEAT_MBYTE - else if (buf[filtd] == 0xef - && enc_utf8 - && filtd + 2 < buflen - && !binary - && buf[filtd + 1] == 0xbb - && buf[filtd + 2] == 0xbf) - { - /* remove utf-8 byte order mark */ - mch_memmove(buf + filtd, buf + filtd + 3, buflen - filtd - 3); - --filtd; - buflen -= 3; + /* Check for utf8 "bom"; U+FEFF is encoded as EF BB BF. Do this + * when finding the BF and check the previous two bytes. */ + else if (*p == 0xbf && enc_utf8 && !binary) + { + /* Find the two bytes before the 0xbf. If p is at buf, or buf + * + 1, these may be in the "prev" string. */ + char_u back1 = p >= buf + 1 ? p[-1] + : prevlen >= 1 ? prev[prevlen - 1] : NUL; + char_u back2 = p >= buf + 2 ? p[-2] + : p == buf + 1 && prevlen >= 1 ? prev[prevlen - 1] + : prevlen >= 2 ? prev[prevlen - 2] : NUL; + + if (back2 == 0xef && back1 == 0xbb) + { + char_u *dest = p - 2; + + /* Usually a BOM is at the beginning of a file, and so at + * the beginning of a line; then we can just step over it. + */ + if (start == dest) + start = p + 1; + else + { + /* have to shuffle buf to close gap */ + int adjust_prevlen = 0; + + if (dest < buf) + { + adjust_prevlen = (int)(buf - dest); /* must be 1 or 2 */ + dest = buf; + } + if (readlen > p - buf + 1) + mch_memmove(dest, p + 1, readlen - (p - buf) - 1); + readlen -= 3 - adjust_prevlen; + prevlen -= adjust_prevlen; + p = dest - 1; + } + } } #endif - } - if (readlen <= 0) - break; + } /* for */ - if (tolist == 0) + if (failed || (cnt >= maxline && maxline >= 0) || readlen <= 0) + break; + if (start < p) { - /* "buf" is full, need to move text to an allocated buffer */ - if (prev == NULL) + /* There's part of a line in buf, store it in "prev". */ + if (p - start + prevlen >= prevsize) { - prev = vim_strnsave(buf, buflen); - prevlen = buflen; - } - else - { - s = alloc((unsigned)(prevlen + buflen)); - if (s != NULL) + /* need bigger "prev" buffer */ + char_u *newprev; + + /* A common use case is ordinary text files and "prev" gets a + * fragment of a line, so the first allocation is made + * small, to avoid repeatedly 'allocing' large and + * 'reallocing' small. */ + if (prevsize == 0) + prevsize = (long)(p - start); + else + { + long grow50pc = (prevsize * 3) / 2; + long growmin = (long)((p - start) * 2 + prevlen); + prevsize = grow50pc > growmin ? grow50pc : growmin; + } + newprev = prev == NULL ? alloc(prevsize) + : vim_realloc(prev, prevsize); + if (newprev == NULL) { - mch_memmove(s, prev, prevlen); - mch_memmove(s + prevlen, buf, buflen); - vim_free(prev); - prev = s; - prevlen += buflen; + do_outofmem_msg((long_u)prevsize); + failed = TRUE; + break; } + prev = newprev; } - filtd = 0; - } - else - { - mch_memmove(buf, buf + tolist, buflen - tolist); - filtd -= tolist; + /* Add the line part to end of "prev". */ + mch_memmove(prev + prevlen, start, p - start); + prevlen += (long)(p - start); } - } + } /* while */ /* * For a negative line count use only the lines at the end of the file, * free the rest. */ - if (maxline < 0) + if (!failed && maxline < 0) while (cnt > -maxline) { listitem_remove(rettv->vval.v_list, rettv->vval.v_list->lv_first); --cnt; } + if (failed) + { + list_free(rettv->vval.v_list, TRUE); + /* readfile doc says an empty list is returned on error */ + rettv->vval.v_list = list_alloc(); + } + vim_free(prev); fclose(fd); } @@ -14691,13 +15039,14 @@ char_u *key; dict_T *d; dictitem_T *di; + char *arg_errmsg = N_("remove() argument"); if (argvars[0].v_type == VAR_DICT) { if (argvars[2].v_type != VAR_UNKNOWN) EMSG2(_(e_toomanyarg), "remove()"); else if ((d = argvars[0].vval.v_dict) != NULL - && !tv_check_lock(d->dv_lock, (char_u *)"remove() argument")) + && !tv_check_lock(d->dv_lock, (char_u *)_(arg_errmsg))) { key = get_tv_string_chk(&argvars[1]); if (key != NULL) @@ -14717,7 +15066,7 @@ else if (argvars[0].v_type != VAR_LIST) EMSG2(_(e_listdictarg), "remove()"); else if ((l = argvars[0].vval.v_list) != NULL - && !tv_check_lock(l->lv_lock, (char_u *)"remove() argument")) + && !tv_check_lock(l->lv_lock, (char_u *)_(arg_errmsg))) { int error = FALSE; @@ -14847,6 +15196,9 @@ typval_T *rettv; { char_u *p; +#ifdef HAVE_READLINK + char_u *buf = NULL; +#endif p = get_tv_string(&argvars[0]); #ifdef FEAT_SHORTCUT @@ -14862,7 +15214,6 @@ #else # ifdef HAVE_READLINK { - char_u buf[MAXPATHL + 1]; char_u *cpy; int len; char_u *remain = NULL; @@ -14879,7 +15230,10 @@ len = STRLEN(p); if (len > 0 && after_pathsep(p, p + len)) + { has_trailing_pathsep = TRUE; + p[len - 1] = NUL; /* the trailing slash breaks readlink() */ + } q = getnextcomp(p); if (*q != NUL) @@ -14890,6 +15244,10 @@ q[-1] = NUL; } + buf = alloc(MAXPATHL + 1); + if (buf == NULL) + goto fail; + for (;;) { for (;;) @@ -15033,6 +15391,7 @@ #ifdef HAVE_READLINK fail: + vim_free(buf); #endif rettv->v_type = VAR_STRING; } @@ -15051,7 +15410,7 @@ if (argvars[0].v_type != VAR_LIST) EMSG2(_(e_listarg), "reverse()"); else if ((l = argvars[0].vval.v_list) != NULL - && !tv_check_lock(l->lv_lock, (char_u *)"reverse()")) + && !tv_check_lock(l->lv_lock, (char_u *)_("reverse() argument"))) { li = l->lv_last; l->lv_first = l->lv_last = NULL; @@ -16256,6 +16615,7 @@ static int item_compare_ic; static char_u *item_compare_func; +static dict_T *item_compare_selfdict; static int item_compare_func_err; #define ITEM_COMPARE_FAIL 999 @@ -16315,7 +16675,8 @@ rettv.v_type = VAR_UNKNOWN; /* clear_tv() uses this */ res = call_func(item_compare_func, (int)STRLEN(item_compare_func), - &rettv, 2, argv, 0L, 0L, &dummy, TRUE, NULL); + &rettv, 2, argv, 0L, 0L, &dummy, TRUE, + item_compare_selfdict); clear_tv(&argv[0]); clear_tv(&argv[1]); @@ -16348,7 +16709,8 @@ else { l = argvars[0].vval.v_list; - if (l == NULL || tv_check_lock(l->lv_lock, (char_u *)"sort()")) + if (l == NULL || tv_check_lock(l->lv_lock, + (char_u *)_("sort() argument"))) return; rettv->vval.v_list = l; rettv->v_type = VAR_LIST; @@ -16360,8 +16722,10 @@ item_compare_ic = FALSE; item_compare_func = NULL; + item_compare_selfdict = NULL; if (argvars[1].v_type != VAR_UNKNOWN) { + /* optional second argument: {func} */ if (argvars[1].v_type == VAR_FUNC) item_compare_func = argvars[1].vval.v_string; else @@ -16376,6 +16740,17 @@ else item_compare_func = get_tv_string(&argvars[1]); } + + if (argvars[2].v_type != VAR_UNKNOWN) + { + /* optional third argument: {dict} */ + if (argvars[2].v_type != VAR_DICT) + { + EMSG(_(e_dictreq)); + return; + } + item_compare_selfdict = argvars[2].vval.v_dict; + } } /* Make an array with each entry pointing to an item in the List. */ @@ -17512,18 +17887,22 @@ typval_T *argvars UNUSED; typval_T *rettv; { - char_u fname[MAXPATHL + 1]; + char_u *fname; tagname_T tn; int first; if (rettv_list_alloc(rettv) == FAIL) return; + fname = alloc(MAXPATHL); + if (fname == NULL) + return; for (first = TRUE; ; first = FALSE) if (get_tagfname(&tn, first, fname) == FAIL || list_append_string(rettv->vval.v_list, fname, -1) == FAIL) break; tagname_free(&tn); + vim_free(fname); } /* @@ -17711,7 +18090,7 @@ typval_T *argvars; typval_T *rettv; { - char_u *instr; + char_u *in_str; char_u *fromstr; char_u *tostr; char_u *p; @@ -17728,7 +18107,7 @@ char_u buf2[NUMBUFLEN]; garray_T ga; - instr = get_tv_string(&argvars[0]); + in_str = get_tv_string(&argvars[0]); fromstr = get_tv_string_buf_chk(&argvars[1], buf); tostr = get_tv_string_buf_chk(&argvars[2], buf2); @@ -17754,19 +18133,19 @@ } /* fromstr and tostr have to contain the same number of chars */ - while (*instr != NUL) + while (*in_str != NUL) { #ifdef FEAT_MBYTE if (has_mbyte) { - inlen = (*mb_ptr2len)(instr); - cpstr = instr; + inlen = (*mb_ptr2len)(in_str); + cpstr = in_str; cpl