📄 eval.txt
字号:
*line2byte()*line2byte({lnum}) 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|. *localtime()*localtime() Return the current time, measured as seconds since 1st Jan 1970. See also |strftime()| and |getftime()|. *maparg()*maparg({name}[, {mode}]) Return the rhs of mapping {name} in mode {mode}. When there is no mapping for {name}, an empty String is returned. These characters can be used for {mode}: "n" Normal "v" Visual "o" Operator-pending "i" Insert "c" Cmd-line "" Normal, Visual and Operator-pending When {mode} is omitted, the modes from "" are used. 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. *mapcheck()*mapcheck({name}[, {mode}]) Check if there is a mapping that matches with {name} in mode {mode}. See |maparg()| for {mode} and special names in {name}. When there is no mapping that matches with {name}, and empty String is returned. If there is one, the rhs of that mapping is returned. If there are several matches, the rhs of one of them is returned. 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<CR>> endif The "_vv" mapping may conflict with a mapping for "_v" or for "_vvv". *match()*match({expr}, {pat}) The result is a Number, which gives the index in {expr} where {pat} matches. A match at the first character returns zero. If there is no match -1 is returned. Example:> :echo match("testing", "ing") results in "4". 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. *matchend()*matchend({expr}, {pat}) Same as match(), but return the index of first character after the match. Example:> :echo matchend("testing", "ing") results in "7". *matchstr()*matchstr({expr}, {pat}) Same as match(), but return the matched string. Example:> :echo matchstr("testing", "ing") results in "ing". When there is no match "" is returned. *nr2char()*nr2char({expr}) Return a string with a single chararacter, which has the ASCII value {expr}. Examples:> nr2char(64) returns "@"> nr2char(32) returns " "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. *setline()*setline({lnum}, {line}) Set line {lnum} of the current buffer to {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")) *strftime()*strftime({format} [, {time}]) 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()|. 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. *strlen()*strlen({expr}) The result is a Number, which is the length of the String {expr}. *strpart()*strpart({src}, {start}, {len}) The result is a String, which is part of {src}, starting from character {start}, with the length {len}. When non-existing characters are included, this doesn't result in an error, the characters are simply omitted.> strpart("abcdefg", 3, 2) == "de"> strpart("abcdefg", -2, 4) == "ab"> strpart("abcdefg", 5, 4) == "fg" Note: To get the first character, {start} must be 0. For example, to get three characters under and after the cursor:> strpart(getline(line(".")), col(".") - 1, 3) *strtrans()*strtrans({expr}) 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. *substitute()*substitute({expr}, {pat}, {sub}, {flags}) 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). 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 a literal "\n", 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()*synID({line}, {col}, {trans}) The result is a Number, which is the syntax ID at the position {line} 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, {line} is 1 for the first line. 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 (echos the name of the syntax item under the cursor):> :echo synIDattr(synID(line("."), col("."), 1), "name") *synIDattr()*synIDattr({synID}, {what} [, {mode}]) 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, cterm: color number as a string, term: empty string) "bg" background color (like "fg") "fg#" like "fg", but name in "#RRGGBB" form "bg#" like "bg", but name in "#RRGGBB" form "bold" "1" if bold "italic" "1" if italic "reverse" "1" if reverse "inverse" "1" if inverse (= reverse) "underline" "1" if underlined When the GUI is not running or the cterm mode is asked for, "fg#" is equal to "fg" and "bg#" is equal to "bg". Example (echos the color of the syntax item under the cursor):> :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg") *synIDtrans()*synIDtrans({synID}) 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. *system()*system({expr}) Get the output of the shell command {expr}. Note: newlines in {expr} may cause the command to fail. This is not to be used for interactive commands. The result is a String. To make the result more system-independent, the shell output is filtered to replace <CR> with <NL> for Macintosh, and <CR><NL> with <NL> for DOS-like systems. 'shellredir' is used to capture the output of the command. Depending on 'shell', you might be able to capture stdout with ">" and stdout plus stderr with ">&" (csh) or use "2>" to capture stderr (sh). The resulting error code can be found in |v:shell_error|. This function will fail in |restricted-mode|. *tempname()* *temp-file-name*tempname() 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 *visualmode()*visualmode() The result is a String, which describes the last Visual mode used. Initially it returns an empty string, but once Visual mode has been used, it returns "v", "V", or "<CTRL-V>" (a single CTRL-V character) for character-wise, line-wise, or block-wise Visual mode respecively. 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. *virtcol()*virtcol({expr}) 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 <Tab> at the position, the returned Number will be the column at the end of the <Tab>. For example, for a <Tab> in column 1, with 'ts' set to 8, it returns 8; The accepted positions are: . the cursor position '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("'t") with text " there", with 't at 'h', returns 6 The first column is 1. 0 is returned for an error. *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)) *winheight()*winheight({nr}) 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." *winnr()*winnr() The result is a Number, which is the number of the current window. The top window has number 1. *feature-list*There are two 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")all_builtin_terms Compiled with all builtin terminals enabled.amiga Amiga version of Vim.arp Compiled with ARP support (Amiga).autocmd Compiled with autocommands support.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.clipboard Compiled with 'clipboard' support.cmdline_compl Compiled with |cmdline-completion| 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.digraphs Compiled with support for digraphs.dos32 32 bits DOS (DJGPP) version of Vim.dos16 16 bits DOS version of Vim.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 |<cfile>|find_in_path Compiled with support for include file searches |+find_in_path|.fname_case Case in file names matters (for Amiga, MS-DOS, and Windows this is not present).fork Compiled to use fork()/exec() instead of system().gui Compiled with GUI enabled.gui_athena Compiled with Athena GUI.gui_beos Compiled with BeOs GUI.gui_gtk Compiled with GTK+ GUI.gui_mac Compiled with Macintosh GUI.gui_motif Compiled with Motif 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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -