-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathREADME
More file actions
1384 lines (1140 loc) · 50.6 KB
/
README
File metadata and controls
1384 lines (1140 loc) · 50.6 KB
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
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Nextvi(1) General Commands Manual Nextvi(1)
NAME
Nextvi - A small vi/ex terminal text editor
SYNOPSIS
vi [-aemsv] [file ...]
DESCRIPTION
Nextvi is a modern clone of the command-line text editor vi(1),
initially developed by Bill Joy in 1976 for Unix-based systems.
Nextvi builds upon many standard features from vi(1) including
a unique modal interface that allows users to switch between normal,
insert, and command modes for efficient text manipulation.
Additional enhancements include an unrestricted macro system,
syntax highlighting, keymaps, bidirectional UTF-8 support, and
numerous other features. Nextvi remains highly efficient, portable,
and hackable, ensuring its continued relevance and high quality
for years to come.
OPTIONS
-a Enable alternate terminal screen
-e Enter ex mode on startup
-m Disable initial file read message
-s Enter raw ex mode on startup
-v Unset all options
MANPAGE NOTATION
<x> A closure where x represents a character literal
[x] A closure where x represents optional argument
{x} A closure where x represents required argument
"x" A closure where x represents a string
<^X> Represents a ctrl key X
< > Separates alternatives in a closure
x-y Range from x to y
VI NORMAL
[#]j Move # lines down
[#]k Move # lines up
[#]+
[#]<^M>
[#]<Enter>
Move # lines down, cursor after indent
[#]- Move # lines up, cursor after indent
[#]h Move # columns left
[#]l Move # columns right
[#]f{arg} Move to arg character found forward # times
[#]F{arg} Move to arg character found backward # times
[#]t{arg} Move until arg character found forward # times
[#]T{arg} Move until arg character found backward # times
[#], Repeat last <f F t T> move backward # times
[#]; Repeat last <f F t T> move forward # times
[#]E Move to end of word # times, skip punctuation
[#]e Move to end of word # times
[#]B Move to start of word backward # times, skip punctuation
[#]b Move to start of word backward # times
[#]W Move to start of word forward # times, skip punctuation
[#]w Move to start of word forward # times
vw Toggle single-line mode for <E e B b W w Space Backspace>
regions
[#]( Move to next sentence boundary down # times
[#]) Move to next sentence boundary up # times
[#]{ Move to next <{> section down # times
[#]} Move to next <{> section up # times
[#][ Move to next <Newline> section down # times
[#]] Move to next <Newline> section up # times
^ Move to start of line after indent
0 Move to start of line
$ Move to end of line
[#]| Goto # column
[#]<Space> Move # characters forward
[#]<^H>
[#]<Backspace>
Move # characters backward
% Move to closest <] ) } [ ( {> pair
{#}% Move to # percent line number
'{<a-z ` ' [ ] *>}
Move to a line mark
`{<a-z ` ' [ ] *>}
Move to a line mark with cursor position
gg Goto first line in buffer
[#]G Move to last line in buffer or # line
H Move to highest line on a screen
L Move to lowest line on a screen
M Move to middle line on a screen
z. Center screen at cursor
z<^M>
z<Enter>
Center screen at top row
z- Center screen at bottom row
[#]<^E> Scroll down 1 or # lines, retain # and cursor position
[#]<^Y> Scroll up 1 or # lines, retain # and cursor position
[#]<^D> Scroll down half a screen size. If [#], set scroll to #
lines
[#]<^U> Scroll up half a screen size. If [#], set scroll to # lines
<^B> Scroll up full screen size
<^F> Scroll down full screen size
# Show global and relative line numbers
2# Toggle show global line numbers permanently
4# Toggle show relative line numbers after indent permanently
8# Toggle show relative line numbers permanently
V Toggle show hidden characters:<Space Tab Newline>
<^C> Toggle show line motion numbers for <l h e b E B w W>
{<1-5>}<^C> Select line motion number mode 1-5
<^V> Loop through line motion number modes
[#]<^R> Redo # times
[#]u Undo # times
<^I>
<Tab>
Open file path from cursor to end of line
<^K> Write current buffer to file. Force write on 2nd attempt
[#]<^W>{arg} Unindent arg region # times
[#]<{arg} Indent left arg region # times
[#]>{arg} Indent right arg region # times
[#]"{<arg>}{cmd}
Execute normal cmd using register arg. # applies to cmd
R Print registers and their contents
[#]&{<arg>} Execute arg register macro in non-blocking mode # times
[#]@{<arg>} Execute arg register macro in blocking mode # times
[#]@@ Execute last macro # times, blocking
[#]&& Execute last macro # times, non-blocking
[#]@:
[#]&:
Execute <:> register as an ex command # times
[#]. Repeat last normal command # times. Repeatable commands:
<x X D C s S Y p P r d c ~ gu gU g~ ! > < ^W i I a A o O ci
di J K>
[#]v. Repeat last normal command moving down across # lines
[#]Q Enter ex mode. # retains current horizontal scroll
: Enter ex prompt
[#]!{arg} Enter pipe ex prompt based on # or arg region
vv Enter ex prompt with the last line from history buffer b-1
[#]vr Enter %s/ ex prompt. Insert # words from cursor
[#]vt[#arg] Enter .,.+0s/ ex prompt. Insert # of lines from cursor.
Insert #arg words from cursor
[#]v/ Enter re ex prompt to set regex keyword. Insert # words
from cursor
v; Enter ! ex prompt
[#]vi Enter %s/ ex prompt. Contains regex for changing spaces to
tabs. # modifies tab width
[#]vI Enter %s/ ex prompt. Contains regex for changing tabs to
spaces. # modifies tab width
vo Remove trailing white spaces and <\r> line endings
<^G> Print buffer status info
1<^G> Enable permanent status row
2<^G> Disable permanent status row
ga Print character info
1ga Enable permanent character info row
2ga Disable permanent character info row
[#]gw Hard word wrap a line to # column limit. Default: 80
[#]gq Hard word wrap a buffer to # column limit. Default: 80
[#]g~{arg} Switch character case for arg region # times
[#]gu{arg} Switch arg region to lowercase # times
[#]gU{arg} Switch arg region to uppercase # times
[#]~ Switch character case # times forward
i Enter insert mode
I Enter insert mode at start of line after indent
A Enter insert mode at end of line
a Enter insert mode 1 character forward
o Create a new line down and enter insert mode
O Create a new line up and enter insert mode
[#]s Delete # characters and enter insert mode
[#]S Delete all across # lines and enter insert mode
[#]c{arg} Delete arg region # times and enter insert mode
C Delete from cursor to end of line and enter insert mode
[#]d{arg} Delete arg region # times
D Delete from cursor to end of line
[#]x Delete # characters from cursor forward
[#]X Delete # characters from cursor backward
di{<arg>} Delete inside arg pairs
ci{<arg>} Change inside arg pairs
[#]r{arg} Replace # characters with arg from cursor forward
[#]K Split a line # times
[#]J Join # lines
[#]y{arg} Yank arg region # times
[#]Y Yank # lines
[#]p Paste default register below current line or after cursor
position # times
[#]P Paste default register above current line or before cursor
position # times
m{<a-z ` ' [ ] *>}
Set buffer local line mark
<^T> Set global line mark 0. Global marks are always valid
{<0 2 4 6 8>}<^T>
Set a global line mark #
{<1 3 5 7 9>}<^T>
Switch to a global line mark #
[#]<^7>{<0-9>}
[#]<^_>{<0-9>}
[#]<^/>{<0-9>}
Show buffer list and switch based on # or 0-9 index when
prompted
<^^>
<^6>
Swap to previous buffer
[#]<^N> Swap to next buffer, # changes direction [forward backward]
\ Swap to /fm/ buffer b-2
{#}\ Refresh secondary directory listing in b-2
vb Recurse into b-1 history buffer. Insert current line into
ex prompt on exit
z1 Set alternative keymap to Farsi keymap
z2 Set alternative keymap to Russian keymap
ze Switch to English keymap
zf Switch to alternative keymap
zL Set td ex option to 2
zl Set td ex option to 1
zr Set td ex option to -1
zR Set td ex option to -2
[#]/ Regex search prompt, move down 1 or # matches
[#]? Regex search prompt, move up 1 or # matches
[#]n
[#]N
Repeat regex search, move [down up] 1 or # matches
<^A> Regex search 1 word from cursor, no center, wraparound move
[up down]
* Regex search, no center, wraparound move [up down]
{#}*
{#}<^A> Regex search, set keyword to # words from cursor
<^]> Filesystem regex search forward based on directory listing
in b-2. Sets global line mark 0 for <^P> fallback
{#}<^]> Filesystem regex search forward, set keyword to # words
from cursor
[#]<^P> Filesystem regex search backward
<^Z> Suspend vi
<^L> Force redraw whole screen and update terminal dimensions
Z{<Any>} Force exit and clean terminal, force quit in an & macro
Zz Force exit and submit history command, force quit in an &
macro
ZZ Exit and write unsaved changes to a file
<ESC ^C> Cancel any pending input or command
VI REGIONS
Regions are vi normal commands that define [h v]range for vi motions.
Commands described with the word "move" define a region.
j + <^M> <Enter> - k h l f F t T , ; B E b e W w ( ) { } [ ] ^ 0 $
<Space> <^H> <Backspace> % ' ` G H L M / ? n N * <^A>
All regions
VI MOTIONS
Motions are vi normal commands that run in a [h v]range.
Commands described with the word "region" consume a region.
Motions can be prefixed or suffixed by [#].
<^W> > < ! c d y g~ gu gU
All motions
dd yy cc g~~ guu gUU >> << <^W><^W> !!
Special motions that can use [#] as number of lines
Examples:
3d/int Delete text until 3rd instance of "int" keyword
3dw Delete 3 words (prefix [#])
d3w Delete 3 words (suffix [#])
"ayl Yank a character into <a> register
"Ayw Append a word to <a> register
VI/EX INSERT
<^H>
<Backspace>
Delete a character, reset ex mode when empty
<^U> Delete until <^X> mark or all
<^W> Delete a word
<^T> Increase indent
<^D> Decrease indent
<^]> Select paste register from 0-9 registers in a loop
<^\>{<arg>} Select paste register arg. <^\> selects default register
<^P> Paste a register
<^X> Mark autocomplete and <^U> starting position. <^X> resets
the mark
<^G> Index current buffer for autocomplete
<^Y> Reset all indexed autocomplete data
<^R> Loop through autocomplete options backward
<^N> Loop through autocomplete options forward
<^B> Print autocomplete options when in vi insert
<^B> Recurse into b-1 history buffer when in ex prompt. Insert
current line into ex prompt on exit
<^A> Loop through lines in a history buffer b-1
<^Z> Suspend vi/ex
<^L> Redraw screen in vi mode, clean terminal in ex
<^O> Switch between vi and ex modes recursively
<^E> Switch to English keymap
<^F> Switch to alternative keymap
<^V>{<arg>} Read a literal character arg
<^K>{arg} Read a digraph sequence arg
<^C>
<ESC>
Exit insert mode in vi, reset in ex
<^M>
<Enter>
Insert <Newline> in vi, submit command in ex
EX
Ex is a powerful line editor for Unix systems, initially developed
by Bill Joy in 1976. This essential tool serves as the backbone
of vi, enabling it to execute commands, macros and even transform
into a purely command-line interface (CLI) when desired.
EX PARSING
Parsing follows the structure:
[<sep>][prefix][cmd][<pad>][args]
Ex commands are initiated and separated by <sep>. Fields can be
padded by <Space> or <Tab>. [prefix] is a field consumed by [cmd],
which accepts [range] structure characters. Padding inside [prefix]
structure is collapsed, except within nested structures. There
can only be one pad in between [cmd] and [args]. To avoid ambiguity
in scripts, it is recommended to always use a pad between [cmd]
and [args].
Examples:
:evi.c
Evaluates to ":e vi.c"
:efbc
Evaluates to ":ef bc" not ":e fbc"
:e vi.c
Edit " vi.c". <pad> is required
EX ESCAPES
Special characters in [args] will become regular when escaped
with <\>.
( ^ ] -
Specials in regex "[]" expression
( ) { + * ? ^ $ [ ] | \ . \< \>
Specials in regex
\ : % !
Specials in ex
EX EXPANSION
<%> in [args] expands to current buffer pathname or any buffer
pathname when followed by a corresponding buffer number.
"%#" expands to last swapped buffer pathname.
"%@" expands to register specified.
Example: make a copy of the current file and edit it
:!cp % %_:e %_
Example: insert current buffer pathname
:&i%
Example: echo the value of <a> register
:!echo "%@a"
<!> in [args] starts and optionally ends a block containing
external commands. This block executes and expands to stdout
and stderr produced.
Example: substitute "int" with the value of $RANDOM
:%s/int/!printf "%s" $RANDOM!
Example: insert output of ls shell command
:&i!ls
Example: insert output of ls more efficiently
:;c!ls!<^V><ESC>
EX RANGES
Some ex commands can be prefixed with ranges.
[range] prefix implements vertical and horizontal ranges.
[vrange] prefix implements vertical range and horizontal position.
Without [cmd], [vrange] replaces [prefix].
[% |][, ;][#][. $ ' > <][- + * / %][0-9]
All ranges structure
{|}{cmd}[|]
Ex command structure
{>}[regex][>]
Search forward structure
{<}[regex][<]
Search backward structure
'{<mark>}
Mark structure
% Range from first to last line
| Begin ex command structure
, Vertical range separator
; Horizontal range separator
# Rebase to previous value in range structure
. Current position
$ Last line of a buffer or end of line
' Begin mark structure
> Begin search forward structure
< Begin search backward structure
- Subtract following number
+ Add following number
* Multiply by the following number
/ Divide by the following number
% Modulo by the following number
0-9 Number or position
Examples:
:1,5p Print lines 1,5
:.-5,.+5p
Print 5 lines around current position
:>int>p
Print first occurrence of "int"
:<int<p
Print first occurrence of "int" in reverse
:.,>int>p
Print until "int" is found
:<int<,.p
Print until "int" is found in reverse
:> Search using previously set regex keyword
:'d,'ap
Print lines from mark <d> to mark <a>
:%p Print all lines in a buffer
:$p Print last line in a buffer
:$*50/100+1
Goto 50% of the file
:;50 Goto character offset 50
:10;50 Goto line 10 character offset 50
:10;.+5
Goto line 10 +5 character offset
:'a;'a Goto line mark <a> offset mark <a>
:;$ Goto end of line
:5;>int>
Search for "int" on line 5
:.;<int<
Search for "int" in reverse on the current line
:;5;+10=
+10 is relative to the initial current offset, not 5
:;5;#+10=
+10 is relative to 5
:;>int>+3;#>>p
Print text enclosed by "int" on the current line
:|grp1|;>(a)+>+1|grp|;#>>p
Print text enclosed by a non-deterministic pattern "a+"
EX COMMANDS
[range]f>[regex]
[vrange]f<[regex]
Ranged search
Horizontal range performs a scoped multi-line search forward.
In multi-line mode, <Newline> is a regular character.
Example: no range given, current line only
:f>int
Example: reverse
:f<int
Example: range given
:10,100f>int
Example: search for "int" followed by "void" on next line
:%;0f>int.void
[range]f+[regex]
[vrange]f-[regex]
Incrementing ranged search
Equivalent to the :f> and :f< commands, except subsequent commands
within range move to the next match just like vi normal [#]n
or [#]N commands.
[vrange]f[regex]
Fuzzy search prompt
Enters a fuzzy search prompt with a list of matches.
Matches are prefixed by selection numbers and line numbers.
Match can be selected using numbers 0-9 if there are less than
10 matches.
<^C> or <ESC> to abort.
<^M> or <Enter> to input a selection number larger than 9.
No range evaluates to <%> range.
No range displays a maximum of xrows * 3 matches.
[vrange]g[<Any>][regex][<Any>][cmd]
Global command
Execute an ex command on a range of lines that matches an
enclosed regex.
No range evaluates to <%> range or <.> range when nested.
Example: remove all empty lines
:g/^$/d
Example: print lines matching previously set regex
:g//p
Multiple ex commands can be chained in one global command.
To chain commands, the ex separator <:> must be escaped once.
Example: print and append lines matching "int" to register <a>
:g/int/p\:ya ax
It is possible to nest global commands inside of global commands.
The first global command will not be executed on lines that
were changed by a nested global command.
Example: nested global command
Append "has a semicolon" to all lines that contain "int" and
end with <;>.
:g/int/g/;$/& A has a semicolon
Example: extract/print data enclosed in "()"
:grp1:err4:g/./;0\:;>(\().+\)>;#>.+(\))>+1p:err1:grp
[vrange]g![<Any>][regex][<Any>][cmd]
Inverted global command
[range]re[regex]
Set regex keyword
Range escapes its text and uses it as the regex.
Example: set keyword to "int"
:re int
Example: set keyword from lines 1 to 3
:1,3re
[vrange]i[str]
Enter ex insert mode before specified position
[str] specifies initial input into the insertion buffer.
[str] in raw ex mode is injected directly and bypasses the
interactive mode.
Example: insert "hello" in vi/ex
:i hello<^M><ESC>
Example: insert "hello" in vi/ex trimming <Newline>
:i hello<^M><^M><Backspace>
Example: discard changes in vi/ex
:i hello<^M><^C>
Example: immediately insert "hello"
:i hello<^V><ESC>
Example: insert "hello" in raw ex mode
i hello
Example: insert two lines in raw ex mode
i hello<^M>world
Example: insert "hello" in raw ex mode (interactive)
i<^M>hello<^M>.<^M>
[vrange]a[str]
Enter ex insert mode after specified position
[range]c[str]
Enter ex change mode
In combination with seq and lim ex options, this command is
optimal for modifying very long lines.
Max insertion buffer is ~1.33GB on a 32 bit build.
Max addressable line is 2.0GB on a 32 bit build.
Example: replace current line with "hello"
:c hello<^M><ESC>
Example: replace lines 1-5 with "hello"
:1,5c hello<^M><ESC>
Example: insert "hello" at current character offset
:;c hello<^M><ESC>
Example: insert "hello" at end of line
:;$c hello<^M><ESC>
Example: insert "hello" at line 5 and end of line
:5;$c hello<^M><ESC>
Example: delete 5 characters from current position
:;;+5c<^M><ESC>
[range]d
Delete line(s)
Example: delete from current position to the start of the buffer
:1,.;0;d
Example: delete from current position to the end of the buffer
:.,$;;$d
[vrange]j[any]
Join line(s)
Any argument activates padding mode.
Example: join all lines
:%-1j
Example: join all lines with space padding
:%-1j x
[vrange]s[<Any>][regex][<Any>][str][<Any>][<g>]
Substitute
Find and replace text in a range of lines that matches an
enclosed regex with an enclosed replacement string.
Example: global replacement
:%s/term1/term2/g
Example: replace matching previously set regex
:%s//term2/g
Substitution backreference inserts the text of matched group
specified by \x where x is group number.
Example: substitution backreference
this is an example text for subs and has int or void
:%s/(int)|(void)/pre\0after
this is an example text for subs and has preintafter or void
:%s/(int)|(void)/pre\2after/g
this is an example text for subs and has prepreafterafter or prevoidafter
ud Undo
rd Redo
[range]p[str]
Print line(s) from a buffer
No range prints a line based on the value of left ex option.
Argument prints the evaluated argument.
Example: utilize character offset ranges
:1,10;5;5p
Example: interleaved character offset ranges
:1;5,10;5p
Example: print current line from offset 5 to 10
:.;5;10p
Example: print buffer pathname
:p %
[range]=[<0-3 Any>][any]
Print range numbers
Argument 0-3 selects a specific number.
Any or any extra argument circumvents buffer range check.
No argument prints all range numbers.
Example: print current character offset only
:;= 2
Example: print value of mark <a>
:'a=
Example: calculate 75 - 100
:,75-100=1p
=?[any]
Print last error
Any argument forwards the error status.
[range]m{marks}
Set line mark(s)
Valid marks: <a-z ` ' [ ] *>
Example: store ranges in <a> and <s> for later reuse in :f>
:>top>,#>bottom>m as:'a,'sf>middle
[range]ya[<reg>][any]
Yank into a register
Argument value range is 0x1-0xff and 0x0 without.
Any extra argument appends to the register.
Default register cannot be appended to.
Example: append to register <1>
:ya 1x
Example: yank into <a> using ranges
:1,5;5;5ya a
ya![<reg>]
Free a register
[range]pu[<reg>][any][\!{cmd}]
Paste or pipe a register
Example: paste <a> at line 1 character offset 5
:1;5pu a
Example: copy default register to X11 clipboard
:pu \!xclip -selection clipboard
Example: copy register <a> to X11 clipboard
:pu a \!xclip -selection clipboard
[0-255]reg[str]
Print registers or put into a register
Prefix selects a register and argument replaces its contents.
Example: shift the printing position to view offscreen register parts
:1left:reg
Example: put "hello" into register <1>
:49reg hello
[0-255]reg+[str]
Print registers or append to a register
e[path]
Open a file at a path
No argument opens "unnamed" buffer.
Files larger than 2.0GB are truncated on a 32 bit build.
Line breaking happens until the first null terminator or EOF.
e![path]
Force open a file at a path
No argument re-reads the current buffer from the filesystem.
[vrange]ef[regex]
Open file using fuzzy search prompt
Requires the b-2 buffer to have a directory listing backfilled.
Example: backfill b-2 using :fd
:fd
Example: backfill b-2 using find
:b-2:%!find .
Prompt behavior is equivalent to the :f command.
Example: enter prompt & print entire listing
:ef
Example: search for pathname containing "v"
:ef v
[vrange]ef![regex]
Forced version of :ef
[range]r[path]
[range]r[\!{cmd}]
Read a file or a pipe
Range is computed on a target.
No range evaluates to <%> range.
No argument evaluates to current buffer path.
Example: read a file
:r vi.c
Example: pipe in all data
:r \!ls
Example: pipe in only lines 3,5
:3,5r \!ls
[range]w[path]
[range]w[\!{cmd}]
Write a file or a pipe
No range evaluates to <%> range.
No argument evaluates to current buffer path.
Example: write a file
:w vi.c
Example: pipe out all data into less
:w \!less
Example: pipe out only first 10 lines
:1,10w \!less
[range]w![path]
Force write a file
[range]wq[path]
[range]wq[\!{cmd}]
Write a file or a pipe and exit
[range]wq![path]
[range]wq![\!{cmd}]
Force write a file or a pipe and force quit
[range]x[path]
Write unsaved changes and exit
[range]x![path]
Force write unsaved changes and force quit
[#lvl]q[#code]
[#lvl]q![#code]
Exit or force quit
[#code] specifies shell exit code.
[#lvl] defines the number of scopes to exit.
Example: conditionally exit this scope and 1 above
:%f>marker:??!p no marker\:1q:s/old/new/g:w
b[index]
Print buffers or switch to a buffer
Temporary buffers are separate from the main buffers
and are selected by a negative index.
Example: switch to the 5th buffer
:b5
Example: switch to the /hist/ ex history buffer
:b-1
Example: switch to the /fm/ directory listing buffer
:b-2
Example: switch to the /sc/ scratch buffer
:b-3
bp[path]
Set current buffer path
bs[any]
Set current buffer saved
Argument resets undo/redo history
bx[#] Set max number of buffers allowed
Buffers will be deallocated if the number specified is lower
than the number of buffers currently in use.
No argument will reset to the default value of 10.
cd[path]
Set a working directory
No argument relinks the current directory in case it got removed
or unmounted.
Currently open buffers' file paths will be automatically adjusted
to reflect a newly set working directory.
fp[path]
Clear or set a secondary directory path
fd[path]
Calculate directory listing in b-2 buffer
No argument uses secondary or a working directory path.
inc[regex]
Include regex for :fd calculation
No argument disables the filter.
Example: include only files in submodule directory that end with .c
:inc submodule.*\.c$
Example: exclude .git and submodule folders
:inc (^(?\:(?\!^\.git|^submodule).)+[^/]+$)
[range]![cmd]
Run an external program
When a range is specified, the buffer's data is piped to an external
program. The resulting stdout and stderr are then piped back into the
buffer, replacing the contents of the original range.
Example: infamously sort a buffer
:%!sort
Example: replace "int" with "uint" using sed
:%!sed -e 's/int/uint/g'
Example: pipe in result of ls command without line replacement
:;$+1!ls
Example: capitalize word at current position using tr
:;;>\\>>!tr '[\:lower\:]' '[\:upper\:]'
&{macro}
Global non-blocking macro
Execute raw vi input sequence.
A non-blocking macro shall not wait for input when the end of
the sequence is reached. A non-blocking macro executing other
macros will always reach a terminating point.
Example: execute vi insert statement
:& ihello
Example: execute :hello
:& \:hello<^V><^M>
Example: execute vi "ci(int" macro
:& ci(int
Example: nest blocking macro inside non-blocking
:& \:@ \\\:blocking<^V><^M>i continue in non-blocking
Example: enable permanent vi line numbers
:& 2#
@{macro}
Global blocking macro
Execute raw vi input sequence.
A blocking macro shall wait for input when the end of the sequence
is reached. A blocking macro executing other macros may cause
input congestion.
Example: execute vi insert statement
:@ ihello
Example: insert "hello" into <:> vi prompt
:@ \:hello
Example: execute vi "ci(int" macro
:@ ci(int
Example: execute "ci(int" exiting insert mode
:@ ci(int<^V><^C>
Example: execute "ci)INT" as a follow-up
:@ ci(int<^V><^C>ci)INT
Example: execute vi "dw" command after user exits insert
:@i:@dw
[#count <$>]?[cond][<?>][then][<?>][else]
While loop conditional
Repeat [cond] [#count] times or infinite with [<$>].
While loop is broken once [cond] returns an error or count exceeded.
Error status of [cond] is forwarded.
No prefix creates a conditional with [#count] set to 1.
Example: attempt to join every line in file using arbitrary count
:10000? & J
Example: undo everything
:$? ud
Example: repeat chain of ex commands 10 times
:10? 1p\:5p\:10p
Example: calculate directory only if :cd succeeded
:? cd /blah?fd
Example: print a line only if it contains "int" at offset 5
:? ;5;#>^int>?p
Example: edit vi.c only if it exists
:? \![ -f ./vi.c ]?e ./vi.c:mpt1
[#count <$>]?![cond][<?>][else][<?>][then]
Inverted while loop conditional
[prefix]??[then][<?>][else]
{prefix}??
Conditional
Unlike while loop conditional, branching depends on the error
status of the last command, reducing the number of escapes required.
A prefix without arguments captures the current error status
at that point in a command chain into id tag specified.
Id tags are global across all nested command contexts.
A prefix with arguments branches based on the boolean expression
in DNF over the most recent captures of each referenced id.
If any id has no capture, neither branch executes.
Prefix operators:
Numerical id tag
, AND (higher precedence)
; OR (lower precedence)
Example: capture error status at id 5, branch later
:>int>:5??:;=:5??p
Example: skip if tag was never set
:2??.=?.=
Example: AND -- branch only if both ids captured success
:f>int:1??:f>void:2??:1,2??p found both
Example: OR -- branch if either id captured success
:f>int:1??:f>void:2??:1;2??p found one
Example: DNF -- (1 AND 2) OR (3 AND 4)
:1,2;3,4??p then?p else
Example: inverted capture -- capture NOT of last status
:f>int:1??!:1??p int was absent
[prefix]??![else][<?>][then]
{prefix}??!
Inverted conditional
{prefix}???
Evaluate prefix tags
This is a nop command that evaluates a boolean expression
at prefix and returns the result.
Example: control while loop from its [then] argument
$?0\?\?\??+1\:0\?\?\:f>int\:\?\?p
ft[filetype]
Set a filetype
No argument prints the current file type.
Reloads the highlight ft, which makes it possible to reset dynamic
highlights created by options like "hlw".
cm[keymap]
Set a keymap
No argument prints the current keymap name.
cm![keymap]
Set an alternative keymap
ac[regex]
Set autocomplete filter regex
No argument resets to the default word filter regex as defined
in led.c.
Example: autocomplete using whole lines from a buffer
:ac .+
[<0-3>]sc[<esc>][<sep>][<exp>][<exe>]
Set ex special characters
Prefix selects a specific character to change.
Missing arguments default to <\ : % !>.
Example: change <%> to <a>
:2sc a
Example: utilize newly set separator in a single command chain
:|1sc a|: p cmd1 a p cmd2 a|sc|a0?:p cmd3
[<0-3>]sc![<esc>][<sep>][<exp>][<exe>]
Set ex special characters
Missing arguments default to <0x0>.
Example: disable <exp> and <exe>
:sc! \\\:
uc Toggle multi-byte utf-8 decoding
This command is particularly useful when editing files with
mixed encodings, binary files, or when the terminal does not
support UTF-8 or lacks the necessary fonts to display UTF-8
characters. It is often paired with :ph command to achieve
hex editor-like functionality.
uz Toggle zero-width character placeholders