-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvile.hlp
7218 lines (5881 loc) · 344 KB
/
vile.hlp
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
Getting along with vile version 9.8
----------------------- -----------
Getting along with vile
Use Ctrl-D and Ctrl-U to scroll through this help information.
Type Ctrl-O to make this the only window on the screen. Type Ctrl-K to get
rid of this window.
First, to leave vile, use any of the following:
:q
:quit
:exit
:wq
(writes current buffer before quitting)
:q!
(quits without writing any changes!)
Q
:wwq or ZZ
(will write all changed buffers)
^X-^C
(don't know why. They don't put in ":q" for us! Actually, if ^C is
your interrupt character, this won't get you out of vile.)
To get help (probably just this text), use any of:
:h
:help
^X-h
^A-h
The only vile commands described herein are those not present in vi, or
differing greatly from those in vi. There is a section at the bottom
describing other differences between vile and vi.
To get a complete list of all commands, type ":show-commands". To get a
list of all commands that contain the string "name", type ":apropos name".
These lists will show all command synonyms and key sequences that are
bound to the same function, along with a short description of the command,
and whether it is a motion or operator command.
To get information on a specific key-binding or function, use the
"describe-key" or "describe-function" commands. You will be asked for a
keystroke or function name, and a short description will be shown.
You needn't type full command names -- type a few characters and hit TAB
to perform command completion. Hitting a second TAB will pop up a window
containing the list of possible completions.
If your screen hops around a lot when you scroll, see the "Note on
Scrolling" section near the bottom of this file.
General Remarks
---------------
vile holds text in "buffers". Usually, these correspond to a file that you
are editing, but not always. For instance, a buffer might be used to
display this help text, or to hold the output of a shell command that you
have run. Buffers have names, and these usually match the names of the
files they contain.
Buffers are sometimes displayed in windows. A buffer may be displayed in
more than one window at the same time. There is no such thing as a hidden
window. All existing windows are on the screen. There may, however, be
hidden buffers, which are not currently associated with any window.
All yank/delete registers (the default unnamed register, the numbered
registers ("1-9") that hold line-deletes, and the named registers ("a-z"))
are global to the editor, and not attached to any single buffer. Thus you
can delete text in one buffer and put it back in another.
Undo operations are attached to a buffer, not a window. Thus if you have
two windows to the same buffer, and make a change in one, you can undo it
in the other.
vile supports many, many "modes" (aka options), which are thoroughly
explained in the section entitled "Editor modes". But do note that this
help file makes references to modes before the concept is fully described.
It's a chicken and egg problem....
vile is 8-bit clean, allowing it to be used more easily at non- English
speaking sites. See the section on "8-Bit Operation" for more information.
Command Prefixes
----------------
To extend the vi command set in vile, two (or three, depending on how you
count them) command "prefixes" exist. These keystrokes, in combination
with another key, can be bound as a pair to execute any vile function. The
default values for these prefixes are
+------------------------------------------------------------------------+
| Key: | Bound to dummy function: |
|----------------------------------+-------------------------------------|
| ^X Control-X | cntl_x-prefix |
|----------------------------------+-------------------------------------|
| ^A Control-A | cntl_a-prefix |
|----------------------------------+-------------------------------------|
| # poundsign | function-prefix |
+------------------------------------------------------------------------+
If you find any of these keys hard to type, or would prefer that they are
all control characters (or all non-control), they can be changed by
binding a new key to the function listed above. See the section on "Key
Rebinding" below. If you do change the values of these keys, most of
vile's informational displays (the Binding List, for instance) will
reflect these changes. This documentation, of course, will not change.
(The '#' key is used in vi to give terminal independent access to function
key bindings. This is also true in vile -- if something is bound to '#2',
then it is also probably available with key F2 on your keyboard.)
Buffer manipulation commands
----------------------------
vile stores buffers in a sorted list. Depending on the setting of the
"autobuffer" mode, this list is either sorted in "most-recently-used"
order (this is the vile default), or in a fixed order dependent on the
order of editing (this is how vi normally does it, and can be attained by
turning "autobuffer" off, with "set noautobuffer").
_
Show a list of the first 9 buffers. Follow this command with a
digit to select that buffer, or simply repeat it ("__") to select
the buffer most-recently visited. In autobuffer mode, this is
identical to "_1". If autobuffer mode is off, the buffer which
will be visited with "__" is flagged with a '#' character in the
list. Modified buffers are preceded by a '*' in the history list.
There are many different ways to get the previous file:
__
_1
(autobuffer mode on)
1_
(autobuffer mode on)
:e#
^^ (ctrl-^)
(but many keyboards can't produce this)
The buffer number may also precede the '_' command. This is
necessary when visiting buffers numbered higher than '9'. For
example, one would type "13_" to visit buffer 13 in the list.
Use tab (or back-tab if supported) to scroll the list of 9 buffers
right/left. Pressing '_' will select the first listed buffer; the
1-9 digits also work as expected when the list is scrolled.
[ See the note under "Differences", below, for comments on vi's
use of '_'.]
:e
Edit a file. If the file is already in a buffer, that buffer will
be recalled into the current window. This occurs as follows: If
the name given contains no path delimiters (i.e. slashes), then it
will be compared to the existing vile buffer names. Failing that
comparison (or if there are any slashes in the name), the name
will be stretched into an absolute path, and will be compared to
the existing buffers' filenames. In either case, the matching
buffer will be chosen. If there are no such matches, the file will
be fetched from the filesystem. This matching technique introduces
an ambiguity, since buffer names are created from the last path
component of filenames. To force vile to edit a file from the
current directory whose basename matches that of one that was
edited elsewhere, simply preface the name with "./". For example,
if you edit "../Makefile" and later attempt to edit "Makefile",
vile will assume you are referring to the _buffer_ named
"Makefile". To get the file in the current directory, specify
"./Makefile".
:e!
Re-edit a file. A different filename can be given, and the buffer
name will change to match it. This command is not as necessary in
vile as it is in vi, since multiple buffers may have outstanding
unwritten changes.
^X-_
Identical to '_', except that the selected buffer is placed in the
current window (windows are described in the next help topic).
This is most useful when:
* two windows show a different view of the same buffer (for
illustration's sake, call the views "A" and "B").
* :e is used to open a new buffer (call this view "C"), which
obscures "A".
* eventually, you decide to return to "A" and "B".
^X-_1 does the trick (reverts to views "A" and "B"), but _1 simply
moves the cursor into B's window, retaining views "C" and "B".
:n
Go to the next buffer. "Next" means "least recently used" in
autobuffer mode. In noautobuffer mode, "next" means next in
numeric sequence. (The ":n file ..." version of the command is not
supported.)
:rename-buffer
Rename the current buffer. Prompts for a new name. Does not affect
the filename associated with the buffer. Use ":f" to do that. This
command is useful for renaming the "[Output]" buffer, if you wish
to preserve its contents, but run a new command.
:set-window
Set the current window to the specified buffer. This is useful
especially when you have split the screen into a number of windows
and want to override the automatic layout of "#" and "%" buffers.
:rewind
Go to the first buffer. This is used only in 'noautobuffer'
(vi-style buffering) mode. It does nothing in "autobuffer" mode.
Remember that "autobuffer" mode is the default.
:unmark-buffer
Clears the "modified" status of a buffer. Useful for the creation
of temporary buffer(s) that are discarded when the editor exits.
:b
Edit a buffer. Recalls the named buffer. Does not look for a file
of that name. Will find "invisible" buffers.
:ki
Kill a buffer. Remove the buffer and its contents from the editor.
Will ask if changes to the buffer should be discarded. Multiple
buffer names may be specified via wildcards (e.g., :ki *.log) and
individual buffer names may be selected via name completion (using
the same conventions as in filename completion, described below).
^X-e
Edit the file whose pathname appears under the cursor. For
example, if you are editing a makefile, you could edit one of the
source files by placing the cursor at the start of its name and
using this command. Note that this does not know about some
characters that your shell might usually translate for you, like
the '$' in '$HOME'.
^X-k
Kill the buffer whose name or filename appears under the cursor.
*
Display a list of all buffers, or make that display go away if
it's already present. Leave your finger on the key, and it's easy
to create and destroy the list. The buffers are numbered; the
numbers correspond to the history numbers shown and used by the
'_' command, described above. (If the buffer number is greater
than 9, then the "nn_" form of the '_' command must be used, since
'_' will only accept a single following digit.) The order of the
list is either most-recently-used, or fixed, depending on the
setting of "autobuffer" mode (see below). vile attempts to keep
the contents of the buffer list window up to date if it is left up
on the screen while other buffer manipulation commands are given.
^A-*
Always display a list of all buffers. Useful for updating the list
if it's already on the screen but may be out of date. Any argument
will cause the list to include _all_ buffers, even those normally
considered "invisible". (For example, macros are stored in
"invisible" buffers.) [This command isn't as necessary now that
the buffer list is maintained dynamically...]
Window manipulation commands
----------------------------
^X-2
Make Two windows. Splits the current window in half. This is the
usual way to create a new window.
^K or ^X-0
Get rid of (Kill) this window.
^O or ^X-1
Make this the Only window on the screen.
^X-o
Move to the next window.
^X-O
Move to the previous window.
v
Make the current window smaller.
V
Make the current window larger.
^A-^D
Scroll the next window down half a screen.
^A-^U
Scroll the next window up half a screen.
^A-^E
Scroll the next window up one line.
^A-^Y
Scroll the next window down one line.
(The previous four commands are useful when comparing two buffers.
Mnemonic - think of them as affecting the "A"lternate window.)
zH zM zL
zt zm zb
These are synonyms for vi's 'z+', 'z.', and 'z-', which position
the line holding the cursor at the top, middle, or bottom of the
screen, respectively. (Any of the second characters can be upper
or lower case.) Mnemonically, these correspond to the H, M, and L
screen positioning commands, or to "top", "middle", or "bottom" -
take your choice. In a macro, only the first character of the
argument is significant, but something like "position-window
middle" is most readable. Supplying a count will offset that far
from the top or bottom of window. (But the middle is always the
middle.)
^X-^R
^X-^L
Scroll the window right or left by 1/3 of a screen, or by the
number of columns specified. Changes the "sideways" value. Neither
of these commands will actually move the cursor in the buffer -
they only reframe your view into the buffer. If the cursor would
be forced to move off-screen (which is of course impossible and
undesirable) as a result of the requested sideways scroll, then
nothing at all will happen. The commands are arguably crippled as
is.
If for some reason you can't get your screen set right via a TERM
variable, try the ":screen-rows" or ":screen-columns" commands (which take
their args (number of rows or columns respectively) before you type the
":").
[ I put the following bindings in my startup file (.vilerc):
bind-key split-current-window ^T ; split into 'T'wo windows
bind-key next-window ^N ; 'N'ext window
bind-key previous-window ^P ; 'P'revious window
Since ^K already 'K'ills a window, and ^O makes it the 'O'nly window,
these give more mnemonic, and faster, access to multiple windows. (These
would be the default, but ^N, ^P, and ^T have other meanings in real vi
(all of which have alternate bindings in vile.) ]
File manipulation commands:
---------------------------
The usual ":e", ":r", ":f", ":w" commands are available, though only ":e!"
and ":w!" are available of the "!" options. The command ":w >> filename"
appends one file to another. The ":r" command reads the named file in
after the current line. To read a file before the first line, use ":0r".
File completion works like command completion: using the TAB and '?' keys
you can complete or see next character choices. Additionally, on unix
hosts, backquotes may be used to invoke a shell command that returns the
path of a desired file. For example:
:e `which locks` ; csh looks for script called "locks"
:e `type -path locks` ; bash equivalent
The commands ":ww" and ":wwq" correspond roughly to ":w" and ":wq", but
they each write all modified buffers, rather than just the current one.
Giving any numeric argument to ":ww" (i.e. "1:ww") will suppress the
per-file and "Press return to continue" message. This may be useful when
using the command from within a macro.
The write-all-buffers command attempts to write all buffers whether marked
"modified" or not.
As in vi, ranges of lines specified by line numbers (including '.', '$',
and '%' shorthands) or marks may precede these commands. Unlike vi, search
patterns cannot be used as line specifiers.
In addition, two non-"colon" commands have been added:
^R
Prompts for a filename, and then reads it in _above_ the current
line. If a register is specified (e.g., "a^R ), the file is read
into that named register, but not inserted into the current
buffer.
^W
is a writing operator, which prompts for a filename, and writes
the specified region to that file. Like all operators, if the
command is repeated, as in ^W^W, then lines are affected. Use
10^W^W to write 10 lines.
If a register is specified (e.g. "a^W ) then the command is _not_
an operator, but writes the specified register to the named file.
Shell Access
------------
Anywhere a filename is valid, a command name is also valid, entered in the
form "!shell-command". The whole line is handed to the shell, and the read
or write operation is done on the commands standard input or output, as
appropriate. Thus you can type ":e !date" to edit a copy of today's date.
The ": !cmd" shell escape works pretty much as it does in vi. The command
":!!" will rerun the previous such shell command.
The '!' operator works as a filter, as expected.
In addition, the ^X-! command runs a shell command and captures its output
in a specific buffer, called "[Output]". This is almost identical to ":e
!cmd", except that in that case the buffer is named according to the
command name.
These "output capture" commands are most useful in conjunction with the
"error finder", '^X-^X', described below.
Filename completion is performed on words of the shell command in response
to a TAB character. To actually include a TAB character in the shell
command, escape it with ^V. Command completion is not currently
implemented - so, for instance, $PATH is not searched for possible
completions to the first word of a command line.
On systems supporting job control, ^Z (or ":stop") will suspend vile.
The "set-environment-variable" (or "setenv") command can be used to export
new or changed environment values to spawned programs. (Note that this
might or might not affect the operation of vile features that are
themselves controlled by environment variables, since those variables may
only be checked once at the time that vile is started.)
The :cd and :pwd commands are of course supported. Unlike vi, filenames
will track their directory of origin, so you can't simply edit a file in
one directory, cd to another, and write it. You must explicitly write to
./filename in the new directory to accomplish this. ":cd -" will return to
the previous directory, as it does in some shells. The CDPATH environment
variable provides a search path for the :cd command. This variable's path
delimiters are host-specific, as follows:
+------------------------------------------------------------------------+
| Unix | colon |
|-------------------------------------+----------------------------------|
| DOS, OS/2, Win32 | semicolon |
|-------------------------------------+----------------------------------|
| VMS | comma |
+------------------------------------------------------------------------+
Giving an argument to the ": !" (also called "shell-command" when writing
macros) will suppress the "Press return to continue" message after the
command runs.
Additional shell-related features are described in the section of this
help file entitled "Working in a project hierarchy".
Text manipulation command:
--------------------------
Remember, these are only the new or different commands. The standard vi
set should still work.
The vi "global" (":g") command is present. So is the "substitute" (":s")
command. These both look pretty different while they're being used than
they do in vi, due to the interactive nature of the prompting. And, since
the searching is done right after the pattern is entered, there may be a
slight delay while you're trying to finish typing your complete command.
(If the pattern does not exist, you may not get to finish typing your
command at all.) You can use the commands just as you would have in vi,
i.e. ":g/oldpat/s//newstring/" will work. But you won't see any of the '/'
characters. Try it- you'll get the idea. Line ranges are not possible on
":g", but they are on ":s".
The ":g" command can be followed by any of l (list), p (print), < (left
shift), > (right shift), r (read file), d (delete), L (lower case), U
(upper case), ~ (flip case), put (append yanked text), Put (prepend yanked
text), s (substitute), trim (trim trailing whitespace). For example,
":g/pattern/Put" will insert the contents of the default yank register
just above every line containing "pattern". The ":g" command can only be
used over the entire file - smaller regions are not permitted.
The ":v" counterpart to ":g" is also implemented - it performs the given
command on all lines that don't match the given pattern.
The substitute command can be followed by any of 'g', a digit, or 'p', to
do the substitution for all occurrences, the n'th occurrence, or to print
the resulting line respectively. You can also add a 'c', and you will be
asked to confirm each replacement before it occurs. The text being
replaced will be highlighted, and you can answer with 'y', 'n', 'q', or
'a'. 'a' will suppress further prompting, and will do the rest of the
replacements.
The ":&" and '&' commands work much as they do in vi, and repeat the last
substitution. The '^A-&' command is a new operator (see below), so it can
work on regions: for example use '^A-&}' to "repeat the previous
substitution over the rest of this paragraph".
The named marks such as "'a" work as they do in vi. vile allows a decimal
digit as a mark. It also recognizes special marks for the beginning and
end of a selection: '< for the beginning and '> for the end (see the
discussion of the quoted motion command).
Infinite Undo
The regular undo ('u') and line-undo ('U') are available for all commands.
They are a little more predictable than their vi counterparts, since they
do not share the default yank register for their operation. Also,
line-undo ('U') is available until the next change anywhere in the file,
rather than until you leave the line.
vile also lets you undo all changes made to a buffer since it was first
edited (so-called "infinite undo"). The '^X-u' command will undo changes,
one by one (or given a count, several at a time). The '^X-r' command will
walk forward, redoing the previously undone changes one by one. A fresh
change to the buffer will cause previously undone changes to no longer be
redoable. Remember that with key rebinding, you can change your 'u' or 'U'
command to be an infinite undo, making it easier to type.
In addition, the '.' command, which normally re-executes the last
buffer-modifying command, has special behavior with respect to undo. If
the '.' command immediately follows one of the undo commands ('u', '^X-u',
or '^X-r'), then it will perform another undo or redo, as appropriate. If
there are any intervening commands, then '.' will re-execute the last
command prior to the undo. [ This modification to the behavior of "u."
does not conflict (much) with traditional use of '.', since by definition,
the sequence "u." is (almost) always identical to "uu", and the latter is
more easily typed. (Credit goes to the designers of "nvi" for this trick.)
(BTW, the one case i know of where "u." is not identical to "uu" is when
putting back the contents of the numbered registers: the sequence
"1pu.u.u.u. would successively insert the contents of "1, "2, "3, "4, and
"5, allowing you to choose the "correct" register. This sequence no longer
works. You can still put them _all_ back with "1p..... ("1p for screen)
and then delete the ones you _don't_ want. ]
The number of changes stored in the undo "history" is controlled by the
numeric mode "undolimit". The default history length is 10 - that is, only
10 changes may be undone. Set the undolimit to 0 for truly infinite undo.
This can consume a lot of memory. You can turn it completely off (and
purge the undo stack) by setting noundoable.
The cursor position after an undo may not always be the same as it would
be in vi.
Operators
vi has a class of commands known as "operators". Operator commands are
always immediately followed by a motion command. The region of text
affected by an operator is bounded on one end by the initial position of
the cursor, and on the other by the cursor position after the motion is
completed. Thus the delete operator ('d') can be followed by the word
motion command ('w'), causing the next word to be deleted. The sequence
"dG" will delete from the cursor through the end of the file, and "d/junk"
will delete to the next occurrence of the string "junk". As a special
"honorary" type of motion, operators can all be "stuttered" to affect
lines. Thus "dd" deletes one line, "4dd" affects 4 lines, etc.
Most operators affect the region exactly, but some cause only whole lines
to be affected. This is usually a function of what sort of motion follows
the operator, but can sometimes be affected by the operator itself. The
best example of motions having different effects is the 'goto-mark'
motions, the ''' and '`' commands. If a mark is set, say mark 'a', with
the 'ma' command, then if the command d`a is executed, the exact text
between the cursor and the mark will be deleted. If, on the other hand,
the d'a command is used, the deleted region will include the lines
containing the cursor and the mark in their entirety.
Some operators in vile can be "forced" to affect regions of whole lines,
though the motion wouldn't normally imply it, by using the '^X' form of
the command. (It's not really forced - it's really a separate operator.)
For example, "d%" (assuming you are on a curly brace) will delete a
C-style block of code. "^X-d%" will delete that same area, plus anything
else on the lines containing the curly-brace endpoints.
Note that some operators always affect whole lines, no matter how the
motion is specified. The '!' operator is an example: "!w" will always
filter an entire line, and not just a single word.
vile extends this notion of the "shape" of a region by adding the concept
of rectangular regions, whose boundaries are delimited by the rectangle
whose opposite corners are at the cursor and at the other end of the
motion, respectively. See the section "Rectangular regions" below.
The "show-operators" command will show all available operators. The
"show-motions" command will show all available motions. Any operator may
be followed by any motion.
There are several new operator commands in vile:
^A-~
Is the operator form of the '~' command, so "^A-~~" changes the
case of all characters on the current line, "^A-~w" does it to a
word, "3^A-~}" does it for 3 paragraphs, etc. (In vile, the simple
'~' command will take a repeat count, unlike some versions of vi.
If you wish it to be an operator, rebind '~' to the "flip-til"
command.)
^A-u
Like ^A-~, but converts the region to upper case.
^A-l
Like ^A-~, but converts the region to lower case.
^A-f
Format the region based on the current fill column. The initial
indentation of both the first and second lines of each "paragraph"
in the region are preserved, and all subsequent lines get the
second line's indentation. This makes indented/outdented
paragraphs (like this one) work correctly. (This is intentionally
_not_ the same behavior obtained by using "!fmt", since that
behavior is obviously available elsewhere.) The usual usage of
this command is "^A-f}", which reformats the current paragraph.
The re-formatting begins again with each new paragraph, where a
paragraph has the same boundaries used by the '{' and '}' commands
- i.e. blank lines, or lines beginning in .I .L .P .Q or .b. This
makes it possible to use "3^A-f}" or "^A-fG" to reformat multiple
paragraphs. The reformatting operation knows a little about both
C, C++, and shell comments, and will attempt to do the "right"
thing with lines that start with '#' or '*' characters. (It also
knows about the '>' character, making it fairly easy to reformat
mail and news inclusions... but is it ethical? :-)
^X-s
For every occurrence of a search string, put in a replace- ment
string. This is similar to "s/pattern/replacement/g" over the
region.
^A-&
Is an operator in vile, similar to the traditional & command. It
repeats the last substitution over the specified region. (Unlike
the '&' command, this one will remember trailing g, p, l, or
numeric options.)
^X-d
Delete the region, including the lines it starts and ends on.
^X-c
Change the region, including the lines it starts and ends on.
^X-y
Yank the region, including the lines it starts and ends on.
^A-t
Trim trailing whitespace from all lines in the region.
^A-<SPACE>
Convert tabs to spaces, using the current tabstop value.
^A-<TAB>
Convert as many spaces to tabs as appropriate.
^A-b
Blank out a region. Turns the region to whitespace. Useful with
rectangular regions.
^A-r
Open up a rectangle. Text to the right of the left edge of the
rectangular region will shift to the right by the width of the
rectangle, leaving a whitespace "hole".
^A-q
Sweep out a rectangle with multiple motion commands. See
description of 'q', below.
^A-s
Select and yank a region. The region will be highlighted on the
screen, as if it had been swept by a mouse. It is also yanked, as
with the 'y' operator. This operator is useful in combination with
the ^S motion command, which lets one reference the selected
region with other operators. (If you use this command much, it is
recommended that you bind it to and easier to type sequence, such
as 'S'.) See also the q (quoted motion) command.
Text insertion
^X-p
Causes the previously yanked or deleted text, no matter how it was
obtained, to be inserted after the current line. Usually text that
did not consist of whole lines where it came from is inserted
immediately following the cursor.
^X-P
As above, but the text is put before the current line. Thus "dw"
followed by a "p" command does a normal insertion of the deleted
word, whereas "^X-p" results in the word being inserted on a line
by itself.
R
vi's overwrite mode is supported. Note that the combination of
overwrite mode and the (ANSI) arrow keys can be used to give a
"picture drawing" mode of operation: anything you type goes into
the buffer without moving adjacent text, and you can move around
using the arrow keys without leaving overwrite mode. Hint: start
with a buffer full of lines that consist entirely of blanks (as
opposed to blank lines).
^A-i
Like their 'i', 'o', and 'O' counterparts, but any autoindent
^A-o
or cmode setting is ignored for the duration of this insert.
^A-O
These are most useful when pre-formatted text is being pasted, as
when using a mouse.
Searching
^X-/
Does a forward search for the "word" located under the cursor.
^X-?
Does a reverse search for the "word" located under the cursor.
^A-/
Does not do a search, but sets the search pattern to the "word"
under the cursor. Useful for "picking up" a word from one buffer,
and searching for it in another.
The following two commands may not always be present in vile, depending on
how it was built:
^X-S
Incremental forward searching. As you enter the search string, the
cursor is advanced to the next match with what you've typed so
far. Use ^F and ^R to continue the search forward or in reverse,
using the current pattern.
^X-R
As above, but in reverse.
Tags
vile supports vi-style "tags" files.
":ta" or ":tag"
allows you to enter a tagname to locate. The editor opens a buffer
containing the requested tag. Take note that tag completion is
supported, so it's possible to type a partial tagname and then
press TAB to force vile to complete the name, assuming it's
unique. If not unique, press TAB twice to see a list of all
possible completions. Example (using the vile sources):
:ta is_sl<tab>
is completed as "is_slashc" . Pressing RETURN following completion
opens a buffer on estruct.h, with the cursor positioned at the
first definition of this tagname.
^]
Uses the identifier currently under the cursor as the tagname.
^T or ^X-^] or ":pop"
- pops to the file and location just previous to the last tag
command.
^A-^] or ":next-tag"
continues searching through the tags file(s) for additional
matches.
When one of these commands is used, vile will (by default) look for a file
named "tags" in the current directory, and load it into a hidden buffer
for use during tag searches. This buffer is editable if you wish (":e
tags"), but will not appear in the buffer lists. If a buffer named "[Tags
1]" is already available when a tag is first requested, it will be used
instead of a file found by searching the tags setting, and of course will
remain visible.
Take note that the tag locate and pop commands, by default, move the
cursor out of the current window if the target tag is located in one of
the editor's other windows. To "pin" all locate and pop actions to the
current window, set pin-tagstack mode.
The name of the default tags file may be changed with "set tags" (see
"tags" under "Editor modes", below). If multiple filenames are given in
the "tags" setting (separated by whitespace), they are searched in order,
and placed in buffers named "[Tags 1]", "[Tags 2]", "[Tags 3]", etc.
Tags searched for using '^]' will always be matched exactly. If the ":ta"
form of the command is used, tag matches will be exact unless the mode
"taglength" is set non-zero, in which case the first tag matching that
many characters will be used.
Filenames referred to in tags files are expanded, so environment variables
and shell special characters like ~ may be used.
The stack of buffer locations waiting to be "popped" to with the '^T' (or
'^X-^]' or ":pop") command may be viewed with the "show-tagstack" command.
The "[Tag Stack]" buffer is animated - it will dynamically keep track of
current tag references.
Limitations: In a real vi-style tags file, there are three tab separated
fields. The first contains the tagname. The second contains the (relative
or absolute) filename. Everything after the second tab is an arbitrary
ex-mode command. vile is not quite so flexible as regular vi, and only
supports a couple of commands in that last "field". It can be a line
number, in which case the tag is an absolute index into the file. Or, it
can be a search command. If it begins with a '/', the search goes forward.
If it begins with a '?', the search goes backward. In either case, the
matching delimiter _must_ be the last character on the line in the tags
file.
All of this isn't as bad as it sounds, since ctags, the program most
people use to generate tags files, does generate exactly this format.
(Surprise, surprise.) However, if you attempt to create your own tags
files, or have other tools that do so, you should be aware of these
limitations.
For further tags usage examples, refer to the section of this help file
entitled "Working in a project hierarchy".
Miscellaneous commands
----------------------
^A-d
Remove blank lines ("deblank"). If the cursor is on a blank line,
then it and any blank lines surrounding it will be removed. If a
non-blank line, then any immediately following blank lines will be
removed. If given an argument, will force exactly that many blank
lines to exist at that point, regardless of how many were there
before. Moves current location forward, to allow repeated use.
^X-^X
The "error finder". Goes to the next file/line error pair
specified in the last buffer captured from a command's output.
This buffer is usually created with the ^X-! command. For example,
"^X-!cc -c junk.c" puts all of the compiler output into the buffer
named "[Output]". Repeatedly hitting ^X-^X will position the
editor at each error in turn, and will eventually start over again
at the top. The buffer searched for "errors" will be the last
shell command run, or the buffer named with the "error- buffer"
command. The "Entering directory XXX" and "Leaving directory XXX"
messages that GNU make puts out with the -w switch are honored, so
that files are found with the correct path. Tip: I use the
following macro to quickly grep a source directory for the string
under the cursor: use-register g load-register "^X!egrep -n :
*.[chs]^M" where the ^X and ^M are each single control characters,
entered using ^V to escape them. Then I invoke with @g to execute.
[NB: this macro won't work with the DOS/VMS/Win32 versions of
vile, since ':' doesn't expand to the word under the cursor on
those hosts due to conflicts with filename drive/disk delimiters.
For those hosts, substitute '&' instead.]
The command parsing is done with regular expressions. Vile
compiles these from the buffer [Error Expressions], which are a
set of regular expressions with extra embedded information.
Unescaped '%' followed by 'V', 'B', 'F', 'L', 'C' or 'T'
substitute verb (Entering/Leaving for gmake), buffer (i.e.,
scratch buffer with a bracketed name), file, line, column and text
fields.
The line and column numbers are 1-based, treating tab character as
a single column. Use %l and %c, respectively for 0-based values.
The V, B, F, T substitutions are for nonblank fields, which is not
always enough, so vile additionally recognizes a range in
brackets, e.g.,
^%[^: ]:\s*%L:%T
is compiled as
^\([^: ]\+\):\s*\([0-9]\+\):\(.\+\)
; example of a macro to add to [Error Expressions]
store-procedure AddError
~local %oldbuffer
setv %oldbuffer=$cbufname
compile-error-expressions
yank-line
edit-file '[Error Expressions]'
unsetl view
goto-beginning-of-file
put-before
unmark
setl view
buffer %oldbuffer
compile-error-expressions
~endm
Use the show-error-expressions command to display the contents of
the [Error Expressions] buffer, along with the expanded regular
expression and annotation for the substitutions. The result is
shown in [Error Patterns].
^X-t
Set or report on the tab-stop width. To set, the spacing must
precede the command, as in "4^X-t". The "set tabstop" command
described below does the same thing. The status output indicates
whether the buffer is currently using the local or global copy of
the tabstop value.
^X-f
Set the local fill-column to be used with ^A-f and auto-wrap mode
on insert. The default value is 7/8's of the screen size, with a
maximum of 70. Since arguments come before commands, you type:
65^X-f. The "set fillcol" command does the same thing. The status
output indicates whether the buffer is currently using the local
or global copy of the tabstop value.
^X-X
Set current encryption key for this buffer. See "Encryption" below
for more information.
K
Count prefix. The first time you type it, it is equivalent to an
argument of 4 to the following command. If you repeat it, it
becomes worth 16, the next time 64, etc...
%
In addition to finding matching braces, brackets, and parentheses,
the '%' command will find matching #if's, #ifdef's and C-style
comments. If the cursor is on the # of "#ifdef"/"#if", the '%'
command will find the matching "#endif" or "#else". On an "#else"
it will find "#endif", and on "#endif" it will go back up to the
"#ifdef"/"#if". If the cursor is on any part of a "/*" or "*/"
sequence, it will find the appropriate corresponding C comment
endpoint. (See fence-if, fence-pairs to customize this behavior).
\
Identical to the ` motion, in that the cursor moves to the
specified mark (i.e. \a moves to mark 'a'). When used with an
operator command, the resulting region is rectangular instead of
"exact". This is similar to the ' motion, which also goes to [the
line holding] the mark, and causes regions to become "full line"
regions.
q
A "quoted motion" command. After entering 'q', more motion
commands are accepted until another 'q' is entered. The result of
the motion is the cumulative effect of all the entered motions.
Thus, one might type:
dq<arrow><arrow><arrow>...<arrow>q
to delete all of the text between the starting point and the final
cursor position.
Any motion command can appear in between the two 'q' commands. If
used alone, i.e., not in an operator context, then the spanned
text is highlighted, and yanked on completion (as well as setting
the special named marks '< and '>) as a side effect. The resulting
selection can then be manipulated with the ^S pseudo-motion,
below. The selection-clear command removes the selection's
highlight attributes.
Most motions will select up to but not including their endpoint.
The 'e', 'E', 'f', 't', and '%' commands are exceptions to this.
If used in an operator context the cursor position may sometimes
appear incorrect. This is because operators sometimes change the
cursor location internally to force the motion to do the "right"
thing, and the 'q' command makes these internal "fudge factors"
visible. An example of this is "dq%q" which does the right thing
(assuming the cursor is on a '(' to start) but which looks wrong,
since the cursor will overshoot the ')' before the second 'q' is
typed.
If a mouse is available on a Unix host, whether in an xterm via
the "xterm-mouse" setting, or in xvile, then button 1 can be
clicked to do the extensions, since it, too, is a motion command.
(Of course in xvile or winvile, it is easier to simply "click and
drag" - the 'q' command isn't really necessary at all.)
Use the repeat-count to specify types of selection: exact=1
(default), full-line=2, rectangle=3.
^A-q
As above, but the motions will sweep out rectangular regions.
^S
A motion, or "pseudo-motion" command. If a region of text has been
previously selected, either with the mouse (if available) or with
the keyboard selection operator (^A-s) it can be referenced by any
other operator by applying that operator to the ^S motion. As an
example, suppose a word is selected with the mouse, or with ^A-sw.
Then, from anywhere in that buffer, one can use d^S to delete that
word. ^S used by itself will move the cursor to the start of the
selected region. ^S applied to the selection operator (^A-s) will
extend the current selection to include the current location of
the cursor.
^S makes it possible to select any region (including rectangular
regions) of text with a mouse, and then apply any vi operator to
that region.
=
If "visual-matches" is set, then vile will highlight all
occurrences of a pattern that is searched for with one of the
usual searching commands. The '=' command will clear this
highlighting, until the next search for a different pattern.
select-all
On hosts where vile provides mouse support, the select-all command
selects, highlights, and yanks all text in the current buffer to
the unnamed register. Clear the selection's highlight attributes
as follows:
+----------------------------------------------------------------+
| Technique | Applies To |
|---------------------------------+------------------------------|
| selection-clear command | any host |
|---------------------------------+------------------------------|
| left mouse button (LMB) click | winvile |
|---------------------------------+------------------------------|
| click mode line with LMB | win32 host |