-
Notifications
You must be signed in to change notification settings - Fork 23
/
README
8974 lines (6857 loc) · 276 KB
/
README
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
*vim_faq.txt* Frequently Asked Questions
Last updated on: 24 October 2024
VIM FAQ by: Christian Brabandt <[email protected]>
Frequently Asked Questions *vim-faq* *Vim-FAQ*
This Vim FAQ is created from the questions and answers posted to the
[email protected] user mailing list and the comp.editors newsgroup. There are
several ways to solve a problem in Vim. This FAQ gives one of those several
possibilities. You can explore the other ways using the information and
links given in this FAQ. The credit for the answers in this FAQ goes to
Peppe, Benji, Charles Campbell and numerous others. An online version of
this FAQ is available at https://vimhelp.org/vim_faq.txt.html
*faq-index*
INDEX ~
*faq-general-information*
SECTION 1 - GENERAL INFORMATION ~
|faq-1.1| What is Vim?
|faq-1.2| Who wrote Vim?
|faq-1.3| Is Vim compatible with Vi?
|faq-1.4| What are some of the improvements of Vim over Vi?
|faq-1.5| Is Vim free?
*faq-resources*
SECTION 2 - RESOURCES ~
|faq-2.1| Where can I learn more about Vim?
|faq-2.2| Is there a mailing list available?
|faq-2.3| Is there an archive available for the Vim mailing lists?
|faq-2.4| Where can I get the Vim user manual in HTML/PDF/PS format?
|faq-2.5| I have a "xyz" (some) problem with Vim. How do I determine if it is
a problem with my setup or with Vim?
|faq-2.6| Where can I report bugs?
|faq-2.7| Where can the FAQ be found?
|faq-2.8| What if I don't find an answer in this FAQ?
|faq-2.9| I have a patch for implementing a Vim feature. Where do I send the
patch?
|faq-2.10| I have a Vim tip or developed a new Vim
syntax/indent/filetype/compiler plugin or developed a new script
or a colorscheme. Is there a public website where I can upload
this?
*faq-availability*
SECTION 3 - AVAILABILITY ~
|faq-3.1| What is the latest version of Vim?
|faq-3.2| Where can I find the latest version of Vim?
|faq-3.3| What platforms does it run on?
|faq-3.4| Where can I download the latest version of the Vim runtime files?
*faq-help*
SECTION 4 - HELP ~
|faq-4.1| How do I use the help files?
|faq-4.2| How do I search for a keyword in the Vim help files?
|faq-4.3| I am getting an error message E123, what did I do wrong?
|faq-4.4| Where can I read about the various modes in Vim?
|faq-4.5| How do I generate the Vim help tags file after adding a new Vim
help file?
|faq-4.6| Can I use compressed versions of the help files?
*faq-editing-a-file*
SECTION 5 - EDITING A FILE ~
|faq-5.1| How do I load a file in Vim for editing?
|faq-5.2| How do I save the current file in another name (save as) and edit
a new file?
|faq-5.3| How do I change the current directory to the directory of the
current file?
|faq-5.4| How do I write a file without the line feed (EOL) at the end of
the file?
|faq-5.5| How do I configure Vim to open a file at the last edited location?
|faq-5.6| When editing a file in Vim, which is being changed by an external
application, Vim opens a warning window (like the confirm dialog)
each time a change is detected. How do I disable this warning?
|faq-5.7| How do I edit a file whose name is under the cursor?
|faq-5.8| How do I reload/re-edit the current file?
|faq-5.9| How do I autosave a file periodically?
|faq-5.10| How do I open a file in read-only mode?
|faq-5.11| How do I open a file for editing without saving the modifications
to the current file?
|faq-5.12| How do I reduce the loading time for very large files in Vim?
*faq-editing-multiple-files*
SECTION 6 - EDITING MULTIPLE FILES ~
|faq-6.1| How do I open multiple files at once from within Vim?
|faq-6.2| How do I switch between multiple files/buffers in Vim?
|faq-6.3| How do I open several files in Vim, with each file in a separate
window/tabpage?
|faq-6.4| How do I configure Vim to autoload several files at once similar
to "work-sets" or "projects"?
|faq-6.5| Is it possible to open multiple top level windows in a single
instance of Vim similar to Nedit or emacs?
|faq-6.6| How do I browse/explore directories from within Vim?
|faq-6.7| How do I edit files over a network using ftp/scp/rcp/http?
*faq-backup*
SECTION 7 - BACKUP ~
|faq-7.1| When I edit and save files, Vim creates a file with the same name
as the original file and a "~" character at the end. How do I stop
Vim from creating this file (or) How do I disable the Vim backup
file feature?
|faq-7.2| When I edit and save files, Vim creates a file with the same name
as the original file and a ".un~" extension at the end. How do I
stop Vim from creating this file (or) How do I disable the Vim
undofile feature.
|faq-7.3| How do I configure Vim to store all the backup files in a
particular directory?
|faq-7.4| When I save a file with Vim, the file permissions are changed.
How do I configure Vim to save a file without changing the file
permissions?
*faq-buffers*
SECTION 8 - BUFFERS ~
|faq-8.1| I have made some modifications to a buffer. How do I edit another
buffer without saving the modified buffer and also without losing
the modifications?
|faq-8.2| How do I configure Vim to auto-save a modified buffer when
switching to another buffer?
|faq-8.3| How do I replace the buffer in the current window with a blank
buffer?
|faq-8.4| Is there a keyboard shortcut to load a buffer by the buffer
number?
|faq-8.5| How do I open all the current buffers in separate windows?
|faq-8.6| How do I close (delete) a buffer without exiting Vim?
|faq-8.7| When I use the command `:%bd` to delete all the buffers, not all
the buffers are deleted. Why?
|faq-8.8| How do I display the buffer number of the current buffer/file?
|faq-8.9| How do I delete a buffer without closing the window in which the
buffer is displayed?
|faq-8.10| How do I map the <Tab> key to cycle through and open all the
buffers?
*faq-windows*
SECTION 9 - WINDOWS ~
|faq-9.1| What is the difference between a Vim window and a buffer?
|faq-9.2| How do I increase the width of a Vim window?
|faq-9.3| How do I zoom into or out of a window?
|faq-9.4| How do I execute an ex command on all the open buffers or open
windows or all the files in the argument list?
*faq-motion*
SECTION 10 - MOTION ~
|faq-10.1| How do I jump to the beginning (first line) or end (last line) of
a file?
|faq-10.2| In insert mode, when I press the <Esc> key to go to command mode,
the cursor moves one character to the left (except when the
cursor is on the first character of the line). Is it possible to
change this behavior to keep the cursor at the same column?
|faq-10.3| How do I configure Vim to maintain the horizontal cursor position
when scrolling with the <Page Up>, <Page Down>, etc keys?
|faq-10.4| Some lines in a file are more than the screen width and they are
all wrapped. When I use the j, k keys to move from one line to
the next, the cursor is moved to the next line in the file
instead of the next line on the screen. How do I move from one
screen line to the next?
|faq-10.5| What is the definition of a sentence, paragraph and section in
Vim?
|faq-10.6| How do I jump to beginning or end of a sentence, paragraph or a
section?
|faq-10.7| I have lines in a file that extends beyond the right extent of the
screen. How do I move the Vim view to the right to see the text
off the screen?
|faq-10.8| How do I scroll two or more buffers simultaneously?
|faq-10.9| When I use my arrow keys, Vim changes modes, inserts weird
characters in my document but doesn't move the cursor properly.
What's going on?
|faq-10.10| How do I configure Vim to move the cursor to the end of the
previous line, when the left arrow key is pressed and the cursor
is currently at the beginning of a line?
|faq-10.11| How do I configure Vim to stay only in insert mode (modeless
editing)?
|faq-10.12| How do I display some context lines when scrolling text?
|faq-10.13| How do I go back to previous cursor locations?
*faq-searching-text*
SECTION 11 - SEARCHING TEXT ~
|faq-11.1| After I searched for a text with a pattern, all the matched text
stays highlighted. How do I turn off the highlighting
temporarily/permanently?
|faq-11.2| How do I enter a carriage return character in a search pattern?
|faq-11.3| How do I search for the character "^M"?
|faq-11.4| How can I search/replace characters that display as "~R", "~S",
etc.?
|faq-11.5| How do I highlight all the non-printable characters in a file?
|faq-11.6| How do I search for whole words in a file?
|faq-11.7| How do I search for the current word under the cursor?
|faq-11.8| How do I search for a word without regard to the case (uppercase
or lowercase)?
|faq-11.9| How do I search for words that occur twice consecutively?
|faq-11.10| How do I count the number of times a particular word occurs in a
buffer?
|faq-11.11| How do I place the cursor at the end of the matched word when
searching for a pattern?
|faq-11.12| How do I search for an empty line?
|faq-11.13| How do I search for a line containing only a single character?
|faq-11.14| How do I search and replace a string in multiple files?
|faq-11.15| I am using the `:s` substitute command in a mapping. When a
search for a pattern fails, the map terminates. I would like the
map to continue processing the next command, even if the
substitute command fails. How do I do this?
|faq-11.16| How do I search for the n-th occurrence of a character in a
line?
|faq-11.17| How do I replace a tab (or any other character) with a hard
return (newline) character?
|faq-11.18| How do I search for a character by its ASCII value?
|faq-11.19| How do I search for long lines?
|faq-11.20| How do I display all the lines in the current buffer that
contain a specified pattern?
|faq-11.21| How do I search for a text string that spans multiple lines?
|faq-11.22| How do I search for a pattern only within a range of lines
in a buffer?
|faq-11.23| How do I clear the last searched pattern?
|faq-11.24| Why does this pattern "a.\{-}p\@!" not match?
|faq-11.25| How can I use "/" within a pattern, without escaping it?
|faq-11.26| How can I operate on a search match?
*faq-changing-text*
SECTION 12 - CHANGING TEXT ~
|faq-12.1| How do I delete all the trailing white space characters (SPACE
and TAB) at the end of all the lines in a file?
|faq-12.2| How do I replace all the occurrences of multiple consecutive
space characters to a single space?
|faq-12.3| How do I reduce a range of empty lines into one line only?
|faq-12.4| How do I delete all blank lines in a file? How do I remove all
the lines containing only space characters?
|faq-12.5| How do I copy/yank the current word?
|faq-12.6| How do I yank text from one position to another position within a
line, without yanking the entire line?
|faq-12.7| When I yank some text into a register, how do I append the text
to the current contents of the register?
|faq-12.8| How do I yank a complete sentence that spans over more than one
line?
|faq-12.9| How do I yank all the lines containing a pattern into a buffer?
|faq-12.10| How do I delete all the lines in a file that do not contain a
pattern?
|faq-12.11| How do I add a line before each line with "pattern" in it?
|faq-12.12| Is there a way to operate on a line if the previous line
contains a particular pattern?
|faq-12.13| How do I execute a command on all the lines containing a
pattern?
|faq-12.14| Can I copy the character above the cursor to the current cursor
position?
|faq-12.15| How do I insert a blank line above/below the current line
without entering insert mode?
|faq-12.16| How do I insert the name of the current file into the current
buffer?
|faq-12.17| How do I insert the contents of a Vim register into the current
buffer?
|faq-12.18| How do I move the cursor past the end of line and insert some
characters at some columns after the end of the line?
|faq-12.19| How to replace the word under the cursor (say: junk) with
"foojunkbar" in Vim?
|faq-12.20| How do I replace a particular text in all the files in a
directory?
|faq-12.21| I have some numbers in a file. How do I increment or decrement
the numbers in the file?
|faq-12.22| How do I reuse the last used search pattern in a `:substitute`
command?
|faq-12.23| How do I change the case of a string using the `:substitute`
command?
|faq-12.24| How do I enter characters that are not present in the keyboard?
|faq-12.25| Is there a command to remove any or all digraphs?
|faq-12.26| In insert mode, when I press the backspace key, it erases only
the characters entered in this instance of insert mode. How do I
erase previously entered characters in insert mode using the
backspace key?
|faq-12.27| I have a file which has lines longer than 72 characters
terminated with "+" and wrapped to the next line. How can I
quickly join the lines?
|faq-12.28| How do I paste characterwise yanked text into separate lines?
|faq-12.29| How do I change the case (uppercase, lowercase) of a word or
a character or a block of text?
|faq-12.30| How do I enter ASCII characters that are not present in the
keyboard?
|faq-12.31| How do I replace non-printable characters in a file?
|faq-12.32| How do I remove duplicate lines from a buffer?
|faq-12.33| How do I prefix all the lines in a file with the corresponding
line numbers?
|faq-12.34| How do I exchange (swap) two characters or words or lines?
|faq-12.35| How do I change the characters used as word delimiters?
*faq-completion-in-insert-mode*
SECTION 13 - COMPLETION IN INSERT MODE ~
|faq-13.1| How do I complete words or lines in insert mode?
|faq-13.2| How do I complete file names in insert mode?
|faq-13.3| I am using CTRL-P/CTRL-N to complete words in insert mode. How do
I complete words that occur after the just completed word?
*faq-text-formatting*
SECTION 14 - TEXT FORMATTING ~
|faq-14.1| How do I format a text paragraph so that a new line is inserted
at the end of each wrapped line?
|faq-14.2| How do I format long lines in a file so that each line contains
less than "n" characters?
|faq-14.3| How do I join short lines to the form a paragraph?
|faq-14.4| How do I format bulleted and numbered lists?
|faq-14.5| How do I indent lines in insert mode?
|faq-14.6| How do I format/indent an entire file?
|faq-14.7| How do I increase or decrease the indentation of the current
line?
|faq-14.8| How do I indent a block/group of lines?
|faq-14.9| When I indent lines using the > or < key, the standard 8-tabstops
are used instead of the current 'tabstop' setting. Why?
|faq-14.10| How do I turn off the automatic indentation of text?
|faq-14.11| How do I configure Vim to automatically set the 'textwidth'
option to a particular value when I edit mails?
|faq-14.12| Is there a way to make Vim auto-magically break lines?
|faq-14.13| I am seeing a lot of ^M symbols in my file. I tried setting the
'fileformat' option to 'dos' and then 'unix' and then 'mac'.
None of these helped. How can I hide these symbols?
|faq-14.14| When I paste some text into a Vim buffer from another
application, the alignment (indentation) of the new text is
messed up. How do I fix this?
|faq-14.15| When there is a very long wrapped line (wrap is "on") and a line
doesn't fit entirely on the screen it is not displayed at all.
There are blank lines beginning with "@" symbol instead of
wrapped line. If I scroll the screen to fit the line the "@"
symbols disappear and the line is displayed again. What Vim
setting control this behavior?
|faq-14.16| How do I convert all the tab characters in a file to space
characters?
|faq-14.17| What Vim options can I use to edit text that will later go to a
word processor?
|faq-14.18| How do I join lines without adding or removing any space
characters?
*faq-visual-mode*
SECTION 15 - VISUAL MODE ~
|faq-15.1| How do I do rectangular block copying?
|faq-15.2| How do I delete or change a column of text in a file?
|faq-15.3| How do I apply an ex-command on a set of visually selected lines?
|faq-15.4| How do I execute an ex command on a column of text selected in
Visual block mode?
|faq-15.5| How do I select the entire file in visual mode?
|faq-15.6| When I visually select a set of lines and press the > key to
indent the selected lines, the visual mode ends. How can I
reselect the region for further operation? (or) How do I
re-select the last selected visual area again?
|faq-15.7| How do I jump to the beginning/end of a visually selected region?
|faq-15.8| When I select text with mouse and then press : to enter an ex
command, the selected text is replaced with the : character. How
do I execute an ex command on a text selected using the mouse
similar to the text selected using the visual mode?
|faq-15.9| When I select a block of text using the mouse, Vim goes into
selection mode instead of Visual mode. Why?
*faq-command-line-mode*
SECTION 16 - COMMAND-LINE MODE ~
|faq-16.1| How do I use the name of the current file in the command mode or
an ex command line?
|faq-16.2| How do I edit the text in the Vim command-line effectively?
|faq-16.3| How do I switch from Vi mode to Ex mode?
|faq-16.4| How do I copy the output from an ex-command into a buffer?
|faq-16.5| When I press the <Tab> key to complete the name of a file in the
command mode, if there are more than one matching file names,
then Vim completes the first matching file name and displays a
list of all matching filenames. How do I configure Vim to only
display the list of all the matching filenames and not complete
the first one?
|faq-16.6| How do I copy text from a buffer to the command line and from the
command line to a buffer?
|faq-16.7| How do I put a command onto the command history without executing
it?
|faq-16.8| How do I increase the height of the command-line?
*faq-viminfo*
SECTION 17 - VIMINFO ~
|faq-17.1| When I invoke Vim, I get error messages about illegal characters
in the viminfo file. What should I do to get rid of these
messages?
|faq-17.2| How do I disable the viminfo feature?
|faq-17.3| How do I save and use Vim marks/commands across Vim sessions?
*faq-remote-editing*
SECTION 18 - REMOTE EDITING ~
|faq-18.1| How do I open a file with existing instance of gvim? What
happened to the Vim 5.x OpenWithVim.exe and SendToVim.exe files?
|faq-18.2| How do I send a command to a Vim server to write all buffers to
disk?
|faq-18.3| Where can I get the documentation about the Vim remote server
functionality?
*faq-options*
SECTION 19 - OPTIONS ~
|faq-19.1| How do I configure Vim in a simple way?
|faq-19.2| How do I toggle the value of an option?
|faq-19.3| How do I set an option that affects only the current
buffer/window?
|faq-19.4| How do I use space characters for a Vim option value?
|faq-19.5| Can I add (embed) Vim option settings to the contents of a file?
|faq-19.6| How do I display the line numbers of all the lines in a file?
|faq-19.7| How do I change the width of the line numbers displayed using the
'number' option?
|faq-19.8| How do I display (view) all the invisible characters like space,
tabs and newlines in a file?
|faq-19.9| How do I configure Vim to always display the current line and
column number?
|faq-19.10| How do I display the current Vim mode?
|faq-19.11| How do I configure Vim to show pending/partial commands on the
status line?
|faq-19.12| How do I configure the Vim status line to display different
settings/values?
|faq-19.13| How do I configure Vim to display status line always?
|faq-19.14| How do I make a Vim setting persistent across different Vim
invocations/instances/sessions?
|faq-19.15| Why do I hear a beep (why does my window flash) about 1 second
after I hit the Escape key?
|faq-19.16| How do I make the "c" and "s" commands display a "$" instead of
deleting the characters I'm changing?
|faq-19.17| How do I remove more than one flag using a single `:set` command
from a Vim option?
*faq-mapping-keys*
SECTION 20 - MAPPING KEYS ~
|faq-20.1| How do I know what a key is mapped to?
|faq-20.2| How do I list all the user-defined key mappings?
|faq-20.3| How do I unmap a key?
|faq-20.4| I am not able to create a mapping for the <xxx> key. What is
wrong?
|faq-20.5| Why does mapping the <C-...> key not work?
|faq-20.6| How do I map the numeric keypad keys?
|faq-20.7| How do I create a mapping that works only in visual mode?
|faq-20.8| How do I create a mapping that works only in normal and operator
pending mode (but not in visual mode)?
|faq-20.9| In a Vim script, how do I know which keys to use for my mappings,
so that the mapped key will not collide with an already used key?
|faq-20.10| How do I map the escape key?
|faq-20.11| How do I map a key to perform nothing?
|faq-20.12| I want to use the <Tab> key to indent a block of text and
<Shift-Tab> key to unindent a block of text. How do I map the keys
to do this? This behavior is similar to textpad, visual studio,
etc.
|faq-20.13| In my mappings the special characters like <CR> are not
recognized. How can I configure Vim to recognize special
characters?
|faq-20.14| How do I use the "|" to separate multiple commands in a map?
|faq-20.15| If I have a mapping/abbreviation whose ending is the beginning of
another mapping/abbreviation, how do I keep the first from
expanding into the second one?
|faq-20.16| Why does it take a second or more for Vim to process a key,
sometimes when I press a key?
|faq-20.17| How do I map a key to run an external command using a visually
selected text?
|faq-20.18| How do I map the CTRL-I key while still retaining the
functionality of the <Tab> key?
|faq-20.19| How do I define a map to accept a count?
|faq-20.20| How can I make my normal mode mapping work from within Insert
Mode?
*faq-abbreviations*
SECTION 21 - ABBREVIATIONS ~
|faq-21.1| How do I auto correct misspelled words?
|faq-21.2| How do I create multi-line abbreviations?
|faq-21.3| When my abbreviations are expanded, an additional space character
is added at the end of the expanded text. How do I avoid this
character?
|faq-21.4| How do I insert the current date/time stamp into the file?
|faq-21.5| How do I prevent an abbreviation from expanding in insert mode?
*faq-record-and-playback*
SECTION 22 - RECORD AND PLAYBACK ~
|faq-22.1| How do I repeat an editing operation (insertion, deletion, paste,
etc)?
|faq-22.2| How I record and repeat a set of key sequences?
|faq-22.3| How do I edit/modify a recorded set of key sequences?
|faq-22.4| How do I write recorded key sequences to a file?
|faq-22.5| I am using register 0 to record my key sequences (i.e. q0 ....
q). In the recorded key sequences, I am yanking some text. After
the first replay of the recorded key sequence, I am no longer
able to play it back.
*faq-autocommands*
SECTION 23 - AUTOCOMMANDS ~
|faq-23.1| How do I execute a command when I try to modify a read-only file?
|faq-23.2| How do I execute a command every time when entering a buffer?
|faq-23.3| How do I execute a command every time when entering a window?
|faq-23.4| From an autocmd, how can I determine the name of the file or the
buffer number for which the autocommand is executed?
|faq-23.5| How do I automatically save all the changed buffers whenever Vim
loses focus?
|faq-23.6| How do I execute/run a function when Vim exits to do some
cleanup?
*faq-syntax-highlight*
SECTION 24 - SYNTAX HIGHLIGHT ~
|faq-24.1| How do I turn off/on syntax highlighting?
|faq-24.2| How do I change the background and foreground colors used by Vim?
|faq-24.3| How do I change the highlight colors to suit a dark/light
background?
|faq-24.4| How do I change the color of the line numbers displayed when the
`:set number` command is used?
|faq-24.5| How do I change the background color used for a Visually selected
block?
|faq-24.6| How do I highlight the special characters (tabs, trailing spaces,
end of line, etc) displayed by the 'list' option?
|faq-24.7| How do I specify a colorscheme in my .vimrc/.gvimrc file, so that
Vim uses the specified colorscheme every time?
|faq-24.8| Vim syntax highlighting is broken. When I am editing a file, some
parts of the file is not syntax highlighted or syntax highlighted
incorrectly.
|faq-24.9| Is there a built-in function to syntax-highlight the
corresponding matching bracket?
|faq-24.10| How do I turn off the C comment syntax highlighting?
|faq-24.11| How do I add my own syntax extensions to the standard syntax
files supplied with Vim?
|faq-24.12| How do I replace a standard syntax file that comes with the Vim
distribution with my own syntax file?
|faq-24.13| How do I highlight all the characters after a particular column?
|faq-24.14| How do I convert a source file (.c, .h, etc) with the Vim syntax
highlighting into a HTML file?
|faq-24.15| How do I list the definition of all the current highlight
groups?
|faq-24.16| How can I embed one syntax highlighting language into another
one?
*faq-vim-script-writing*
SECTION 25 - VIM SCRIPT WRITING ~
|faq-25.1| How do I list the names of all the scripts sourced by Vim?
|faq-25.2| How do I debug Vim scripts?
|faq-25.3| How do I locate the script/plugin which sets a Vim option?
|faq-25.4| I am getting some error/informational messages from Vim (possibly
when running a script), the messages are cleared immediately. How
do I display the messages again?
|faq-25.5| How do I save and restore a plugin specific information across
Vim invocations?
|faq-25.6| How do I start insert mode from a Vim function?
|faq-25.7| How do I change the cursor position from within a Vim function?
|faq-25.8| How do I check the value of an environment variable in the .vimrc
file?
|faq-25.9| How do I check whether an environment variable is set or not from
a Vim function?
|faq-25.10| How do I call/use the Vim built-in functions?
|faq-25.11| I am using some normal mode commands in my Vim script. How do I
avoid using the user-defined mappings for these normal mode
commands and use the standard Vim functionality for these normal
mode commands?
|faq-25.12| How do I get a visually selected text into a Vim variable or
register?
|faq-25.13| I have some text in a Vim variable "myvar". I would like to use
this variable in a `:s` substitute command to replace a text
"mytext". How do I do this?
|faq-25.14| A Vim variable (bno) contains a buffer number. How do I use this
variable to open the corresponding buffer?
|faq-25.15| How do I store the value of a Vim option into a Vim variable?
|faq-25.16| I have copied and inserted some text into a buffer from a Vim
function. How do I indent the inserted text from the Vim
function?
|faq-25.17| How do I get the character under the cursor from a Vim script?
|faq-25.18| How do I get the name of the current file without the extension?
|faq-25.19| How do I get the basename of the current file?
|faq-25.20| How do I get the output from a Vim function into the current
buffer?
|faq-25.21| How do I call external programs from a Vim function?
|faq-25.22| How do I get the return status of a program executed using the
`:!` command?
|faq-25.23| How do I determine whether the current buffer is modified or
not?
|faq-25.24| I would like to use the carriage return character in a normal
command from a Vim script. How do I specify the carriage return
character?
|faq-25.25| How do I split long lines in a Vim script?
|faq-25.26| When I try to "execute" my function using the `:execute Myfunc()`
command, the cursor is moved to the top of the current buffer.
Why?
|faq-25.27| How do I source/execute the contents of a register?
|faq-25.28| After calling a Vim function or a mapping, when I press the "u"
key to undo the last change, Vim undoes all the changes made by
the mapping/function. Why?
|faq-25.29| How can I call a function defined with s: (script local
function) from another script/plugin?
|faq-25.30| Is it possible to un-source a sourced script? In other words,
reverse all the commands executed by sourcing a script.
*faq-plugins*
SECTION 26 - PLUGINS ~
|faq-26.1| How do I set different options for different types of files?
|faq-26.2| I have downloaded a Vim plugin or a syntax file or a indent file,
or a color scheme or a filetype plugin from the web. Where should
I copy these files so that Vim will find them?
|faq-26.3| How do I extend an existing filetype plugin?
|faq-26.4| How do I turn off loading the Vim plugins?
|faq-26.5| How do I turn on/off loading the filetype plugins?
|faq-26.6| How do I override settings made in a file type plugin in the
global ftplugin directory for all the file types?
|faq-26.7| How do I disable the Vim directory browser plugin?
|faq-26.8| How do I set the filetype option for files with names matching a
particular pattern or depending on the file extension?
*faq-editing-program-files*
SECTION 27 - EDITING PROGRAM FILES ~
|faq-27.1| How do I enable automatic indentation for C/C++ files?
|faq-27.2| How do I configure the indentation used for C/C++ files?
|faq-27.3| How do I turn off the automatic indentation feature?
|faq-27.4| How do I change the number of space characters used for the
automatic indentation?
|faq-27.5| I am editing a C program using Vim. How do I display the
definition of a macro or a variable?
|faq-27.6| I am editing a C program using Vim. How do I jump to the
beginning or end of a code block from within the block?
|faq-27.7| When editing C++ files and when inserting new lines above or
below a comment (//) line, Vim automatically inserts the C++
comment character (//) at the beginning of the line. How do I
disable this?
|faq-27.8| How do I add the comment character "#" to a set of lines at the
beginning of each line?
|faq-27.9| How do I edit a header file with the same name as the
corresponding C source file?
|faq-27.10| How do I automatically insert comment leaders while typing
comments?
*faq-quickfix*
SECTION 28 - QUICKFIX ~
|faq-28.1| How do I build programs from Vim?
|faq-28.2| When I run the make command in Vim I get the errors listed as the
compiler compiles the program. When it finishes this list
disappears and I have to use the `:clist` command to see the error
message again. Is there any other way to see these error
messages?
|faq-28.3| How can I perform a command for each item in the
quickfix/location list?
*faq-folding*
SECTION 29 - FOLDING ~
|faq-29.1| How do I extend the Vim folding support?
|faq-29.2| When I enable folding by setting the 'foldmethod' option, all the
folds are closed. How do I prevent this?
|faq-29.3| How do I control how many folds will be opened when I start
editing a file?
|faq-29.4| How do I open and close folds using the mouse?
|faq-29.5| How do I change the text displayed for a closed fold?
|faq-29.6| How do I store and restore manually created folds across
different Vim invocations?
|faq-29.7| I have enabled syntax based folding. Why is Vim so slow?
*faq-vim-with-external-applications*
SECTION 30 - VIM WITH EXTERNAL APPLICATIONS ~
|faq-30.1| Can I run a shell inside a Vim window?
|faq-30.2| How do I pass the word under the cursor to an external command?
|faq-30.3| How do I get the output of a shell command into a Vim buffer?
|faq-30.4| How do I pipe the contents of the current buffer to an external
command and replace the contents of the buffer with the output
from the command?
|faq-30.5| How do I sort a section of my file?
|faq-30.6| How do I use Vim as a pager?
|faq-30.7| How do I view Unix man pages from inside Vim?
|faq-30.8| How do I change the diff command used by the Vim diff support?
|faq-30.9| How do I use the Vim diff mode without folding?
*faq-gui-vim*
SECTION 31 - GUI VIM ~
|faq-31.1| How do I create buffer specific menus?
|faq-31.2| How do I change the font used by GUI Vim?
|faq-31.3| When starting GUI Vim, how do I specify the location of the GVIM
window?
|faq-31.4| How do I add a horizontal scrollbar in GVim?
|faq-31.5| How do I make the scrollbar appear in the left side by default?
|faq-31.6| How do I remove the Vim menubar?
|faq-31.7| I am using GUI Vim. When I press the <Alt> key and a letter, the
menu starting with that letter is selected. I don't want this
behavior as I want to map the <Alt>-<key> combination. How do I do
this?
|faq-31.8| Is it possible to scroll the text by dragging the scrollbar so
that the cursor stays in the original location?
|faq-31.9| How do I get gvim to start browsing files in a particular
directory when using the `:browse` command?
|faq-31.10| For some questions, like when a file is changed outside of Vim,
Vim displays a GUI dialog box. How do I replace this GUI dialog
box with a console dialog box?
|faq-31.11| I am trying to use GUI Vim as the editor for my xxx application.
When the xxx application launches GUI Vim to edit a file, the
control immediately returns to the xxx application. How do I
start GUI Vim, so that the control returns to the xxx
application only after I quit Vim?
|faq-31.12| Why does the "Select Font" dialog doesn't show all the fonts
installed in my system?
|faq-31.13| How do I use the mouse in Vim command-line mode?
|faq-31.14| When I use the middle mouse button to scroll text, it pastes the
last copied text. How do I disable this behavior?
|faq-31.15| How do I change the location and size of a GUI Vim window?
|faq-31.16| When splitting the Vim window vertically, Vim changes
the position.
*faq-vim-on-unix*
SECTION 32 - VIM ON UNIX ~
|faq-32.1| I am running Vim in a xterm. When I press the CTRL-S key, Vim
freezes. What should I do now?
|faq-32.2| I am seeing weird screen update problems in Vim. What can I do to
solve this screen/display update problems?
|faq-32.3| I am using the terminal/console version of Vim. In insertmode,
When I press the backspace key, the character before the cursor
is not erased. How do I configure Vim to do this?
|faq-32.4| I am using Vim in a xterm. When I quit Vim, the screen contents
are restored back to the original contents. How do I disable
this?
|faq-32.5| When I start Vim, it takes quite a few seconds to start. How do I
minimize the startup time?
|faq-32.6| How can I make the cursor in gvim in unix stop blinking?
|faq-32.7| How do I change the menu font on GTK Vim?
|faq-32.8| How do I prevent CTRL-Z from suspending Vim?
|faq-32.9| When I kill the xterm running Vim, the Vim process continues to
run and takes up a lot of CPU (99%) time. Why is this happening?
|faq-32.10| How do I get the Vim syntax highlighting to work in a Unix
terminal?
*faq-vim-on-ms-windows*
SECTION 33 - VIM ON MS-WINDOWS ~
|faq-33.1| In MS-Windows, CTRL-V doesn't start the blockwise visual mode.
What happened?
|faq-33.2| When I press the CTRL-Y key, it acts like the CTRL-R key. How do
I configure Vim to treat CTRL-Y as CTRL-Y?
|faq-33.3| How do I start GUI Vim in a maximized window always?
|faq-33.4| After doing some editing operations, Vim freezes. The cursor
becomes an empty rectangle. I am not able enter any characters.
What is happening?
|faq-33.5| I am using Windows XP, the display speed of maximized GVim is
very slow. What can I do to speed the display updates?
|faq-33.6| What are the recommended settings for using Vim with cygwin?
|faq-33.7| I am trying to use GNU diff with Vim diff mode. When I run the
diff from command line, it works. When I try to use the diff with
Vim it doesn't work. What should I do now?
|faq-33.8| Is it possible to use Vim as an external editor for MS-Windows
Outlook email client?
|faq-33.9| I am using Vim to edit HTML files. How do I start internet
explorer with the current file to preview the HTML file?
|faq-33.10| I would like to use Vim with Microsoft Visual Studio. How do I
do this?
|faq-33.11| Where do I place the _vimrc and _gvimrc files?
|faq-33.12| Every time I save a file, Vim warns about the file being changed
outside of Vim. Why?
*faq-printing*
SECTION 34 - PRINTING ~
|faq-34.1| How do I print a file along with line numbers for all the lines?
|faq-34.2| How do I print a file with the Vim syntax highlighting colors?
*faq-building-vim-from-source*
SECTION 35 - BUILDING VIM FROM SOURCE ~
|faq-35.1| How do I build Vim from the sources on a Unix system?
|faq-35.2| How do I install Vim in my home directory or a directory other
than the default installation directory in Unix?
|faq-35.3| How do I build Vim from the sources on a MS-Windows system?
|faq-35.4| The Vim help, syntax, indent files are missing from my Vim
installation. How do I install these files?
|faq-35.5| I have built Vim from the source and installed the Vim package
using "make install". Do I need to keep the Vim source directory?
|faq-35.6| How do I determine the Vim features which are enabled at compile
time?
|faq-35.7| Can I build Vim without the GUI support?
|faq-35.8| When building Vim on a Unix system, I am getting "undefined
reference to term_set_winsize" error. How do I resolve this
error?
|faq-35.9| Vim configure keeps complaining about the lack of gtk-config
while trying to use GTK 2.03. This is correct, since in GTK 2
they moved to using the generic pkg-config. I can get pkg-config
to list the various includes and libs for gtk, but for some
reason the configure script still isn't picking this up.
|faq-35.10| I did successfully download the sources and compiled Vim on
Unix. But feature ... still does not work. What is wrong and
how can I fix it?
*faq-various*
SECTION 36 - VARIOUS ~
|faq-36.1| How do I edit binary files with Vim?
|faq-36.2| How do I disable the visual error flash and the error beep?
|faq-36.3| How do I display the ascii value of a character displayed in a
buffer?
|faq-36.4| Can I use zero as a count for a Vim command?
|faq-36.5| How do I disable the Vim welcome screen?
|faq-36.6| How do I avoid the "hit enter to continue" prompt?
|faq-36.7| How do I invoke Vim from command line to run a group of commands
on a group of files?
|faq-36.8| How do I use a normal mode command from insert mode without
leaving the insert mode?
|faq-36.9| How do I start Vim in insert mode?
|faq-36.10| How do I use Copy and Paste with Vim?
|faq-36.11| Why shouldn't I modify the files in the system runtime
directory?
*faq-unicode*
SECTION 37 - UNICODE ~
|faq-37.1| Is it possible to create Unicode files using Vim?
|faq-37.2| Which Vim settings are particularly important for editing Unicode
files?
|faq-37.3| What is the 'encoding' option?
|faq-37.4| How does Vim name the various Unicode encodings?
|faq-37.5| How does Vim specify the presence or absence of a byte-order
mark?
|faq-37.6| What is the 'fileencoding' option?
|faq-37.7| What is the 'fileencodings' option?
|faq-37.8| What is the 'termencoding' option?
|faq-37.9| What is the 'bomb' option?
|faq-37.10| Where can I find an example of a typical use of all these
options?
|faq-37.11| How can I insert Unicode characters into a file using Vim?
|faq-37.12| How can I know which digraphs are defined and for which
characters?
=============================================================================
*faq-1*
SECTION 1 - GENERAL INFORMATION ~
*faq-1.1*
1.1. What is Vim?
Vim stands for Vi IMproved. It used to be Vi IMitation, but there are so
many improvements that a name change was appropriate. Vim is a text editor
which includes almost all the commands from the Unix program "Vi" and a lot
of new ones. All commands can be given with the keyboard. This has the
advantage that you can keep your fingers on the keyboard and your eyes on
the screen. For those who want it, there is mouse support and a GUI version
with scrollbars and menus.
Vim is an editor, not a word processor. A word processor is used mainly
to do layout of text. This means positioning it, changing the way it
appears on output. More often than not, the final document is meant to
be printed or typeset or what have you, in order to present it in a
pleasing manner to others. Examples of word processors are Microsoft
Word, FrameMaker, and OpenOffice Writer.
An editor is simply for entering text. Any typesetting or laying out of the
document is secondary. With an editor, one's main concern is entering text,
not making the text look good. Examples of editors other than Vim and Vi
are Emacs, TextMate, Ultraedit and gedit. And Notepad.
For more information, read:
|intro|
*faq-1.2*
1.2. Who wrote Vim?
Most of Vim is based on Stevie and was written by Bram Moolenaar, with
contributions from too many people to mention here.
For more information, read:
|author|
|credits|
*faq-1.3*
1.3. Is Vim compatible with Vi?
Yes. Vim is very much compatible with Vi. You can use the "-C"
command-line flag to start Vim in Vi compatible mode: >
$ vim -C
<
You can also use: >
$ vim -u NONE
<
You can also set the 'compatible' option to enable Vi compatibility: >
:set compatible
<
If you want to make sure, to start Vim in a 'nocompatible' mode to
original Vi, supply the -N command line argument: >
$ vim -N
<
For more information, read:
|-C|
|-N|
|'compatible'|
|compatible-default|
*faq-1.4*
1.4. What are some of the improvements of Vim over Vi?
A short summary of the improvements of Vim over vi is listed below. The
list shows that Vim is a thoroughly modern and feature-packed editor.
Standard features of modern editors are implemented, and there is an equal
emphasis on general power-user features and features for programmers.
Features to modernise Vi: ~
Multi-level undo ~
Allows you to set the number of times you can undo your changes in a
file buffer. You can also redo an undone change.
Also starting with version 7.3 Vim can permanently store your undo
information, so that you can undo your changes which you have done
in a previous editing session.
Tabs, Multiple windows and buffers ~
Each file can be displayed in its own window. You can move easily from
one window to another. Each file opened during a Vim session also has
an associated buffer and you can easily jump from one to the other.
Also like any modern GUI, Vim supports opening several files in tabs.
You can do batch processing for tabs, buffers, windows and the
argumentlist.
Flexible insert mode ~
Vim allows you to use the arrow keys while in insert mode to move
around in the file. No more hitting <Esc>, moving around, then hitting
`i' or `a'.
Macros ~
Vim has a facility which allows you to record a sequence of typed
characters and repeat them any number of times.
Visual mode ~
You can highlight sections of text and execute operations on this
section of text only.
Block operators ~
Allow selection and highlighting of rectangular blocks of text in
order do execute specific operations on them.
Online help system ~
You can easily find help on any aspect of using Vim. Help is displayed
in its own window.
Command-line editing and history ~
History allows you to use the arrow keys to repeat or search for a
command that has already been typed. Allows you to match the beginning
of a command with the beginning of another similar command in the
history buffer. You can also edit a command to correct typos or change
a few values.
Command line completion. ~
Using the <Tab> key, you can complete commands, options, filenames,
etc. as needed.
Horizontal scrolling. ~
Long lines can be scrolled horizontally (with or without the GUI).
Unicode and internationalization improvements. ~
Vim is able to edit files in unicode encoding and uses internally an
utf-8 encoding. Additionally Vim can display text right to left
oriented.
Advanced user features: ~
Text formatting ~
With two keystrokes, you can format large sections of text, without
the use of external programs.
Completion in Insert mode ~
Vim provides several different possibilities to complete your text.
For example Vim can complete words while you are typing, by matching
the current word with other similar words in the file.
Jump tags ~
Just like in an internet browser, you can jump back to previous parts
of the text you were editing, and then forward again. Your brain is
thus free to edit instead of navigate.
Automatic commands ~
Commands automatically executed when reading or writing a file,
jumping to another buffer, etc.
Viminfo ~
Allows storing of the command line history, marks and registers in a
file to be read on startup. Therefore, you can recall old search
patterns, macros, etc., in a new Vim session.
Mouse support ~
The mouse is supported in an xterm and for MS-DOS. It can be used to
position the cursor, select the visual area, paste a register, etc.
Graphical User Interface (GUI) ~
There are several different graphical user interfaces available.
Also, it's very easy to add your own menus. Of course, console vim is
still supported, and very widely used.
Scripting language ~
Vim has a powerful scripting language so new commands can be created.
You can also use Perl, Python, TCL, Lua and Ruby to achieve the same
thing!
Plugins ~
Extra functionality implemented via vim commands (regular commands or
the scripting language) that is automatically loaded on startup.
Examples: file explorer, network editing, enhanced autocompletion,
syntax checks.
More are being developed and shared on VimOnline all the time.
Syntax highlighting for many programming languages ~
Syntax highlighting (including concealing items) for hundreds of
programming languages is supported. Support for others can be
added.
Extended regular expressions ~
Vim supports extended regular expressions which are similar in
functionality to that of Perl regular expressions.
Integrated Spell checking ~
Spell checking has been integrated into Vim.
Diff mode ~
Vim can highlight the differences between two, three or four files.
Identical lines will be folded away and hidden.
Encryption using the blowfish algorithm ~
Vim allows to encrypt your files using the symmetric block cipher
blowfish as well as the swap file.
Extensive customizable ~
Vim can be tuned and customized to work like you want by setting
options. You can define your own commands, macros and even plugins
to extend its capabilities
Packages ~
Packages have been added to keep the installation of the growing
number of plugins manageable. This is a convenient way to get one
or more plugins, drop them in a directory and keep them updated.
Vim will load them automatically, or only when desired.