aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/various.txt
blob: 1ded5154a7d80e7cc249cb9c8f7a1d02b6fcf24f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
*various.txt*   Nvim


		  VIM REFERENCE MANUAL    by Bram Moolenaar


Various commands					*various*

                                      Type |gO| to see the table of contents.

==============================================================================
1. Various commands					*various-cmds*

							*CTRL-L*
CTRL-L			Clears and redraws the screen.  The redraw may happen
			later, after processing typeahead.
			See also |nvim__redraw()|.
							*CTRL-L-default*
			By default, also clears search highlighting
			|:nohlsearch| and updates diffs |:diffupdate|.
			|default-mappings|

							*:mod* *:mode*
:mod[e]			Clears and redraws the screen.
			See also |nvim__redraw()|.

							*:redr* *:redraw*
:redr[aw][!]		Redraws pending screen updates now, or the entire
			screen if "!" is included.  To CLEAR the screen use
			|:mode| or |CTRL-L|.
			It can be used to redraw the screen in a script
			or function (or a mapping if |'lazyredraw'| is set).
			See also |nvim__redraw()|.

						*:redraws* *:redrawstatus*
:redraws[tatus][!]	Redraws the status line and window bar of the current
			window, or all status lines and window bars if "!" is
			included. Redraws the commandline instead if it contains
			the 'ruler'. Useful if 'statusline' or 'winbar' includes
			an item that doesn't cause automatic updating.
			See also |nvim__redraw()|.

						*:redrawt* *:redrawtabline*
:redrawt[abline]	Redraw the tabline.  Useful to update the tabline when
			'tabline' includes an item that doesn't trigger
			automatic updating. See also |nvim__redraw()|.

							*N<Del>*
<Del>			When entering a number: Remove the last digit.
			Note: if you like to use <BS> for this, add this
			mapping to your vimrc: >
				:map CTRL-V <BS>   CTRL-V <Del>
<
:as[cii]	or					*ga* *:as* *:ascii*
ga			Print the ascii value of the character under the
			cursor in decimal, hexadecimal and octal.
			Mnemonic: Get Ascii value.

			For example, when the cursor is on a 'R':
				<R>  82,  Hex 52,  Octal 122 ~
			When the character is a non-standard ASCII character,
			but printable according to the 'isprint' option, the
			non-printable version is also given.

			When the character is larger than 127, the <M-x> form
			is also printed.  For example:
				<~A>  <M-^A>  129,  Hex 81,  Octal 201 ~
				<p>  <|~>  <M-~>  254,  Hex fe,  Octal 376 ~
			(where <p> is a special character)

			The <Nul> character in a file is stored internally as
			<NL>, but it will be shown as:
				<^@>  0,  Hex 00,  Octal 000 ~

			If the character has composing characters these are
			also shown.  The value of 'maxcombine' doesn't matter.

			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 ö.

							*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.
			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
			cursor is halfway through a multibyte character the
			command won't move the cursor.

							*gx*
gx			Opens the current filepath or URL (decided by
			|<cfile>|, 'isfname') at cursor using the system
			default handler, by calling |vim.ui.open()|.

							*v_gx*
{Visual}gx		Opens the selected text using the system default
			handler, by calling |vim.ui.open()|.

						*:p* *:pr* *:print* *E749*
:[range]p[rint] [flags]
			Print [range] lines (default current line).
			In the GUI you can use the File.Print menu entry.
			See |ex-flags| for [flags].
			The |:filter| command can be used to only show lines
			matching a pattern.

:[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 show tabs as ">", trailing spaces
			as "-", and non-breakable space characters as "+" by
			default.  Further changed by 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
			number.  (See also |hl-LineNr| and 'numberwidth').
			See |ex-flags| for [flags].

							*:#*
:[range]# [count] [flags]
			synonym for :number.

							*:#!* *vim-shebang*
:#!{anything}		Ignored, so that you can start a Vim script with: >
				#!vim -S
				let mylogbook='$HOME/logbook.md'
				exe $':e {mylogbook}'
				$
				put ='## ' .. strftime('%d. %b %Y')
				norm! o
<
			Make that script executable and run it to create a
			new diary entry.

							*:z* *E144*
:[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
			its value.

			:z can be used either alone or followed by any of
			several marks.  These have the following effect:

			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.

							*:z!*
:[range]z![+-^.=][count]
			Like ":z", but when [count] is not specified, it
			defaults to the Vim window height minus one.

:[range]z[!]#[+-^.=][count]				*:z#*
			Like ":z" or ":z!", but number the lines.

							*:=*
:= [args]		Without [args]: prints the last line number.
			With [args]: equivalent to `:lua ={expr}`. see |:lua|

:{range}=		Prints the last line number in {range}.  For example,
			this prints the current line number: >
				:.=

: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
			"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.

			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>"
<

:{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.

						  *:sh* *:shell* *E371* *E360*
:sh[ell]		Removed. |vim-differences|

						  *:terminal* *:te*
:te[rminal][!] [{cmd}]	Run {cmd} in a non-interactive 'shell' in a new
			|terminal-emulator| buffer. Without {cmd}, start an
			interactive 'shell'.

			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|. Type <C-\><C-O>
			to execute a single normal mode command |t_CTRL-\_CTRL-O|

			Fails if changes have been made to the current buffer,
			unless 'hidden' is set.

			If {cmd} is omitted, and the 'shell' job exits with no
			error, the buffer is closed automatically
			|default-autocmds|.

			To enter |Terminal-mode| automatically: >
			      autocmd TermOpen * startinsert
<
							*:!cmd* *:!*
:!{cmd}			Execute {cmd} with 'shell'. See also |:terminal|.
			For the filter command, see |:range!|.

			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})
<
			For powershell, chaining a stringed executable path
			requires using the call operator (&). >
				:!Write-Output "1`n2" | & "C:\Windows\System32\sort.exe" /r
<
							*E34*
			Any "!" in {cmd} is replaced with the previous
			external command (see also 'cpoptions'), unless
			escaped by a backslash.  Example: ":!ls" followed by
			":!echo ! \! \\!" executes "echo ls ! \!".

			Any "|" in {cmd} is passed to the shell, you cannot
			use it to append a Vim command.  See |:bar|.

			Any "%" in {cmd} is expanded to the current file name.
			Any "#" in {cmd} is expanded to the alternate file name.
			Special characters are not escaped, use quotes or
			|shellescape()|: >
				:!ls "%"
				:exe "!ls " .. shellescape(expand("%"))
<
			Newline character ends {cmd} unless a backslash
			precedes the newline.  What follows is interpreted as
			another |:| command.

			After the command has been executed, the timestamp and
			size of the current file is checked |timestamp|.

			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).

			To avoid the hit-enter prompt use: >
				:silent !{cmd}
<
							*:!!*
:!!			Repeat last ":!{cmd}".

							*:ve* *:ver* *:version*
:ve[rsion]		Print editor version and build information.
			See also |feature-compile|.

							*: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.

			Only one ":redir" can be active at a time.  Calls to
			":redir" will close any active redirection before
			starting redirection to the new target.  For recursive
			use check out |execute()|.

			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()".
			Alternatives are the 'verbosefile' option or
			|execute()| function, these can be used in combination
			with ":redir".

:redi[r] >> {file}	Redirect messages to file {file}.  Append if {file}
			already exists.

: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
			optional.
:redi[r] @{a-z}>>	Append messages to register {a-z}.

:redi[r] @*>
:redi[r] @+>		Redirect messages to the selection or clipboard. For
			backward compatibility, the ">" after the register
			name can be omitted. See |quotestar| and |quoteplus|.
:redi[r] @*>>
:redi[r] @+>>		Append messages to the selection or clipboard.

:redi[r] @">		Redirect messages to the unnamed register. For
			backward compatibility, the ">" after the register
			name can be omitted.
:redi[r] @">>		Append messages to the unnamed register.

: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
			command output messages will cause errors.  When using
			a local variable (l:var in a function or s:var in a
			script) and another `:redir` causes the current one to
			end, the scope might be different and the assignment
			fails.
			To get the output of one command the |execute()|
			function can be used instead of redirection.

:redi[r] =>> {var}	Append messages to an existing variable.  Only string
			variables can be used.

:redi[r] END		End redirecting messages.

							*:filt* *:filter*
:filt[er][!] {pattern} {command}
:filt[er][!] /{pattern}/ {command}
			Restrict the output of {command} to lines matching
			with {pattern}.  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 {pattern}.

			{pattern} 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 {pattern}.
			Without the enclosing character the pattern cannot
			include the bar character. 'ignorecase' is not used.

			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
			works. Some of the commands that support filtering:
			   |:#|          - 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
			   |:history|    - filter by history commands
			   |: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
			   |:registers|  - filter by register contents
					   (does not work multi-line)
			   |:set|        - filter by option name

			Only normal messages are filtered, error messages are
			not.

						*:sil* *:silent* *:silent!*
: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
<			":silent" also skips the hit-enter prompt.
			Dialogs that prompt for user input (|confirm()|,
			'swapfile', …) are never silent.

						*: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 they were
defined in Lua they will only be located if 'verbose' is set. So Start
nvim with -V1 arg to see them. 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*
[count]K		Runs the program given by 'keywordprg' to lookup the
			|word| (defined by 'iskeyword') under or right of the
			cursor. Default is "man". Works like this: >
				:tabnew | terminal {program} {keyword}
<			Special cases:
			- If 'keywordprg' begins with ":" it is invoked as
			  a Vim command with [count].
			- If 'keywordprg' is empty, |:help| is used.
			- 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: >
				!man 2 mkdir
<			- When 'keywordprg' is equal to "man -s", a [count]
			  before "K" is inserted after the "-s".  If there is
			  no count, the "-s" is removed.
							       *K-lsp-default*
			- The Nvim |LSP| client sets K to show LSP "hover"
			  feature. |lsp-defaults|

							*v_K*
{Visual}K		Like "K", but use the visually highlighted text for
			the keyword.  Only works when the highlighted text is
			not more than one line.

							*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.

[N]gs							*gs* *:sl* *:sleep*
:[N]sl[eep] [N][m]	Do nothing for [N] seconds, or [N] milliseconds if [m]
			was given.  "gs" always uses seconds.
			Default is one second. >
			     :sleep	     "sleep for one second
			     :5sleep	     "sleep for five seconds
			     :sleep 100m     "sleep for 100 milliseconds
			     10gs	     "sleep for ten seconds
<			Can be interrupted with CTRL-C.
			"gs" stands for "goto sleep".
			While sleeping the cursor is positioned in the text,
			if at a visible position.
			Queued messages are processed during the sleep.

							*:sl!* *:sleep!*
:[N]sl[eep]! [N][m]	Same as above. Unlike Vim, it does not hide the
			cursor. |vim-differences|

==============================================================================
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/scripts/less.sh".

This shell script uses the Vim script "$VIMRUNTIME/scripts/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
the whole screen.  But it works well enough for most uses, and you get syntax
highlighting.

The "h" key will give you a short overview of the available commands.

If you want to set options differently when using less, define the
LessInitFunc in your vimrc, for example: >

	func LessInitFunc()
	  set nocursorcolumn nocursorline
	endfunc
<
==============================================================================
3. Commenting							*commenting*

Nvim supports commenting and uncommenting of lines based on 'commentstring'.

Acting on a single line behaves as follows:
- If the line matches 'commentstring', the comment markers are removed (e.g.
  `/*foo*/` is transformed to `foo`).
- Otherwise the comment markers are added to the current line (e.g. `foo` is
  transformed to `/*foo*/`). Blank lines are ignored.

Acting on multiple lines behaves as follows:
- If each affected non-blank line matches 'commentstring', then all comment
  markers are removed.
- Otherwise all affected lines are converted to comments; blank lines are
  transformed to empty comments (e.g. `/**/`). Comment markers are aligned to
  the least indented line.

Matching 'commentstring' does not account for whitespace in comment markers.
Removing comment markers is first attempted exactly, with fallback to using
markers trimmed from whitespace.

If the filetype of the buffer is associated with a language for which a
|treesitter| parser is installed, then |vim.filetype.get_option()| is called
to look up the value of 'commentstring' corresponding to the cursor position.
(This can be different from the buffer's 'commentstring' in case of
|treesitter-language-injections|.)

							*gc* *gc-default*
gc{motion}		Comment or uncomment lines covered by {motion}.

							*gcc* *gcc-default*
gcc			Comment or uncomment [count] lines starting at cursor.

							*v_gc* *v_gc-default*
{Visual}gc		Comment or uncomment the selected line(s).

							*o_gc* *o_gc-default*
gc			Text object for the largest contiguous block of
			non-blank commented lines around the cursor (e.g.
			`gcgc` uncomments a comment block; `dgc` deletes it).
			Works only in Operator-pending mode.

 vim:noet:tw=78:ts=8:ft=help:norl: