2017-03-21 09:08:19 -07:00
|
|
|
*various.txt* Nvim
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
|
|
|
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
|
|
|
|
|
|
|
|
|
|
|
Various commands *various*
|
|
|
|
|
2017-10-20 17:33:58 -07:00
|
|
|
Type |gO| to see the table of contents.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
1. Various commands *various-cmds*
|
|
|
|
|
|
|
|
*CTRL-L*
|
2019-06-29 15:09:45 -07:00
|
|
|
CTRL-L Clears and redraws the screen. The redraw may happen
|
2014-07-10 21:05:51 -07:00
|
|
|
later, after processing typeahead.
|
2021-08-16 08:31:14 -07:00
|
|
|
*CTRL-L-default*
|
|
|
|
By default, also clears search highlighting
|
|
|
|
|:nohlsearch| and updates diffs |:diffupdate|.
|
|
|
|
|default-mappings|
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2019-06-29 15:09:45 -07:00
|
|
|
*:mod* *:mode*
|
|
|
|
:mod[e] Clears and redraws the screen.
|
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
*:redr* *:redraw*
|
2019-06-29 15:09:45 -07:00
|
|
|
:redr[aw][!] Redraws pending screen updates now, or the entire
|
|
|
|
screen if "!" is included. To CLEAR the screen use
|
|
|
|
|:mode| or |CTRL-L|.
|
|
|
|
Useful to update the screen during a script or
|
|
|
|
function (or a mapping if 'lazyredraw' set).
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*:redraws* *:redrawstatus*
|
2019-06-29 15:09:45 -07:00
|
|
|
:redraws[tatus][!] Redraws the status line of the current window, or all
|
|
|
|
status lines if "!" is included.
|
|
|
|
Useful if 'statusline' includes an item that doesn't
|
|
|
|
cause automatic updating.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2019-07-22 03:25:07 -07:00
|
|
|
*:redrawt* *:redrawtabline*
|
|
|
|
:redrawt[abline] Redraw the tabline. Useful to update the tabline when
|
|
|
|
'tabline' includes an item that doesn't trigger
|
|
|
|
automatic updating.
|
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
*N<Del>*
|
|
|
|
<Del> When entering a number: Remove the last digit.
|
|
|
|
Note: if you like to use <BS> for this, add this
|
2015-10-17 07:25:53 -07:00
|
|
|
mapping to your vimrc: >
|
2014-07-10 21:05:51 -07:00
|
|
|
:map CTRL-V <BS> CTRL-V <Del>
|
2015-04-23 22:32:28 -07:00
|
|
|
<
|
2014-07-10 21:05:51 -07:00
|
|
|
:as[cii] or *ga* *:as* *:ascii*
|
|
|
|
ga Print the ascii value of the character under the
|
2018-02-28 04:06:14 -07:00
|
|
|
cursor in decimal, hexadecimal and octal.
|
|
|
|
Mnemonic: Get Ascii value.
|
2021-01-04 12:10:34 -07:00
|
|
|
|
2018-02-28 04:06:14 -07:00
|
|
|
For example, when the cursor is on a 'R':
|
2014-07-10 21:05:51 -07:00
|
|
|
<R> 82, Hex 52, Octal 122 ~
|
|
|
|
When the character is a non-standard ASCII character,
|
|
|
|
but printable according to the 'isprint' option, the
|
2018-02-28 04:06:14 -07:00
|
|
|
non-printable version is also given.
|
2021-01-04 12:10:34 -07:00
|
|
|
|
2018-02-28 04:06:14 -07:00
|
|
|
When the character is larger than 127, the <M-x> form
|
|
|
|
is also printed. For example:
|
2014-07-10 21:05:51 -07:00
|
|
|
<~A> <M-^A> 129, Hex 81, Octal 201 ~
|
|
|
|
<p> <|~> <M-~> 254, Hex fe, Octal 376 ~
|
|
|
|
(where <p> is a special character)
|
2021-01-04 12:10:34 -07:00
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
The <Nul> character in a file is stored internally as
|
|
|
|
<NL>, but it will be shown as:
|
|
|
|
<^@> 0, Hex 00, Octal 000 ~
|
2021-01-04 12:10:34 -07:00
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
If the character has composing characters these are
|
|
|
|
also shown. The value of 'maxcombine' doesn't matter.
|
2021-01-04 12:10:34 -07:00
|
|
|
|
2018-02-28 04:06:14 -07:00
|
|
|
If the character can be inserted as a digraph, also
|
|
|
|
output the two characters that can be used to create
|
|
|
|
the character:
|
|
|
|
<ö> 246, Hex 00f6, Oct 366, Digr o: ~
|
|
|
|
This shows you can type CTRL-K o : to insert ö.
|
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*g8*
|
|
|
|
g8 Print the hex values of the bytes used in the
|
|
|
|
character under the cursor, assuming it is in |UTF-8|
|
|
|
|
encoding. This also shows composing characters. The
|
|
|
|
value of 'maxcombine' doesn't matter.
|
|
|
|
Example of a character with two composing characters:
|
|
|
|
e0 b8 81 + e0 b8 b9 + e0 b9 89 ~
|
|
|
|
|
|
|
|
*8g8*
|
|
|
|
8g8 Find an illegal UTF-8 byte sequence at or after the
|
|
|
|
cursor. This works in two situations:
|
|
|
|
1. when 'encoding' is any 8-bit encoding
|
|
|
|
2. when 'encoding' is "utf-8" and 'fileencoding' is
|
|
|
|
any 8-bit encoding
|
|
|
|
Thus it can be used when editing a file that was
|
|
|
|
supposed to be UTF-8 but was read as if it is an 8-bit
|
|
|
|
encoding because it contains illegal bytes.
|
|
|
|
Does not wrap around the end of the file.
|
|
|
|
Note that when the cursor is on an illegal byte or the
|
2021-04-29 18:13:43 -07:00
|
|
|
cursor is halfway through a multibyte character the
|
2015-01-19 23:21:14 -07:00
|
|
|
command won't move the cursor.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*:p* *:pr* *:print* *E749*
|
|
|
|
:[range]p[rint] [flags]
|
|
|
|
Print [range] lines (default current line).
|
|
|
|
Note: If you are looking for a way to print your text
|
|
|
|
on paper see |:hardcopy|. In the GUI you can use the
|
|
|
|
File.Print menu entry.
|
|
|
|
See |ex-flags| for [flags].
|
2017-04-28 11:42:06 -07:00
|
|
|
The |:filter| command can be used to only show lines
|
|
|
|
matching a pattern.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
:[range]p[rint] {count} [flags]
|
|
|
|
Print {count} lines, starting with [range] (default
|
|
|
|
current line |cmdline-ranges|).
|
|
|
|
See |ex-flags| for [flags].
|
|
|
|
|
|
|
|
*:l* *:list*
|
|
|
|
:[range]l[ist] [count] [flags]
|
|
|
|
Same as :print, but display unprintable characters
|
|
|
|
with '^' and put $ after the line. This can be
|
|
|
|
further changed with the 'listchars' option.
|
|
|
|
See |ex-flags| for [flags].
|
|
|
|
|
|
|
|
*:nu* *:number*
|
|
|
|
:[range]nu[mber] [count] [flags]
|
|
|
|
Same as :print, but precede each line with its line
|
2017-11-06 16:51:03 -07:00
|
|
|
number. (See also |hl-LineNr| and 'numberwidth').
|
2014-07-10 21:05:51 -07:00
|
|
|
See |ex-flags| for [flags].
|
|
|
|
|
|
|
|
*:#*
|
|
|
|
:[range]# [count] [flags]
|
|
|
|
synonym for :number.
|
|
|
|
|
|
|
|
*:#!*
|
|
|
|
:#!{anything} Ignored, so that you can start a Vim script with: >
|
|
|
|
#!vim -S
|
|
|
|
echo "this is a Vim script"
|
|
|
|
quit
|
|
|
|
<
|
|
|
|
*:z* *E144*
|
2021-05-01 16:03:43 -07:00
|
|
|
:[range]z[+-^.=][count] Display several lines of text surrounding the line
|
|
|
|
specified with [range], or around the current line
|
|
|
|
if there is no [range].
|
|
|
|
|
|
|
|
If there is a [count], that's how many lines you'll
|
|
|
|
see; if there is no [count] and only one window then
|
|
|
|
twice the value of the 'scroll' option is used,
|
|
|
|
otherwise the current window height minus 3 is used.
|
|
|
|
This is the value of "scr" in the table below.
|
|
|
|
|
|
|
|
If there is a [count] the 'window' option is set to
|
2014-07-10 21:05:51 -07:00
|
|
|
its value.
|
|
|
|
|
|
|
|
:z can be used either alone or followed by any of
|
2021-04-29 18:13:43 -07:00
|
|
|
several marks. These have the following effect:
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
mark first line last line new cursor line ~
|
|
|
|
---- ---------- --------- ------------
|
|
|
|
+ current line 1 scr forward 1 scr forward
|
|
|
|
- 1 scr back current line current line
|
|
|
|
^ 2 scr back 1 scr back 1 scr back
|
|
|
|
. 1/2 scr back 1/2 scr fwd 1/2 scr fwd
|
|
|
|
= 1/2 scr back 1/2 scr fwd current line
|
|
|
|
|
|
|
|
Specifying no mark at all is the same as "+".
|
|
|
|
If the mark is "=", a line of dashes is printed
|
|
|
|
around the current line.
|
|
|
|
|
2021-05-01 16:03:43 -07:00
|
|
|
:[range]z#[+-^.=][count] *:z#*
|
2014-07-10 21:05:51 -07:00
|
|
|
Like ":z", but number the lines.
|
|
|
|
{not in all versions of Vi, not with these arguments}
|
|
|
|
|
|
|
|
*:=*
|
|
|
|
:= [flags] Print the last line number.
|
|
|
|
See |ex-flags| for [flags].
|
|
|
|
|
|
|
|
:{range}= [flags] Prints the last line number in {range}. For example,
|
|
|
|
this prints the current line number: >
|
|
|
|
:.=
|
|
|
|
< See |ex-flags| for [flags].
|
|
|
|
|
|
|
|
:norm[al][!] {commands} *:norm* *:normal*
|
|
|
|
Execute Normal mode commands {commands}. This makes
|
|
|
|
it possible to execute Normal mode commands typed on
|
|
|
|
the command-line. {commands} are executed like they
|
|
|
|
are typed. For undo all commands are undone together.
|
|
|
|
Execution stops when an error is encountered.
|
|
|
|
|
|
|
|
If the [!] is given, mappings will not be used.
|
|
|
|
Without it, when this command is called from a
|
|
|
|
non-remappable mapping (|:noremap|), the argument can
|
|
|
|
be mapped anyway.
|
|
|
|
|
|
|
|
{commands} should be a complete command. If
|
|
|
|
{commands} does not finish a command, the last one
|
|
|
|
will be aborted as if <Esc> or <C-C> was typed.
|
|
|
|
This implies that an insert command must be completed
|
|
|
|
(to start Insert mode, see |:startinsert|). A ":"
|
|
|
|
command must be completed as well. And you can't use
|
|
|
|
"Q" or "gQ" to start Ex mode.
|
|
|
|
|
|
|
|
The display is not updated while ":normal" is busy.
|
|
|
|
|
|
|
|
{commands} cannot start with a space. Put a count of
|
|
|
|
1 (one) before it, "1 " is one space.
|
|
|
|
|
|
|
|
The 'insertmode' option is ignored for {commands}.
|
|
|
|
|
|
|
|
This command cannot be followed by another command,
|
|
|
|
since any '|' is considered part of the command.
|
|
|
|
|
|
|
|
This command can be used recursively, but the depth is
|
|
|
|
limited by 'maxmapdepth'.
|
|
|
|
|
|
|
|
An alternative is to use |:execute|, which uses an
|
|
|
|
expression as argument. This allows the use of
|
|
|
|
printable characters to represent special characters.
|
|
|
|
|
|
|
|
Example: >
|
|
|
|
:exe "normal \<c-w>\<c-w>"
|
2015-04-29 17:04:26 -07:00
|
|
|
<
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
:{range}norm[al][!] {commands} *:normal-range*
|
|
|
|
Execute Normal mode commands {commands} for each line
|
|
|
|
in the {range}. Before executing the {commands}, the
|
|
|
|
cursor is positioned in the first column of the range,
|
|
|
|
for each line. Otherwise it's the same as the
|
|
|
|
":normal" command without a range.
|
|
|
|
|
2014-10-05 10:32:24 -07:00
|
|
|
*:sh* *:shell* *E371* *E360*
|
2018-12-08 18:10:54 -07:00
|
|
|
:sh[ell] Removed. |vim-differences|
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2015-07-14 04:53:45 -07:00
|
|
|
*:terminal* *:te*
|
2018-12-08 17:49:59 -07:00
|
|
|
:te[rminal][!] [{cmd}] Run {cmd} in a non-interactive 'shell' in a new
|
|
|
|
|terminal-emulator| buffer. Without {cmd}, start an
|
|
|
|
interactive 'shell'.
|
2015-03-28 08:33:19 -07:00
|
|
|
|
2017-11-14 02:47:49 -07:00
|
|
|
Type |i| to enter |Terminal-mode|, then keys are sent to
|
|
|
|
the job running in the terminal. Type <C-\><C-N> to
|
|
|
|
leave Terminal-mode. |CTRL-\_CTRL-N|
|
2017-05-16 08:19:12 -07:00
|
|
|
|
2017-11-14 02:47:49 -07:00
|
|
|
Fails if changes have been made to the current buffer,
|
|
|
|
unless 'hidden' is set.
|
2017-05-16 08:19:12 -07:00
|
|
|
|
|
|
|
To enter |Terminal-mode| automatically: >
|
2017-11-14 02:47:49 -07:00
|
|
|
autocmd TermOpen * startinsert
|
2016-03-03 11:43:14 -07:00
|
|
|
<
|
2014-07-10 21:05:51 -07:00
|
|
|
*:!cmd* *:!* *E34*
|
2015-05-05 19:00:43 -07:00
|
|
|
:!{cmd} Execute {cmd} with 'shell'. See also |:terminal|.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2019-04-27 08:53:56 -07:00
|
|
|
The command runs in a non-interactive shell connected
|
|
|
|
to a pipe (not a terminal). Use |:terminal| to run an
|
|
|
|
interactive shell connected to a terminal.
|
|
|
|
|
|
|
|
Backgrounded ("&") commands must not write to stdout
|
|
|
|
or stderr, the streams are closed immediately. |E5677|
|
|
|
|
Use |jobstart()| instead. >
|
|
|
|
:call jobstart('foo', {'detach':1})
|
|
|
|
<
|
|
|
|
Any "!" in {cmd} is replaced with the previous
|
|
|
|
external command (see also 'cpoptions'), unless
|
|
|
|
escaped by a backslash. Example: ":!ls" followed by
|
2014-07-10 21:05:51 -07:00
|
|
|
":!echo ! \! \\!" executes "echo ls ! \!".
|
|
|
|
|
2019-04-27 08:53:56 -07:00
|
|
|
Any "|" in {cmd} is passed to the shell, you cannot
|
|
|
|
use it to append a Vim command. See |:bar|.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2019-04-27 08:53:56 -07:00
|
|
|
Any "%" in {cmd} is expanded to the current file name.
|
2021-04-28 05:39:30 -07:00
|
|
|
Any "#" in {cmd} is expanded to the alternate file name.
|
2019-04-27 08:53:56 -07:00
|
|
|
Special characters are not escaped, use quotes or
|
|
|
|
|shellescape()|: >
|
2014-07-10 21:05:51 -07:00
|
|
|
:!ls "%"
|
|
|
|
:exe "!ls " . shellescape(expand("%"))
|
|
|
|
<
|
2019-04-27 08:53:56 -07:00
|
|
|
Newline character ends {cmd} unless a backslash
|
|
|
|
precedes the newline. What follows is interpreted as
|
|
|
|
another |:| command.
|
2016-09-29 17:33:50 -07:00
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
After the command has been executed, the timestamp and
|
|
|
|
size of the current file is checked |timestamp|.
|
|
|
|
|
2016-10-07 04:18:24 -07:00
|
|
|
If the command produces too much output some lines may
|
|
|
|
be skipped so the command can execute quickly. No
|
|
|
|
data is lost, this only affects the display. The last
|
|
|
|
few lines are always displayed (never skipped).
|
2016-09-29 17:33:50 -07:00
|
|
|
|
2019-04-27 08:53:56 -07:00
|
|
|
To avoid the hit-enter prompt use: >
|
2014-07-10 21:05:51 -07:00
|
|
|
:silent !{cmd}
|
2019-04-27 08:53:56 -07:00
|
|
|
<
|
2014-07-10 21:05:51 -07:00
|
|
|
*:!!*
|
|
|
|
:!! Repeat last ":!{cmd}".
|
|
|
|
|
2019-08-01 21:44:48 -07:00
|
|
|
*:ve* *:ver* *:version*
|
2019-04-07 18:23:39 -07:00
|
|
|
:ve[rsion] Print editor version and build information.
|
|
|
|
See also |feature-compile|.
|
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
*:redi* *:redir*
|
|
|
|
:redi[r][!] > {file} Redirect messages to file {file}. The messages which
|
|
|
|
are the output of commands are written to that file,
|
|
|
|
until redirection ends. The messages are also still
|
|
|
|
shown on the screen. When [!] is included, an
|
|
|
|
existing file is overwritten. When [!] is omitted,
|
|
|
|
and {file} exists, this command fails.
|
2017-02-01 13:58:52 -07:00
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
Only one ":redir" can be active at a time. Calls to
|
|
|
|
":redir" will close any active redirection before
|
2017-02-01 13:58:52 -07:00
|
|
|
starting redirection to the new target. For recursive
|
|
|
|
use check out |execute()|.
|
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
To stop the messages and commands from being echoed to
|
|
|
|
the screen, put the commands in a function and call it
|
|
|
|
with ":silent call Function()".
|
2016-06-19 21:39:46 -07:00
|
|
|
Alternatives are the 'verbosefile' option or
|
2016-07-31 10:23:29 -07:00
|
|
|
|execute()| function, these can be used in combination
|
2016-06-19 21:39:46 -07:00
|
|
|
with ":redir".
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
:redi[r] >> {file} Redirect messages to file {file}. Append if {file}
|
2015-04-29 17:04:26 -07:00
|
|
|
already exists.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
:redi[r] @{a-zA-Z}
|
|
|
|
:redi[r] @{a-zA-Z}> Redirect messages to register {a-z}. Append to the
|
|
|
|
contents of the register if its name is given
|
|
|
|
uppercase {A-Z}. The ">" after the register name is
|
2015-04-29 17:04:26 -07:00
|
|
|
optional.
|
|
|
|
:redi[r] @{a-z}>> Append messages to register {a-z}.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2021-01-04 12:10:34 -07:00
|
|
|
:redi[r] @*>
|
2014-07-10 21:05:51 -07:00
|
|
|
:redi[r] @+> Redirect messages to the selection or clipboard. For
|
|
|
|
backward compatibility, the ">" after the register
|
|
|
|
name can be omitted. See |quotestar| and |quoteplus|.
|
2021-01-04 12:10:34 -07:00
|
|
|
:redi[r] @*>>
|
2014-07-10 21:05:51 -07:00
|
|
|
:redi[r] @+>> Append messages to the selection or clipboard.
|
|
|
|
|
|
|
|
:redi[r] @"> Redirect messages to the unnamed register. For
|
|
|
|
backward compatibility, the ">" after the register
|
2015-04-29 17:04:26 -07:00
|
|
|
name can be omitted.
|
|
|
|
:redi[r] @">> Append messages to the unnamed register.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
:redi[r] => {var} Redirect messages to a variable. If the variable
|
|
|
|
doesn't exist, then it is created. If the variable
|
|
|
|
exists, then it is initialized to an empty string.
|
|
|
|
The variable will remain empty until redirection ends.
|
|
|
|
Only string variables can be used. After the
|
|
|
|
redirection starts, if the variable is removed or
|
|
|
|
locked or the variable type is changed, then further
|
2015-04-29 17:04:26 -07:00
|
|
|
command output messages will cause errors.
|
2017-02-01 13:58:52 -07:00
|
|
|
To get the output of one command the |execute()|
|
2021-04-27 20:14:29 -07:00
|
|
|
function can be used instead of redirection.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
:redi[r] =>> {var} Append messages to an existing variable. Only string
|
2015-04-29 17:04:26 -07:00
|
|
|
variables can be used.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2015-04-29 17:04:26 -07:00
|
|
|
:redi[r] END End redirecting messages.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2017-04-28 11:42:06 -07:00
|
|
|
*:filt* *:filter*
|
|
|
|
:filt[er][!] {pat} {command}
|
|
|
|
:filt[er][!] /{pat}/ {command}
|
|
|
|
Restrict the output of {command} to lines matching
|
|
|
|
with {pat}. For example, to list only xml files: >
|
|
|
|
:filter /\.xml$/ oldfiles
|
|
|
|
< If the [!] is given, restrict the output of {command}
|
|
|
|
to lines that do NOT match {pat}.
|
|
|
|
|
|
|
|
{pat} is a Vim search pattern. Instead of enclosing
|
|
|
|
it in / any non-ID character (see |'isident'|) can be
|
|
|
|
used, so long as it does not appear in {pat}. Without
|
|
|
|
the enclosing character the pattern cannot include the
|
2021-05-02 07:24:39 -07:00
|
|
|
bar character. 'ignorecase' is not used.
|
2017-04-28 11:42:06 -07:00
|
|
|
|
|
|
|
The pattern is matched against the relevant part of
|
|
|
|
the output, not necessarily the whole line. Only some
|
|
|
|
commands support filtering, try it out to check if it
|
2019-07-01 11:02:48 -07:00
|
|
|
works. Some of the commands that support filtering:
|
2019-07-01 11:28:37 -07:00
|
|
|
|:#| - filter whole line
|
|
|
|
|:clist| - filter by file name or module name
|
|
|
|
|:command| - filter by command name
|
|
|
|
|:files| - filter by file name
|
|
|
|
|:highlight| - filter by highlight group
|
|
|
|
|:jumps| - filter by file name
|
|
|
|
|:let| - filter by variable name
|
|
|
|
|:list| - filter whole line
|
|
|
|
|:llist| - filter by file name or module name
|
|
|
|
|:marks| - filter by text in the current file,
|
|
|
|
or file name for other files
|
|
|
|
|:oldfiles| - filter by file name
|
|
|
|
|:set| - filter by variable name
|
2017-04-28 11:42:06 -07:00
|
|
|
|
|
|
|
Only normal messages are filtered, error messages are
|
|
|
|
not.
|
|
|
|
|
2016-06-07 09:06:20 -07:00
|
|
|
*:sil* *:silent* *:silent!*
|
2014-07-10 21:05:51 -07:00
|
|
|
:sil[ent][!] {command} Execute {command} silently. Normal messages will not
|
|
|
|
be given or added to the message history.
|
|
|
|
When [!] is added, error messages will also be
|
|
|
|
skipped, and commands and mappings will not be aborted
|
|
|
|
when an error is detected. |v:errmsg| is still set.
|
|
|
|
When [!] is not used, an error message will cause
|
|
|
|
further messages to be displayed normally.
|
|
|
|
Redirection, started with |:redir|, will continue as
|
|
|
|
usual, although there might be small differences.
|
|
|
|
This will allow redirecting the output of a command
|
|
|
|
without seeing it on the screen. Example: >
|
|
|
|
:redir >/tmp/foobar
|
|
|
|
:silent g/Aap/p
|
|
|
|
:redir END
|
|
|
|
< To execute a Normal mode command silently, use the
|
|
|
|
|:normal| command. For example, to search for a
|
|
|
|
string without messages: >
|
|
|
|
:silent exe "normal /path\<CR>"
|
|
|
|
< ":silent!" is useful to execute a command that may
|
|
|
|
fail, but the failure is to be ignored. Example: >
|
|
|
|
:let v:errmsg = ""
|
|
|
|
:silent! /^begin
|
|
|
|
:if v:errmsg != ""
|
|
|
|
: ... pattern was not found
|
2018-11-30 18:41:31 -07:00
|
|
|
< ":silent" also skips the hit-enter prompt.
|
|
|
|
Dialogs that prompt for user input (|confirm()|,
|
|
|
|
'swapfile', …) are never silent.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*:uns* *:unsilent*
|
|
|
|
:uns[ilent] {command} Execute {command} not silently. Only makes a
|
|
|
|
difference when |:silent| was used to get to this
|
|
|
|
command.
|
|
|
|
Use this for giving a message even when |:silent| was
|
|
|
|
used. In this example |:silent| is used to avoid the
|
|
|
|
message about reading the file and |:unsilent| to be
|
|
|
|
able to list the first line of each file. >
|
|
|
|
:silent argdo unsilent echo expand('%') . ": " . getline(1)
|
|
|
|
<
|
|
|
|
|
|
|
|
*:verb* *:verbose*
|
|
|
|
:[count]verb[ose] {command}
|
|
|
|
Execute {command} with 'verbose' set to [count]. If
|
|
|
|
[count] is omitted one is used. ":0verbose" can be
|
|
|
|
used to set 'verbose' to zero.
|
|
|
|
The additional use of ":silent" makes messages
|
|
|
|
generated but not displayed.
|
|
|
|
The combination of ":silent" and ":verbose" can be
|
|
|
|
used to generate messages and check them with
|
|
|
|
|v:statusmsg| and friends. For example: >
|
|
|
|
:let v:statusmsg = ""
|
|
|
|
:silent verbose runtime foobar.vim
|
|
|
|
:if v:statusmsg != ""
|
|
|
|
: " foobar.vim could not be found
|
|
|
|
:endif
|
|
|
|
< When concatenating another command, the ":verbose"
|
|
|
|
only applies to the first one: >
|
|
|
|
:4verbose set verbose | set verbose
|
|
|
|
< verbose=4 ~
|
|
|
|
verbose=0 ~
|
|
|
|
For logging verbose messages in a file use the
|
|
|
|
'verbosefile' option.
|
|
|
|
|
|
|
|
*:verbose-cmd*
|
|
|
|
When 'verbose' is non-zero, listing the value of a Vim option or a key map or
|
|
|
|
an abbreviation or a user-defined function or a command or a highlight group
|
|
|
|
or an autocommand will also display where it was last defined. If it was
|
|
|
|
defined manually then there will be no "Last set" message. When it was
|
|
|
|
defined while executing a function, user command or autocommand, the script in
|
|
|
|
which it was defined is reported.
|
|
|
|
|
|
|
|
*K*
|
2015-01-23 18:03:05 -07:00
|
|
|
[count]K Run a program to lookup the keyword under the
|
2014-07-10 21:05:51 -07:00
|
|
|
cursor. The name of the program is given with the
|
|
|
|
'keywordprg' (kp) option (default is "man"). The
|
|
|
|
keyword is formed of letters, numbers and the
|
|
|
|
characters in 'iskeyword'. The keyword under or
|
|
|
|
right of the cursor is used. The same can be done
|
|
|
|
with the command >
|
|
|
|
:!{program} {keyword}
|
2015-01-23 18:03:05 -07:00
|
|
|
< Special cases:
|
|
|
|
- If 'keywordprg' begins with ":" it is invoked as
|
|
|
|
a Vim command with [count].
|
2014-07-10 21:05:51 -07:00
|
|
|
- If 'keywordprg' is empty, the ":help" command is
|
|
|
|
used. It's a good idea to include more characters
|
|
|
|
in 'iskeyword' then, to be able to find more help.
|
2015-01-23 18:03:05 -07:00
|
|
|
- When 'keywordprg' is equal to "man", a [count]
|
|
|
|
before "K" is inserted after the "man" command and
|
|
|
|
before the keyword. For example, using "2K" while
|
|
|
|
the cursor is on "mkdir", results in: >
|
2014-07-10 21:05:51 -07:00
|
|
|
!man 2 mkdir
|
2015-01-23 18:03:05 -07:00
|
|
|
< - When 'keywordprg' is equal to "man -s", a [count]
|
2014-07-10 21:05:51 -07:00
|
|
|
before "K" is inserted after the "-s". If there is
|
|
|
|
no count, the "-s" is removed.
|
|
|
|
|
|
|
|
*v_K*
|
|
|
|
{Visual}K Like "K", but use the visually highlighted text for
|
|
|
|
the keyword. Only works when the highlighted text is
|
2015-04-29 17:04:26 -07:00
|
|
|
not more than one line.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2017-10-20 17:33:58 -07:00
|
|
|
*gO*
|
|
|
|
gO Show a filetype-specific, navigable "outline" of the
|
|
|
|
current buffer. For example, in a |help| buffer this
|
|
|
|
shows the table of contents.
|
|
|
|
|
|
|
|
Currently works in |help| and |:Man| buffers.
|
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
[N]gs *gs* *:sl* *:sleep*
|
2021-01-16 19:07:25 -07:00
|
|
|
:[N]sl[eep] [N][m] Do nothing for [N] seconds, or [N] milliseconds if [m]
|
2019-05-25 01:00:41 -07:00
|
|
|
was given. "gs" always uses seconds.
|
|
|
|
Default is one second. >
|
2014-07-10 21:05:51 -07:00
|
|
|
:sleep "sleep for one second
|
|
|
|
:5sleep "sleep for five seconds
|
2021-01-16 19:07:25 -07:00
|
|
|
:sleep 100m "sleep for 100 milliseconds
|
2014-07-10 21:05:51 -07:00
|
|
|
10gs "sleep for ten seconds
|
2019-05-25 01:00:41 -07:00
|
|
|
< Can be interrupted with CTRL-C.
|
2014-07-10 21:05:51 -07:00
|
|
|
"gs" stands for "goto sleep".
|
|
|
|
While sleeping the cursor is positioned in the text,
|
2015-04-29 17:04:26 -07:00
|
|
|
if at a visible position.
|
2019-05-25 01:00:41 -07:00
|
|
|
Queued messages are processed during the sleep.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2021-05-01 19:33:02 -07:00
|
|
|
*:sl!* *:sleep!*
|
2021-06-19 08:28:22 -07:00
|
|
|
:[N]sl[eep]! [N] [m] Same as above. Unlike Vim, it does not hide the
|
|
|
|
cursor. |vim-differences|
|
2021-05-01 19:33:02 -07:00
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
==============================================================================
|
|
|
|
2. Using Vim like less or more *less*
|
|
|
|
|
|
|
|
If you use the less or more program to view a file, you don't get syntax
|
|
|
|
highlighting. Thus you would like to use Vim instead. You can do this by
|
|
|
|
using the shell script "$VIMRUNTIME/macros/less.sh".
|
|
|
|
|
|
|
|
This shell script uses the Vim script "$VIMRUNTIME/macros/less.vim". It sets
|
|
|
|
up mappings to simulate the commands that less supports. Otherwise, you can
|
|
|
|
still use the Vim commands.
|
|
|
|
|
|
|
|
This isn't perfect. For example, when viewing a short file Vim will still use
|
2021-04-28 19:51:23 -07:00
|
|
|
the whole screen. But it works well enough for most uses, and you get syntax
|
2014-07-10 21:05:51 -07:00
|
|
|
highlighting.
|
|
|
|
|
|
|
|
The "h" key will give you a short overview of the available commands.
|
|
|
|
|
2016-05-03 12:06:03 -07:00
|
|
|
If you want to set options differently when using less, define the
|
|
|
|
LessInitFunc in your vimrc, for example: >
|
|
|
|
|
|
|
|
func LessInitFunc()
|
|
|
|
set nocursorcolumn nocursorline
|
|
|
|
endfunc
|
|
|
|
<
|
|
|
|
|
2017-10-20 17:33:58 -07:00
|
|
|
vim:noet:tw=78:ts=8:ft=help:norl:
|