blob: b36f91f50bf3eea80fcec9fcae86cc2fc6d0afb7 [file] [log] [blame]
Bram Moolenaaraedfcbe2016-03-25 17:02:51 +01001*usr_05.txt* For Vim version 7.4. Last change: 2016 Mar 25
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
3 VIM USER MANUAL - by Bram Moolenaar
4
5 Set your settings
6
7
8Vim can be tuned to work like you want it to. This chapter shows you how to
9make Vim start with options set to different values. Add plugins to extend
Bram Moolenaar4399ef42005-02-12 14:29:27 +000010Vim's capabilities. Or define your own macros.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011
12|05.1| The vimrc file
13|05.2| The example vimrc file explained
14|05.3| Simple mappings
Bram Moolenaaraedfcbe2016-03-25 17:02:51 +010015|05.4| Adding a package
16|05.5| Adding a plugin
17|05.6| Adding a help file
18|05.7| The option window
19|05.8| Often used options
Bram Moolenaar071d4272004-06-13 20:20:40 +000020
21 Next chapter: |usr_06.txt| Using syntax highlighting
22 Previous chapter: |usr_04.txt| Making small changes
23Table of contents: |usr_toc.txt|
24
25==============================================================================
26*05.1* The vimrc file *vimrc-intro*
27
28You probably got tired of typing commands that you use very often. To start
Bram Moolenaar910f66f2006-04-05 20:41:53 +000029Vim with all your favorite option settings and mappings, you write them in
30what is called the vimrc file. Vim executes the commands in this file when it
31starts up.
Bram Moolenaar071d4272004-06-13 20:20:40 +000032
Bram Moolenaar910f66f2006-04-05 20:41:53 +000033If you already have a vimrc file (e.g., when your sysadmin has one setup for
34you), you can edit it this way: >
Bram Moolenaar071d4272004-06-13 20:20:40 +000035
Bram Moolenaar910f66f2006-04-05 20:41:53 +000036 :edit $MYVIMRC
Bram Moolenaar071d4272004-06-13 20:20:40 +000037
Bram Moolenaar910f66f2006-04-05 20:41:53 +000038If you don't have a vimrc file yet, see |vimrc| to find out where you can
Bram Moolenaar071d4272004-06-13 20:20:40 +000039create a vimrc file. Also, the ":version" command mentions the name of the
40"user vimrc file" Vim looks for.
41
Bram Moolenaar910f66f2006-04-05 20:41:53 +000042For Unix and Macintosh this file is always used and is recommended:
Bram Moolenaar071d4272004-06-13 20:20:40 +000043
Bram Moolenaar910f66f2006-04-05 20:41:53 +000044 ~/.vimrc ~
Bram Moolenaar071d4272004-06-13 20:20:40 +000045
Bram Moolenaar910f66f2006-04-05 20:41:53 +000046For MS-DOS and MS-Windows you can use one of these:
Bram Moolenaar071d4272004-06-13 20:20:40 +000047
Bram Moolenaar910f66f2006-04-05 20:41:53 +000048 $HOME/_vimrc ~
49 $VIM/_vimrc ~
Bram Moolenaar071d4272004-06-13 20:20:40 +000050
51The vimrc file can contain all the commands that you type after a colon. The
52most simple ones are for setting options. For example, if you want Vim to
Bram Moolenaar2df58b42012-11-28 18:21:11 +010053always start with the 'incsearch' option on, add this line your vimrc file: >
Bram Moolenaar071d4272004-06-13 20:20:40 +000054
55 set incsearch
56
57For this new line to take effect you need to exit Vim and start it again.
58Later you will learn how to do this without exiting Vim.
59
60This chapter only explains the most basic items. For more information on how
61to write a Vim script file: |usr_41.txt|.
62
63==============================================================================
64*05.2* The example vimrc file explained *vimrc_example.vim*
65
66In the first chapter was explained how the example vimrc (included in the
67Vim distribution) file can be used to make Vim startup in not-compatible mode
68(see |not-compatible|). The file can be found here:
69
70 $VIMRUNTIME/vimrc_example.vim ~
71
72In this section we will explain the various commands used in this file. This
73will give you hints about how to set up your own preferences. Not everything
74will be explained though. Use the ":help" command to find out more.
75
76>
77 set nocompatible
78
79As mentioned in the first chapter, these manuals explain Vim working in an
80improved way, thus not completely Vi compatible. Setting the 'compatible'
81option off, thus 'nocompatible' takes care of this.
82
83>
84 set backspace=indent,eol,start
85
86This specifies where in Insert mode the <BS> is allowed to delete the
87character in front of the cursor. The three items, separated by commas, tell
88Vim to delete the white space at the start of the line, a line break and the
89character before where Insert mode started.
90>
91
92 set autoindent
93
94This makes Vim use the indent of the previous line for a newly created line.
95Thus there is the same amount of white space before the new line. For example
96when pressing <Enter> in Insert mode, and when using the "o" command to open a
97new line.
98>
99
100 if has("vms")
101 set nobackup
102 else
103 set backup
104 endif
105
106This tells Vim to keep a backup copy of a file when overwriting it. But not
107on the VMS system, since it keeps old versions of files already. The backup
108file will have the same name as the original file with "~" added. See |07.4|
109>
110
111 set history=50
112
113Keep 50 commands and 50 search patterns in the history. Use another number if
114you want to remember fewer or more lines.
115>
116
117 set ruler
118
119Always display the current cursor position in the lower right corner of the
120Vim window.
121
122>
123 set showcmd
124
125Display an incomplete command in the lower right corner of the Vim window,
126left of the ruler. For example, when you type "2f", Vim is waiting for you to
127type the character to find and "2f" is displayed. When you press "w" next,
128the "2fw" command is executed and the displayed "2f" is removed.
129
130 +-------------------------------------------------+
131 |text in the Vim window |
132 |~ |
133 |~ |
134 |-- VISUAL -- 2f 43,8 17% |
135 +-------------------------------------------------+
136 ^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^
137 'showmode' 'showcmd' 'ruler'
138
139>
140 set incsearch
141
142Display the match for a search pattern when halfway typing it.
143
144>
145 map Q gq
146
147This defines a key mapping. More about that in the next section. This
148defines the "Q" command to do formatting with the "gq" operator. This is how
149it worked before Vim 5.0. Otherwise the "Q" command starts Ex mode, but you
150will not need it.
151
152>
Bram Moolenaar8fc061c2004-12-29 21:03:02 +0000153 vnoremap _g y:exe "grep /" . escape(@", '\\/') . "/ *.c *.h"<CR>
Bram Moolenaar071d4272004-06-13 20:20:40 +0000154
Bram Moolenaar8fc061c2004-12-29 21:03:02 +0000155This mapping yanks the visually selected text and searches for it in C files.
156This is a complicated mapping. You can see that mappings can be used to do
157quite complicated things. Still, it is just a sequence of commands that are
Bram Moolenaar071d4272004-06-13 20:20:40 +0000158executed like you typed them.
159
160>
161 if &t_Co > 2 || has("gui_running")
162 syntax on
163 set hlsearch
164 endif
165
166This switches on syntax highlighting, but only if colors are available. And
167the 'hlsearch' option tells Vim to highlight matches with the last used search
168pattern. The "if" command is very useful to set options only when some
169condition is met. More about that in |usr_41.txt|.
170
171 *vimrc-filetype* >
172 filetype plugin indent on
173
174This switches on three very clever mechanisms:
1751. Filetype detection.
176 Whenever you start editing a file, Vim will try to figure out what kind of
177 file this is. When you edit "main.c", Vim will see the ".c" extension and
178 recognize this as a "c" filetype. When you edit a file that starts with
179 "#!/bin/sh", Vim will recognize it as a "sh" filetype.
180 The filetype detection is used for syntax highlighting and the other two
181 items below.
182 See |filetypes|.
183
1842. Using filetype plugin files
185 Many different filetypes are edited with different options. For example,
186 when you edit a "c" file, it's very useful to set the 'cindent' option to
187 automatically indent the lines. These commonly useful option settings are
188 included with Vim in filetype plugins. You can also add your own, see
189 |write-filetype-plugin|.
190
1913. Using indent files
192 When editing programs, the indent of a line can often be computed
193 automatically. Vim comes with these indent rules for a number of
194 filetypes. See |:filetype-indent-on| and 'indentexpr'.
195
196>
197 autocmd FileType text setlocal textwidth=78
198
199This makes Vim break text to avoid lines getting longer than 78 characters.
200But only for files that have been detected to be plain text. There are
201actually two parts here. "autocmd FileType text" is an autocommand. This
202defines that when the file type is set to "text" the following command is
203automatically executed. "setlocal textwidth=78" sets the 'textwidth' option
204to 78, but only locally in one file.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000205
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000206 *restore-cursor* >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000207 autocmd BufReadPost *
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100208 \ if line("'\"") > 1 && line("'\"") <= line("$") |
209 \ exe "normal! g`\"" |
Bram Moolenaar071d4272004-06-13 20:20:40 +0000210 \ endif
211
212Another autocommand. This time it is used after reading any file. The
213complicated stuff after it checks if the '" mark is defined, and jumps to it
214if so. The backslash at the start of a line is used to continue the command
215from the previous line. That avoids a line getting very long.
216See |line-continuation|. This only works in a Vim script file, not when
217typing commands at the command-line.
218
219==============================================================================
220*05.3* Simple mappings
221
222A mapping enables you to bind a set of Vim commands to a single key. Suppose,
223for example, that you need to surround certain words with curly braces. In
224other words, you need to change a word such as "amount" into "{amount}". With
225the :map command, you can tell Vim that the F5 key does this job. The command
226is as follows: >
227
228 :map <F5> i{<Esc>ea}<Esc>
229<
230 Note:
231 When entering this command, you must enter <F5> by typing four
232 characters. Similarly, <Esc> is not entered by pressing the <Esc>
233 key, but by typing five characters. Watch out for this difference
234 when reading the manual!
235
236Let's break this down:
237 <F5> The F5 function key. This is the trigger key that causes the
238 command to be executed as the key is pressed.
239
240 i{<Esc> Insert the { character. The <Esc> key ends Insert mode.
241
242 e Move to the end of the word.
243
244 a}<Esc> Append the } to the word.
245
246After you execute the ":map" command, all you have to do to put {} around a
247word is to put the cursor on the first character and press F5.
248
249In this example, the trigger is a single key; it can be any string. But when
250you use an existing Vim command, that command will no longer be available.
251You better avoid that.
252 One key that can be used with mappings is the backslash. Since you
253probably want to define more than one mapping, add another character. You
Bram Moolenaar4399ef42005-02-12 14:29:27 +0000254could map "\p" to add parentheses around a word, and "\c" to add curly braces,
255for example: >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000256
257 :map \p i(<Esc>ea)<Esc>
258 :map \c i{<Esc>ea}<Esc>
259
260You need to type the \ and the p quickly after another, so that Vim knows they
261belong together.
262
263The ":map" command (with no arguments) lists your current mappings. At
264least the ones for Normal mode. More about mappings in section |40.1|.
265
266==============================================================================
Bram Moolenaaraedfcbe2016-03-25 17:02:51 +0100267*05.4* Adding a package *add-package* *matchit-install*
268
269A package is a set of files that you can add to Vim. There are two kinds of
270packages: optional and automatically loaded on startup.
271
272The Vim distribution comes with a few packages that you can optionally use.
273For example, the matchit plugin. This plugin makes the "%" command jump to
274matching HTML tags, if/else/endif in Vim scripts, etc. Very useful, although
275it's not backwards compatible (that's why it is not enabled by default).
276
277To start using the matchit plugin, add one line to your vimrc file: >
278 packadd matchit
279
280That's all! You can also type the command to try it out. Now you can find
281help about this plugin: >
282 :help matchit
283
284This works, because when `:packadd` loaded the plugin it also added the
285package directory in 'runtimepath', so that the help file can be found.
286
287You can find packages on the Internet in various places. It usually comes as
288an archive or as a repository. For an archive you can follow these steps:
289 1. create the package directory: >
290 mkdir -p ~/.vim/pack/fancy
291< "fancy" can be any name of your liking. Use one that describes the
292 package.
293 2. unpack the archive in that directory. This assumes the top
294 directory in the archive is "start": >
295 cd ~/.vim/pack/fancy
296 unzip /tmp/fancy.zip
297< If the archive layout is different make sure that you end up with a
298 path like this:
299 ~/.vim/pack/fancy/start/fancytext/plugin/fancy.vim ~
300 Here "fancytext" is the name of the package, it can be anything
301 else.
302
303More information about packages can be found here: |packages|.
304
305==============================================================================
306*05.5* Adding a plugin *add-plugin* *plugin*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000307
308Vim's functionality can be extended by adding plugins. A plugin is nothing
309more than a Vim script file that is loaded automatically when Vim starts. You
310can add a plugin very easily by dropping it in your plugin directory.
311{not available when Vim was compiled without the |+eval| feature}
312
313There are two types of plugins:
314
315 global plugin: Used for all kinds of files
316 filetype plugin: Only used for a specific type of file
317
318The global plugins will be discussed first, then the filetype ones
319|add-filetype-plugin|.
320
321
322GLOBAL PLUGINS *standard-plugin*
323
324When you start Vim, it will automatically load a number of global plugins.
325You don't have to do anything for this. They add functionality that most
326people will want to use, but which was implemented as a Vim script instead of
327being compiled into Vim. You can find them listed in the help index
328|standard-plugin-list|. Also see |load-plugins|.
329
330 *add-global-plugin*
331You can add a global plugin to add functionality that will always be present
332when you use Vim. There are only two steps for adding a global plugin:
3331. Get a copy of the plugin.
3342. Drop it in the right directory.
335
336
337GETTING A GLOBAL PLUGIN
338
339Where can you find plugins?
340- Some come with Vim. You can find them in the directory $VIMRUNTIME/macros
341 and its sub-directories.
Bram Moolenaar76b92b22006-03-24 22:46:53 +0000342- Download from the net. There is a large collection on http://www.vim.org.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000343- They are sometimes posted in a Vim |maillist|.
344- You could write one yourself, see |write-plugin|.
345
Bram Moolenaar76b92b22006-03-24 22:46:53 +0000346Some plugins come as a vimball archive, see |vimball|.
347Some plugins can be updated automatically, see |getscript|.
348
Bram Moolenaar071d4272004-06-13 20:20:40 +0000349
350USING A GLOBAL PLUGIN
351
352First read the text in the plugin itself to check for any special conditions.
353Then copy the file to your plugin directory:
354
355 system plugin directory ~
356 Unix ~/.vim/plugin/
357 PC and OS/2 $HOME/vimfiles/plugin or $VIM/vimfiles/plugin
358 Amiga s:vimfiles/plugin
359 Macintosh $VIM:vimfiles:plugin
360 Mac OS X ~/.vim/plugin/
361 RISC-OS Choices:vimfiles.plugin
362
363Example for Unix (assuming you didn't have a plugin directory yet): >
364
365 mkdir ~/.vim
366 mkdir ~/.vim/plugin
367 cp /usr/local/share/vim/vim60/macros/justify.vim ~/.vim/plugin
368
369That's all! Now you can use the commands defined in this plugin to justify
370text.
371
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000372Instead of putting plugins directly into the plugin/ directory, you may
373better organize them by putting them into subdirectories under plugin/.
374As an example, consider using "~/.vim/plugin/perl/*.vim" for all your Perl
375plugins.
Bram Moolenaar07d4d732005-10-03 22:04:08 +0000376
Bram Moolenaar071d4272004-06-13 20:20:40 +0000377
378FILETYPE PLUGINS *add-filetype-plugin* *ftplugins*
379
380The Vim distribution comes with a set of plugins for different filetypes that
381you can start using with this command: >
382
383 :filetype plugin on
384
385That's all! See |vimrc-filetype|.
386
387If you are missing a plugin for a filetype you are using, or you found a
388better one, you can add it. There are two steps for adding a filetype plugin:
3891. Get a copy of the plugin.
3902. Drop it in the right directory.
391
392
393GETTING A FILETYPE PLUGIN
394
395You can find them in the same places as the global plugins. Watch out if the
396type of file is mentioned, then you know if the plugin is a global or a
397filetype one. The scripts in $VIMRUNTIME/macros are global ones, the filetype
398plugins are in $VIMRUNTIME/ftplugin.
399
400
401USING A FILETYPE PLUGIN *ftplugin-name*
402
403You can add a filetype plugin by dropping it in the right directory. The
404name of this directory is in the same directory mentioned above for global
405plugins, but the last part is "ftplugin". Suppose you have found a plugin for
406the "stuff" filetype, and you are on Unix. Then you can move this file to the
407ftplugin directory: >
408
409 mv thefile ~/.vim/ftplugin/stuff.vim
410
411If that file already exists you already have a plugin for "stuff". You might
412want to check if the existing plugin doesn't conflict with the one you are
413adding. If it's OK, you can give the new one another name: >
414
415 mv thefile ~/.vim/ftplugin/stuff_too.vim
416
417The underscore is used to separate the name of the filetype from the rest,
Bram Moolenaarf4b8e572004-06-24 15:53:16 +0000418which can be anything. If you use "otherstuff.vim" it wouldn't work, it would
419be loaded for the "otherstuff" filetype.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000420
421On MS-DOS you cannot use long filenames. You would run into trouble if you
422add a second plugin and the filetype has more than six characters. You can
423use an extra directory to get around this: >
424
425 mkdir $VIM/vimfiles/ftplugin/fortran
426 copy thefile $VIM/vimfiles/ftplugin/fortran/too.vim
427
428The generic names for the filetype plugins are: >
429
430 ftplugin/<filetype>.vim
431 ftplugin/<filetype>_<name>.vim
432 ftplugin/<filetype>/<name>.vim
433
434Here "<name>" can be any name that you prefer.
435Examples for the "stuff" filetype on Unix: >
436
437 ~/.vim/ftplugin/stuff.vim
438 ~/.vim/ftplugin/stuff_def.vim
439 ~/.vim/ftplugin/stuff/header.vim
440
441The <filetype> part is the name of the filetype the plugin is to be used for.
442Only files of this filetype will use the settings from the plugin. The <name>
443part of the plugin file doesn't matter, you can use it to have several plugins
444for the same filetype. Note that it must end in ".vim".
445
446
447Further reading:
448|filetype-plugins| Documentation for the filetype plugins and information
449 about how to avoid that mappings cause problems.
450|load-plugins| When the global plugins are loaded during startup.
451|ftplugin-overrule| Overruling the settings from a global plugin.
452|write-plugin| How to write a plugin script.
453|plugin-details| For more information about using plugins or when your
454 plugin doesn't work.
455|new-filetype| How to detect a new file type.
456
457==============================================================================
Bram Moolenaaraedfcbe2016-03-25 17:02:51 +0100458*05.6* Adding a help file *add-local-help*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000459
460If you are lucky, the plugin you installed also comes with a help file. We
461will explain how to install the help file, so that you can easily find help
462for your new plugin.
Bram Moolenaaraedfcbe2016-03-25 17:02:51 +0100463 Let us use the "doit.vim" plugin as an example. This plugin comes with
464documentation: "doit.txt". Let's first copy the plugin to the right
465directory. This time we will do it from inside Vim. (You may skip some of
466the "mkdir" commands if you already have the directory.) >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000467
468 :!mkdir ~/.vim
469 :!mkdir ~/.vim/plugin
Bram Moolenaaraedfcbe2016-03-25 17:02:51 +0100470 :!cp /tmp/doit.vim ~/.vim/plugin
Bram Moolenaar071d4272004-06-13 20:20:40 +0000471
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000472The "cp" command is for Unix, on MS-DOS you can use "copy".
473
Bram Moolenaar071d4272004-06-13 20:20:40 +0000474Now create a "doc" directory in one of the directories in 'runtimepath'. >
475
476 :!mkdir ~/.vim/doc
477
478Copy the help file to the "doc" directory. >
479
Bram Moolenaaraedfcbe2016-03-25 17:02:51 +0100480 :!cp /tmp/doit.txt ~/.vim/doc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000481
482Now comes the trick, which allows you to jump to the subjects in the new help
483file: Generate the local tags file with the |:helptags| command. >
484
485 :helptags ~/.vim/doc
486
487Now you can use the >
488
Bram Moolenaaraedfcbe2016-03-25 17:02:51 +0100489 :help doit
Bram Moolenaar071d4272004-06-13 20:20:40 +0000490
Bram Moolenaaraedfcbe2016-03-25 17:02:51 +0100491command to find help for "doit" in the help file you just added. You can see
492an entry for the local help file when you do: >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000493
494 :help local-additions
495
496The title lines from the local help files are automagically added to this
497section. There you can see which local help files have been added and jump to
498them through the tag.
499
500For writing a local help file, see |write-local-help|.
501
502==============================================================================
Bram Moolenaaraedfcbe2016-03-25 17:02:51 +0100503*05.7* The option window
Bram Moolenaar071d4272004-06-13 20:20:40 +0000504
505If you are looking for an option that does what you want, you can search in
506the help files here: |options|. Another way is by using this command: >
507
508 :options
509
510This opens a new window, with a list of options with a one-line explanation.
511The options are grouped by subject. Move the cursor to a subject and press
512<Enter> to jump there. Press <Enter> again to jump back. Or use CTRL-O.
513
514You can change the value of an option. For example, move to the "displaying
515text" subject. Then move the cursor down to this line:
516
517 set wrap nowrap ~
518
519When you hit <Enter>, the line will change to:
520
521 set nowrap wrap ~
522
523The option has now been switched off.
524
525Just above this line is a short description of the 'wrap' option. Move the
526cursor one line up to place it in this line. Now hit <Enter> and you jump to
527the full help on the 'wrap' option.
528
529For options that take a number or string argument you can edit the value.
530Then press <Enter> to apply the new value. For example, move the cursor a few
531lines up to this line:
532
533 set so=0 ~
534
535Position the cursor on the zero with "$". Change it into a five with "r5".
536Then press <Enter> to apply the new value. When you now move the cursor
537around you will notice that the text starts scrolling before you reach the
538border. This is what the 'scrolloff' option does, it specifies an offset
539from the window border where scrolling starts.
540
541==============================================================================
Bram Moolenaaraedfcbe2016-03-25 17:02:51 +0100542*05.8* Often used options
Bram Moolenaar071d4272004-06-13 20:20:40 +0000543
544There are an awful lot of options. Most of them you will hardly ever use.
545Some of the more useful ones will be mentioned here. Don't forget you can
546find more help on these options with the ":help" command, with single quotes
547before and after the option name. For example: >
548
549 :help 'wrap'
550
551In case you have messed up an option value, you can set it back to the
Bram Moolenaarf4b8e572004-06-24 15:53:16 +0000552default by putting an ampersand (&) after the option name. Example: >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000553
554 :set iskeyword&
555
556
557NOT WRAPPING LINES
558
559Vim normally wraps long lines, so that you can see all of the text. Sometimes
560it's better to let the text continue right of the window. Then you need to
Bram Moolenaarf4b8e572004-06-24 15:53:16 +0000561scroll the text left-right to see all of a long line. Switch wrapping off
562with this command: >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000563
564 :set nowrap
565
566Vim will automatically scroll the text when you move to text that is not
567displayed. To see a context of ten characters, do this: >
568
569 :set sidescroll=10
570
571This doesn't change the text in the file, only the way it is displayed.
572
573
574WRAPPING MOVEMENT COMMANDS
575
576Most commands for moving around will stop moving at the start and end of a
577line. You can change that with the 'whichwrap' option. This sets it to the
578default value: >
579
580 :set whichwrap=b,s
581
582This allows the <BS> key, when used in the first position of a line, to move
583the cursor to the end of the previous line. And the <Space> key moves from
584the end of a line to the start of the next one.
585
586To allow the cursor keys <Left> and <Right> to also wrap, use this command: >
587
588 :set whichwrap=b,s,<,>
589
590This is still only for Normal mode. To let <Left> and <Right> do this in
591Insert mode as well: >
592
593 :set whichwrap=b,s,<,>,[,]
594
595There are a few other flags that can be added, see 'whichwrap'.
596
597
598VIEWING TABS
599
600When there are tabs in a file, you cannot see where they are. To make them
601visible: >
602
603 :set list
604
Bram Moolenaar1b826e52007-05-12 15:14:36 +0000605Now every tab is displayed as ^I. And a $ is displayed at the end of each
Bram Moolenaar071d4272004-06-13 20:20:40 +0000606line, so that you can spot trailing spaces that would otherwise go unnoticed.
607 A disadvantage is that this looks ugly when there are many Tabs in a file.
608If you have a color terminal, or are using the GUI, Vim can show the spaces
609and tabs as highlighted characters. Use the 'listchars' option: >
610
611 :set listchars=tab:>-,trail:-
612
613Now every tab will be displayed as ">---" (with more or less "-") and trailing
614white space as "-". Looks a lot better, doesn't it?
615
616
617KEYWORDS
618
619The 'iskeyword' option specifies which characters can appear in a word: >
620
621 :set iskeyword
622< iskeyword=@,48-57,_,192-255 ~
623
624The "@" stands for all alphabetic letters. "48-57" stands for ASCII
625characters 48 to 57, which are the numbers 0 to 9. "192-255" are the
626printable latin characters.
627 Sometimes you will want to include a dash in keywords, so that commands
628like "w" consider "upper-case" to be one word. You can do it like this: >
629
630 :set iskeyword+=-
631 :set iskeyword
632< iskeyword=@,48-57,_,192-255,- ~
633
634If you look at the new value, you will see that Vim has added a comma for you.
635 To remove a character use "-=". For example, to remove the underscore: >
636
637 :set iskeyword-=_
638 :set iskeyword
639< iskeyword=@,48-57,192-255,- ~
640
641This time a comma is automatically deleted.
642
643
644ROOM FOR MESSAGES
645
646When Vim starts there is one line at the bottom that is used for messages.
647When a message is long, it is either truncated, thus you can only see part of
648it, or the text scrolls and you have to press <Enter> to continue.
649 You can set the 'cmdheight' option to the number of lines used for
650messages. Example: >
651
652 :set cmdheight=3
653
654This does mean there is less room to edit text, thus it's a compromise.
655
656==============================================================================
657
658Next chapter: |usr_06.txt| Using syntax highlighting
659
660Copyright: see |manual-copyright| vim:tw=78:ts=8:ft=help:norl: