forked from Bastardkb/qmk_userspace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
motion.txt
1390 lines (1156 loc) · 52.4 KB
/
motion.txt
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
*motion.txt* Nvim
VIM REFERENCE MANUAL by Bram Moolenaar
Cursor motions *cursor-motions* *navigation*
These commands move the cursor position. If the new position is off of the
screen, the screen is scrolled to show the cursor (see also 'scrolljump' and
'scrolloff' options).
General remarks:
If you want to know where you are in the file use the "CTRL-G" command
|CTRL-G| or the "g CTRL-G" command |g_CTRL-G|. If you set the 'ruler' option,
the cursor position is continuously shown in the status line (which slows down
Vim a little).
Experienced users prefer the hjkl keys because they are always right under
their fingers. Beginners often prefer the arrow keys, because they do not
know what the hjkl keys do. The mnemonic value of hjkl is clear from looking
at the keyboard. Think of j as an arrow pointing downwards.
The 'virtualedit' option can be set to make it possible to move the cursor to
positions where there is no character or within a multi-column character (like
a tab).
Type |gO| to see the table of contents.
==============================================================================
1. Motions and operators *operator*
The motion commands can be used after an operator command, to have the command
operate on the text that was moved over. That is the text between the cursor
position before and after the motion. Operators are generally used to delete
or change text. The following operators are available:
|c| c change
|d| d delete
|y| y yank into register (does not change the text)
|~| ~ swap case (only if 'tildeop' is set)
|g~| g~ swap case
|gu| gu make lowercase
|gU| gU make uppercase
|!| ! filter through an external program
|=| = filter through 'equalprg' or C-indenting if empty
|gq| gq text formatting
|gw| gw text formatting with no cursor movement
|g?| g? ROT13 encoding
|>| > shift right
|<| < shift left
|zf| zf define a fold
|g@| g@ call function set with the 'operatorfunc' option
*motion-count-multiplied*
If the motion includes a count and the operator also had a count before it,
the two counts are multiplied. For example: "2d3w" deletes six words.
*operator-doubled*
When doubling the operator it operates on a line. When using a count, before
or after the first character, that many lines are operated upon. Thus `3dd`
deletes three lines. A count before and after the first character is
multiplied, thus `2y3y` yanks six lines.
After applying the operator the cursor is mostly left at the start of the text
that was operated upon. For example, "yfe" doesn't move the cursor, but "yFe"
moves the cursor leftwards to the "e" where the yank started.
*linewise* *charwise* *characterwise*
The operator either affects whole lines, or the characters between the start
and end position. Generally, motions that move between lines affect lines
(are linewise), and motions that move within a line affect characters (are
charwise). However, there are some exceptions.
*exclusive* *inclusive*
Character motion is either inclusive or exclusive. When inclusive, the
start and end position of the motion are included in the operation. When
exclusive, the last character towards the end of the buffer is not included.
Linewise motions always include the start and end position. Plugins can
check the v:event.inclusive flag of the |TextYankPost| event.
Which motions are linewise, inclusive or exclusive is mentioned with the
command. There are however, two general exceptions:
1. If the motion is exclusive and the end of the motion is in column 1, the
end of the motion is moved to the end of the previous line and the motion
becomes inclusive. Example: "}" moves to the first line after a paragraph,
but "d}" will not include that line.
*exclusive-linewise*
2. If the motion is exclusive, the end of the motion is in column 1 and the
start of the motion was at or before the first non-blank in the line, the
motion becomes linewise. Example: If a paragraph begins with some blanks
and you do "d}" while standing on the first non-blank, all the lines of
the paragraph are deleted, including the blanks. If you do a put now, the
deleted lines will be inserted below the cursor position.
Note that when the operator is pending (the operator command is typed, but the
motion isn't yet), a special set of mappings can be used. See |:omap|.
Instead of first giving the operator and then a motion you can use Visual
mode: mark the start of the text with "v", move the cursor to the end of the
text that is to be affected and then hit the operator. The text between the
start and the cursor position is highlighted, so you can see what text will
be operated upon. This allows much more freedom, but requires more key
strokes and has limited redo functionality. See the chapter on Visual mode
|Visual-mode|.
You can use a ":" command for a motion. For example "d:call FindEnd()".
But this can't be repeated with "." if the command is more than one line.
This can be repeated: >
d:call search("f")<CR>
This cannot be repeated: >
d:if 1<CR>
call search("f")<CR>
endif<CR>
Note that when using ":" any motion becomes charwise exclusive.
*forced-motion*
FORCING A MOTION TO BE LINEWISE, CHARWISE OR BLOCKWISE
When a motion is not of the type you would like to use, you can force another
type by using "v", "V" or CTRL-V just after the operator.
Example: >
dj
deletes two lines >
dvj
deletes from the cursor position until the character below the cursor >
d<C-V>j
deletes the character under the cursor and the character below the cursor. >
Be careful with forcing a linewise movement to be used charwise or blockwise,
the column may not always be defined.
*o_v*
v When used after an operator, before the motion command: Force
the operator to work charwise, also when the motion is
linewise. If the motion was linewise, it will become
|exclusive|.
If the motion already was charwise, toggle
inclusive/exclusive. This can be used to make an exclusive
motion inclusive and an inclusive motion exclusive.
*o_V*
V When used after an operator, before the motion command: Force
the operator to work linewise, also when the motion is
charwise.
*o_CTRL-V*
CTRL-V When used after an operator, before the motion command: Force
the operator to work blockwise. This works like Visual block
mode selection, with the corners defined by the cursor
position before and after the motion.
==============================================================================
2. Left-right motions *left-right-motions*
These commands move the cursor to the specified column in the current line.
They stop at the first column and at the end of the line, except "$", which
may move to one of the next lines. See 'whichwrap' option to make some of the
commands move across line boundaries.
h or *h*
<Left> or *<Left>*
CTRL-H or *CTRL-H* *<BS>*
<BS> [count] characters to the left. |exclusive| motion.
Note: If you prefer <BS> to delete a character, use
the mapping:
:map CTRL-V<BS> X
(to enter "CTRL-V<BS>" type the CTRL-V key, followed
by the <BS> key)
l or *l*
<Right> or *<Right>* *<Space>*
<Space> [count] characters to the right. |exclusive| motion.
See the 'whichwrap' option for adjusting the behavior
at end of line
*0*
0 To the first character of the line. |exclusive|
motion.
*<Home>* *<kHome>*
<Home> To the first character of the line. |exclusive|
motion. When moving up or down next, stay in same
TEXT column (if possible). Most other commands stay
in the same SCREEN column. <Home> works like "1|",
which differs from "0" when the line starts with a
<Tab>.
*^*
^ To the first non-blank character of the line.
|exclusive| motion. Any count is ignored.
*$* *<End>* *<kEnd>*
$ or <End> To the end of the line. When a count is given also go
[count - 1] lines downward, or as far is possible.
|inclusive| motion. If a count of 2 or larger is
given and the cursor is on the last line, that is an
error and the cursor doesn't move.
In Visual mode the cursor goes to just after the last
character in the line.
When 'virtualedit' is active, "$" may move the cursor
back from past the end of the line to the last
character in the line.
*g_*
g_ To the last non-blank character of the line and
[count - 1] lines downward |inclusive|.
*g0* *g<Home>*
g0 or g<Home> When lines wrap ('wrap' on): To the first character of
the screen line. |exclusive| motion. Differs from
"0" when a line is wider than the screen.
When lines don't wrap ('wrap' off): To the leftmost
character of the current line that is on the screen.
Differs from "0" when the first character of the line
is not on the screen.
*g^*
g^ When lines wrap ('wrap' on): To the first non-blank
character of the screen line. |exclusive| motion.
Differs from "^" when a line is wider than the screen.
When lines don't wrap ('wrap' off): To the leftmost
non-blank character of the current line that is on the
screen. Differs from "^" when the first non-blank
character of the line is not on the screen.
*gm*
gm Like "g0", but half a screenwidth to the right (or as
much as possible).
*gM*
gM Like "g0", but to halfway the text of the line.
With a count: to this percentage of text in the line.
Thus "10gM" is near the start of the text and "90gM"
is near the end of the text.
*g$*
g$ When lines wrap ('wrap' on): To the last character of
the screen line and [count - 1] screen lines downward
|inclusive|. Differs from "$" when a line is wider
than the screen.
When lines don't wrap ('wrap' off): To the rightmost
character of the current line that is visible on the
screen. Differs from "$" when the last character of
the line is not on the screen or when a count is used.
Additionally, vertical movements keep the column,
instead of going to the end of the line.
When 'virtualedit' is enabled moves to the end of the
screen line.
*g<End>* *g<kEnd>*
g<End> Like |g$| but to the last non-blank character
instead of the last character.
*bar*
| To screen column [count] in the current line.
|exclusive| motion. Ceci n'est pas une pipe.
*f*
f{char} To [count]'th occurrence of {char} to the right. The
cursor is placed on {char} |inclusive|.
{char} can be entered as a digraph |digraph-arg|.
When 'encoding' is set to Unicode, composing
characters may be used, see |utf-8-char-arg|.
|:lmap| mappings apply to {char}. The CTRL-^ command
in Insert mode can be used to switch this on/off
|i_CTRL-^|.
*F*
F{char} To the [count]'th occurrence of {char} to the left.
The cursor is placed on {char} |exclusive|.
{char} can be entered like with the |f| command.
*t*
t{char} Till before [count]'th occurrence of {char} to the
right. The cursor is placed on the character left of
{char} |inclusive|.
{char} can be entered like with the |f| command.
*T*
T{char} Till after [count]'th occurrence of {char} to the
left. The cursor is placed on the character right of
{char} |exclusive|.
{char} can be entered like with the |f| command.
*;*
; Repeat latest f, t, F or T [count] times. See |cpo-;|
*,*
, Repeat latest f, t, F or T in opposite direction
[count] times. See also |cpo-;|
==============================================================================
3. Up-down motions *up-down-motions*
k or *k*
<Up> or *<Up>* *CTRL-P*
CTRL-P [count] lines upward |linewise|.
j or *j*
<Down> or *<Down>*
CTRL-J or *CTRL-J*
<NL> or *<NL>* *CTRL-N*
CTRL-N [count] lines downward |linewise|.
gk or *gk* *g<Up>*
g<Up> [count] display lines upward. |exclusive| motion.
Differs from 'k' when lines wrap, and when used with
an operator, because it's not linewise.
gj or *gj* *g<Down>*
g<Down> [count] display lines downward. |exclusive| motion.
Differs from 'j' when lines wrap, and when used with
an operator, because it's not linewise.
*-*
`-` <minus> [count] lines upward, on the first non-blank
character |linewise|.
`+` or *+*
CTRL-M or *CTRL-M* *<CR>*
<CR> [count] lines downward, on the first non-blank
character |linewise|.
*_*
_ <underscore> [count] - 1 lines downward, on the first non-blank
character |linewise|.
*G*
G Goto line [count], default last line, on the first
non-blank character |linewise|. If 'startofline' not
set, keep the same column.
G is one of the |jump-motions|.
*<C-End>*
<C-End> Goto line [count], default last line, on the last
character |inclusive|.
<C-Home> or *gg* *<C-Home>*
gg Goto line [count], default first line, on the first
non-blank character |linewise|. If 'startofline' not
set, keep the same column.
*:[range]*
:[range] Set the cursor on the last line number in [range].
In Ex mode, print the lines in [range].
[range] can also be just one line number, e.g., ":1"
or ":'m".
In contrast with |G| this command does not modify the
|jumplist|.
*N%*
{count}% Go to {count} percentage in the file, on the first
non-blank in the line |linewise|. To compute the new
line number this formula is used:
({count} * number-of-lines + 99) / 100
See also 'startofline' option.
:[range]go[to] [count] *:go* *:goto* *go*
[count]go Go to [count] byte in the buffer. |exclusive| motion.
Default [count] is one, start of the file. When
giving [range], the last number in it used as the byte
count. End-of-line characters are counted depending
on the current 'fileformat' setting.
Also see the |line2byte()| function, and the 'o'
option in 'statusline'.
These commands move to the specified line. They stop when reaching the first
or the last line. The first two commands put the cursor in the same column
(if possible) as it was after the last command that changed the column,
except after the "$" command, then the cursor will be put on the last
character of the line.
==============================================================================
4. Word motions *word-motions*
<S-Right> or *<S-Right>* *w*
w [count] words forward. |exclusive| motion.
<C-Right> or *<C-Right>* *W*
W [count] WORDS forward. |exclusive| motion.
*e*
e Forward to the end of word [count] |inclusive|.
Does not stop in an empty line.
*E*
E Forward to the end of WORD [count] |inclusive|.
Does not stop in an empty line.
<S-Left> or *<S-Left>* *b*
b [count] words backward. |exclusive| motion.
<C-Left> or *<C-Left>* *B*
B [count] WORDS backward. |exclusive| motion.
*ge*
ge Backward to the end of word [count] |inclusive|.
*gE*
gE Backward to the end of WORD [count] |inclusive|.
These commands move over words or WORDS.
*word*
A word consists of a sequence of letters, digits and underscores, or a
sequence of other non-blank characters, separated with white space (spaces,
tabs, <EOL>). This can be changed with the 'iskeyword' option. An empty line
is also considered to be a word.
*WORD*
A WORD consists of a sequence of non-blank characters, separated with white
space. An empty line is also considered to be a WORD.
A sequence of folded lines is counted for one word of a single character.
"w" and "W", "e" and "E" move to the start/end of the first word or WORD after
a range of folded lines. "b" and "B" move to the start of the first word or
WORD before the fold.
Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is
on a non-blank. This is Vi-compatible, see |cpo-_| to change the behavior.
Another special case: When using the "w" motion in combination with an
operator and the last word moved over is at the end of a line, the end of
that word becomes the end of the operated text, not the first word in the
next line.
The original Vi implementation of "e" is buggy. For example, the "e" command
will stop on the first character of a line if the previous line was empty.
But when you use "2e" this does not happen. In Vim "ee" and "2e" are the
same, which is more logical. However, this causes a small incompatibility
between Vi and Vim.
==============================================================================
5. Text object motions *object-motions*
*(*
( [count] |sentence|s backward. |exclusive| motion.
*)*
) [count] |sentence|s forward. |exclusive| motion.
*{*
{ [count] |paragraph|s backward. |exclusive| motion.
*}*
} [count] |paragraph|s forward. |exclusive| motion.
*]]*
]] [count] |section|s forward or to the next "{" in the
first column. When used after an operator, then also
stops below a "}" in the first column. |exclusive|
Note that |exclusive-linewise| often applies.
*][*
][ [count] |section|s forward or to the next '}' in the
first column. |exclusive|
Note that |exclusive-linewise| often applies.
*[[*
[[ [count] |section|s backward or to the previous "{" in
the first column. |exclusive|
Note that |exclusive-linewise| often applies.
*[]*
[] [count] |section|s backward or to the previous "}" in
the first column. |exclusive|
Note that |exclusive-linewise| often applies.
These commands move over three kinds of text objects.
*sentence*
A sentence is defined as ending at a '.', '!' or '?' followed by either the
end of a line, or by a space or tab. Any number of closing ')', ']', '"'
and ''' characters may appear after the '.', '!' or '?' before the spaces,
tabs or end of line. A paragraph and section boundary is also a sentence
boundary.
If the 'J' flag is present in 'cpoptions', at least two spaces have to
follow the punctuation mark; <Tab>s are not recognized as white space.
The definition of a sentence cannot be changed.
*paragraph*
A paragraph begins after each empty line, and also at each of a set of
paragraph macros, specified by the pairs of characters in the 'paragraphs'
option. The default is "IPLPPPQPP TPHPLIPpLpItpplpipbp", which corresponds to
the macros ".IP", ".LP", etc. (These are nroff macros, so the dot must be in
the first column). A section boundary is also a paragraph boundary.
Note that a blank line (only containing white space) is NOT a paragraph
boundary.
Note: this does not include a '{' or '}' in the first column.
*section*
A section begins after a form-feed (<C-L>) in the first column and at each of
a set of section macros, specified by the pairs of characters in the
'sections' option. The default is "SHNHH HUnhsh", which defines a section to
start at the nroff macros ".SH", ".NH", ".H", ".HU", ".nh" and ".sh".
The "]]" and "[[" commands stop at the '{' in the first column. This is
useful to find the start of a function in a C program. To search for a '}' in
the first column, the end of a C function, use "][" (forward) or "[]"
(backward). Note that the first character of the command determines the
search direction.
If your '{' or '}' are not in the first column, and you would like to use "[["
and "]]" anyway, try these mappings: >
:map [[ ?{<CR>w99[{
:map ][ /}<CR>b99]}
:map ]] j0[[%/{<CR>
:map [] k$][%?}<CR>
[type these literally, see |<>|]
==============================================================================
6. Text object selection *object-select* *text-objects*
*v_a* *v_i*
This is a series of commands that can only be used while in Visual mode or
after an operator. The commands that start with "a" select "a"n object
including white space, the commands starting with "i" select an "inner" object
without white space, or just the white space. Thus the "inner" commands
always select less text than the "a" commands.
Also see `gn` and `gN`, operating on the last search pattern.
*v_aw* *aw*
aw "a word", select [count] words (see |word|).
Leading or trailing white space is included, but not
counted.
When used in Visual linewise mode "aw" switches to
Visual charwise mode.
*v_iw* *iw*
iw "inner word", select [count] words (see |word|).
White space between words is counted too.
When used in Visual linewise mode "iw" switches to
Visual charwise mode.
*v_aW* *aW*
aW "a WORD", select [count] WORDs (see |WORD|).
Leading or trailing white space is included, but not
counted.
When used in Visual linewise mode "aW" switches to
Visual charwise mode.
*v_iW* *iW*
iW "inner WORD", select [count] WORDs (see |WORD|).
White space between words is counted too.
When used in Visual linewise mode "iW" switches to
Visual charwise mode.
*v_as* *as*
as "a sentence", select [count] sentences (see
|sentence|).
When used in Visual mode it is made charwise.
*v_is* *is*
is "inner sentence", select [count] sentences (see
|sentence|).
When used in Visual mode it is made charwise.
*v_ap* *ap*
ap "a paragraph", select [count] paragraphs (see
|paragraph|).
Exception: a blank line (only containing white space)
is also a paragraph boundary.
When used in Visual mode it is made linewise.
*v_ip* *ip*
ip "inner paragraph", select [count] paragraphs (see
|paragraph|).
Exception: a blank line (only containing white space)
is also a paragraph boundary.
When used in Visual mode it is made linewise.
a] *v_a]* *v_a[* *a]* *a[*
a[ "a [] block", select [count] '[' ']' blocks. This
goes backwards to the [count] unclosed '[', and finds
the matching ']'. The enclosed text is selected,
including the '[' and ']'. The |cpo-M| option flag
is used to handle escaped brackets.
When used in Visual mode it is made charwise.
i] *v_i]* *v_i[* *i]* *i[*
i[ "inner [] block", select [count] '[' ']' blocks. This
goes backwards to the [count] unclosed '[', and finds
the matching ']'. The enclosed text is selected,
excluding the '[' and ']'. It's an error to select an
empty inner block like "[]". The |cpo-M| option flag
is used to handle escaped brackets.
When used in Visual mode it is made charwise.
a) *v_a)* *a)* *a(*
a( *vab* *v_ab* *v_a(* *ab*
ab "a block", select [count] blocks, from "[count] [(" to
the matching ')', including the '(' and ')' (see
|[(|). Does not include white space outside of the
parenthesis. The |cpo-M| option flag is used to
handle escaped parenthesis.
When used in Visual mode it is made charwise.
i) *v_i)* *i)* *i(*
i( *vib* *v_ib* *v_i(* *ib*
ib "inner block", select [count] blocks, from "[count] [("
to the matching ')', excluding the '(' and ')' (see
|[(|). If the cursor is not inside a () block, then
find the next "(". It's an error to select an empty
inner block like "()". The |cpo-M| option flag
is used to handle escaped parenthesis.
When used in Visual mode it is made charwise.
a> *v_a>* *v_a<* *a>* *a<*
a< "a <> block", select [count] <> blocks, from the
[count]'th unmatched '<' backwards to the matching
'>', including the '<' and '>'. The |cpo-M| option flag
is used to handle escaped '<' and '>'.
When used in Visual mode it is made charwise.
i> *v_i>* *v_i<* *i>* *i<*
i< "inner <> block", select [count] <> blocks, from
the [count]'th unmatched '<' backwards to the matching
'>', excluding the '<' and '>'. It's an error to
select an empty inner block like "<>". The |cpo-M|
option flag is used to handle escaped '<' and '>'.
When used in Visual mode it is made charwise.
*v_at* *at*
at "a tag block", select [count] tag blocks, from the
[count]'th unmatched "<aaa>" backwards to the matching
"</aaa>", including the "<aaa>" and "</aaa>".
See |tag-blocks| about the details.
When used in Visual mode it is made charwise.
*v_it* *it*
it "inner tag block", select [count] tag blocks, from the
[count]'th unmatched "<aaa>" backwards to the matching
"</aaa>", excluding the "<aaa>" and "</aaa>".
See |tag-blocks| about the details.
When used in Visual mode it is made charwise.
a} *v_a}* *a}* *a{*
a{ *v_aB* *v_a{* *aB*
aB "a Block", select [count] Blocks, from `[count] [{` to
the matching "}", including the "{" and "}" (see
|[{|). The |cpo-M| option flag is used to handle
escaped braces.
When used in Visual mode it is made charwise.
i} *v_i}* *i}* *i{*
i{ *v_iB* *v_i{* *iB*
iB "inner Block", select [count] Blocks, from `[count] [{`
to the matching "}", excluding the "{" and "}" (see
|[{|). It"s an error to select an empty inner block
like "{}". The |cpo-M| option flag is used to handle
escaped braces.
When used in Visual mode it is made charwise.
a" *v_aquote* *aquote*
a' *v_a'* *a'*
a` *v_a`* *a`*
"a quoted string". Selects the text from the previous
quote until the next quote. The 'quoteescape' option
is used to skip escaped quotes.
Only works within one line.
When the cursor starts on a quote, Vim will figure out
which quote pairs form a string by searching from the
start of the line.
Any trailing white space is included, unless there is
none, then leading white space is included.
When used in Visual mode it is made charwise.
Repeating this object in Visual mode another string is
included. A count is currently not used.
i" *v_iquote* *iquote*
i' *v_i'* *i'*
i` *v_i`* *i`*
Like a", a' and a`, but exclude the quotes and
repeating won't extend the Visual selection.
Special case: With a count of 2 the quotes are
included, but no extra white space as with a"/a'/a`.
*o_object-select*
When used after an operator:
For non-block objects:
For the "a" commands: The operator applies to the object and the white
space after the object. If there is no white space after the object
or when the cursor was in the white space before the object, the white
space before the object is included.
For the "inner" commands: If the cursor was on the object, the
operator applies to the object. If the cursor was on white space, the
operator applies to the white space.
For a block object:
The operator applies to the block where the cursor is in, or the block
on which the cursor is on one of the braces. For the "inner" commands
the surrounding braces are excluded. For the "a" commands, the braces
are included.
*v_object-select*
When used in Visual mode:
When start and end of the Visual area are the same (just after typing "v"):
One object is selected, the same as for using an operator.
When start and end of the Visual area are not the same:
For non-block objects the area is extended by one object or the white
space up to the next object, or both for the "a" objects. The
direction in which this happens depends on which side of the Visual
area the cursor is. For the block objects the block is extended one
level outwards.
For illustration, here is a list of delete commands, grouped from small to big
objects. Note that for a single character and a whole line the existing vi
movement commands are used.
"dl" delete character (alias: "x") |dl|
"diw" delete inner word *diw*
"daw" delete a word *daw*
"diW" delete inner WORD (see |WORD|) *diW*
"daW" delete a WORD (see |WORD|) *daW*
"dgn" delete the next search pattern match *dgn*
"dd" delete one line |dd|
"dis" delete inner sentence *dis*
"das" delete a sentence *das*
"dib" delete inner '(' ')' block *dib*
"dab" delete a '(' ')' block *dab*
"dip" delete inner paragraph *dip*
"dap" delete a paragraph *dap*
"diB" delete inner '{' '}' block *diB*
"daB" delete a '{' '}' block *daB*
Note the difference between using a movement command and an object. The
movement command operates from here (cursor position) to where the movement
takes us. When using an object the whole object is operated upon, no matter
where on the object the cursor is. For example, compare "dw" and "daw": "dw"
deletes from the cursor position to the start of the next word, "daw" deletes
the word under the cursor and the space after or before it.
Tag blocks *tag-blocks*
For the "it" and "at" text objects an attempt is done to select blocks between
matching tags for HTML and XML. But since these are not completely compatible
there are a few restrictions.
The normal method is to select a <tag> until the matching </tag>. For "at"
the tags are included, for "it" they are excluded. But when "it" is repeated
the tags will be included (otherwise nothing would change). Also, "it" used
on a tag block with no contents will select the leading tag.
"<aaa/>" items are skipped. Case is ignored, also for XML where case does
matter.
In HTML it is possible to have a tag like <br> or <meta ...> without a
matching end tag. These are ignored.
The text objects are tolerant about mistakes. Stray end tags are ignored.
==============================================================================
7. Marks *mark-motions* *E20* *E78*
Jumping to a mark can be done in two ways:
1. With ` (backtick): The cursor is positioned at the specified location
and the motion is |exclusive|.
2. With ' (single quote): The cursor is positioned on the first non-blank
character in the line of the specified location and
the motion is linewise.
*mark-view*
3. Apart from the above if 'jumpoptions' contains "view", they will also try to
restore the mark view. This is the number of lines between the cursor position
and the window topline (first buffer line displayed in the window) when it was
set.
*m* *mark* *Mark*
m{a-zA-Z} Set mark {a-zA-Z} at cursor position (does not move
the cursor, this is not a motion command).
*m'* *m`*
m' or m` Set the previous context mark. This can be jumped to
with the "''" or "``" command (does not move the
cursor, this is not a motion command).
*m[* *m]*
m[ or m] Set the |'[| or |']| mark. Useful when an operator is
to be simulated by multiple commands. (does not move
the cursor, this is not a motion command).
*m<* *m>*
m< or m> Set the |'<| or |'>| mark. Useful to change what the
`gv` command selects. (does not move the cursor, this
is not a motion command).
Note that the Visual mode cannot be set, only the
start and end position.
*:ma* *:mark* *E191*
:[range]ma[rk] {a-zA-Z'}
Set mark {a-zA-Z'} at last line number in [range],
column 0. Default is cursor line.
*:k*
:[range]k{a-zA-Z'} Same as :mark, but the space before the mark name can
be omitted.
*'* *'a* *`* *`a*
'{a-z} `{a-z} Jump to the mark {a-z} in the current buffer.
*'A* *'0* *`A* *`0*
'{A-Z0-9} `{A-Z0-9} To the mark {A-Z0-9} in the file where it was set (not
a motion command when in another file).
*g'* *g'a* *g`* *g`a*
g'{mark} g`{mark}
Jump to the {mark}, but don't change the jumplist when
jumping within the current buffer. Example: >
g`"
< jumps to the last known position in a file.
See also |:keepjumps|.
*:marks*
:marks List all the current marks (not a motion command).
The |'(|, |')|, |'{| and |'}| marks are not listed.
The first column has number zero.
*E283*
:marks {arg} List the marks that are mentioned in {arg} (not a
motion command). For example: >
:marks aB
< to list marks 'a' and 'B'.
*:delm* *:delmarks*
:delm[arks] {marks} Delete the specified marks. Marks that can be deleted
include A-Z and 0-9. You cannot delete the ' mark.
They can be specified by giving the list of mark
names, or with a range, separated with a dash. Spaces
are ignored. Examples: >
:delmarks a deletes mark a
:delmarks a b 1 deletes marks a, b and 1
:delmarks Aa deletes marks A and a
:delmarks p-z deletes marks in the range p to z
:delmarks ^.[] deletes marks ^ . [ ]
:delmarks \" deletes mark "
<
:delm[arks]! Delete all marks for the current buffer, but not marks
A-Z or 0-9. Also clear the |changelist|.
A mark is not visible in any way. It is just a position in the file that is
remembered. Do not confuse marks with named registers, they are totally
unrelated.
'a - 'z lowercase marks, valid within one file
'A - 'Z uppercase marks, also called file marks, valid between files
'0 - '9 numbered marks, set from .shada file
Lowercase marks 'a to 'z are remembered as long as the file remains in the
buffer list. If you remove the file from the buffer list, all its marks are
lost. If you delete a line that contains a mark, that mark is erased.
Lowercase marks can be used in combination with operators. For example: "d't"
deletes the lines from the cursor position to mark 't'. Hint: Use mark 't' for
Top, 'b' for Bottom, etc.. Lowercase marks are restored when using undo and
redo.
Uppercase marks 'A to 'Z include the file name. You can use them to jump from
file to file. You can only use an uppercase mark with an operator if the mark
is in the current file. The line number of the mark remains correct, even if
you insert/delete lines or edit another file for a moment. When the 'shada'
option is not empty, uppercase marks are kept in the .shada file. See
|shada-file-marks|.
Numbered marks '0 to '9 are quite different. They can not be set directly.
They are only present when using a shada file |shada-file|. Basically '0
is the location of the cursor when you last exited Vim, '1 the last but one
time, etc. Use the "r" flag in 'shada' to specify files for which no
Numbered mark should be stored. See |shada-file-marks|.
*'[* *`[*
'[ `[ To the first character of the previously changed
or yanked text.
*']* *`]*
'] `] To the last character of the previously changed or
yanked text.
After executing an operator the Cursor is put at the beginning of the text
that was operated upon. After a put command ("p" or "P") the cursor is
sometimes placed at the first inserted line and sometimes on the last inserted
character. The four commands above put the cursor at either end. Example:
After yanking 10 lines you want to go to the last one of them: "10Y']". After
inserting several lines with the "p" command you want to jump to the lowest
inserted line: "p']". This also works for text that has been inserted.
Note: After deleting text, the start and end positions are the same, except
when using blockwise Visual mode. These commands do not work when no change
was made yet in the current file.
*'<* *`<*
'< `< To the first line or character of the last selected
Visual area in the current buffer. For block mode it
may also be the last character in the first line (to
be able to define the block).
*'>* *`>*
'> `> To the last line or character of the last selected
Visual area in the current buffer. For block mode it
may also be the first character of the last line (to
be able to define the block). Note that 'selection'
applies, the position may be just after the Visual
area.
*''* *``*
'' `` To the position before the latest jump, or where the
last "m'" or "m`" command was given. Not set when the
|:keepjumps| command modifier was used.
Also see |restore-position|.
*'quote* *`quote*
'" `" To the cursor position when last exiting the current
buffer. Defaults to the first character of the first
line. See |last-position-jump| for how to use this
for each opened file.
Only one position is remembered per buffer, not one
for each window. As long as the buffer is visible in
a window the position won't be changed. Mark is also
reset when |:wshada| is run.
*'^* *`^*
'^ `^ To the position where the cursor was the last time
when Insert mode was stopped. This is used by the
|gi| command. Not set when the |:keepjumps| command
modifier was used.
*'.* *`.*
'. `. To the position where the last change was made. The
position is at or near where the change started.
Sometimes a command is executed as several changes,
then the position can be near the end of what the
command changed. For example when inserting a word,
the position will be on the last character.
To jump to older changes use |g;|.
*'(* *`(*
'( `( To the start of the current sentence, like the |(|
command.
*')* *`)*
') `) To the end of the current sentence, like the |)|
command.
*'{* *`{*
'{ `{ To the start of the current paragraph, like the |{|
command.
*'}* *`}*
'} `} To the end of the current paragraph, like the |}|
command.
These commands are not marks themselves, but jump to a mark:
*]'*
]' [count] times to next line with a lowercase mark below
the cursor, on the first non-blank character in the
line.
*]`*
]` [count] times to lowercase mark after the cursor.
*['*
[' [count] times to previous line with a lowercase mark
before the cursor, on the first non-blank character in
the line.
*[`*
[` [count] times to lowercase mark before the cursor.
:loc[kmarks] {command} *:loc* *:lock* *:lockmarks*
Execute {command} without adjusting marks. This is
useful when changing text in a way that the line count
will be the same when the change has completed.
WARNING: When the line count does change, marks below
the change will keep their line number, thus move to
another text line.
These items will not be adjusted for deleted/inserted
lines:
- lower case letter marks 'a - 'z
- upper case letter marks 'A - 'Z
- numbered marks '0 - '9
- last insert position '^
- last change position '.
- last affected text area '[ and ']
- the Visual area '< and '>
- line numbers in placed signs
- line numbers in quickfix positions
- positions in the |jumplist|
- positions in the |tagstack|
These items will still be adjusted:
- previous context mark ''
- the cursor position
- the view of a window on a buffer
- folds
- diffs
:kee[pmarks] {command} *:kee* *:keep* *:keepmarks*
Currently only has effect for the filter command
|:range!|:
- When the number of lines after filtering is equal to
or larger than before, all marks are kept at the
same line number.
- When the number of lines decreases, the marks in the