annotate runtime/doc/usr_05.txt @ 35062:f57990be7526 v9.1.0376

patch 9.1.0376: Vim9: Trailing commands after class/enum keywords ignored Commit: https://github.com/vim/vim/commit/ac7731895c996acef4d02b784f9952749226e203 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sat Apr 27 11:36:12 2024 +0200 patch 9.1.0376: Vim9: Trailing commands after class/enum keywords ignored Problem: Vim9: Trailing commands after class/enum keywords ignored Solution: Remove EX_TRLBAR keyword from command definition (Yegappan Lakshmanan) closes: #14649 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 27 Apr 2024 12:00:03 +0200
parents 79c73c4b3ecb
children 945f1fec1802
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35056
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents: 34057
diff changeset
1 *usr_05.txt* For Vim version 9.1. Last change: 2024 Apr 26
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 VIM USER MANUAL - by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 Set your settings
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 Vim can be tuned to work like you want it to. This chapter shows you how to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 make Vim start with options set to different values. Add plugins to extend
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 43
diff changeset
10 Vim's capabilities. Or define your own macros.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 |05.1| The vimrc file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 |05.2| The example vimrc file explained
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
14 |05.3| The defaults.vim file explained
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
15 |05.4| Simple mappings
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
16 |05.5| Adding a package
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
17 |05.6| Adding a plugin
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
18 |05.7| Adding a help file
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
19 |05.8| The option window
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
20 |05.9| Often used options
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 Next chapter: |usr_06.txt| Using syntax highlighting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 Previous chapter: |usr_04.txt| Making small changes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 Table of contents: |usr_toc.txt|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 *05.1* The vimrc file *vimrc-intro*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 You probably got tired of typing commands that you use very often. To start
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 810
diff changeset
30 Vim with all your favorite option settings and mappings, you write them in
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 810
diff changeset
31 what is called the vimrc file. Vim executes the commands in this file when it
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 810
diff changeset
32 starts up.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 810
diff changeset
34 If you already have a vimrc file (e.g., when your sysadmin has one setup for
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 810
diff changeset
35 you), you can edit it this way: >
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 810
diff changeset
37 :edit $MYVIMRC
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 810
diff changeset
38
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 810
diff changeset
39 If you don't have a vimrc file yet, see |vimrc| to find out where you can
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 create a vimrc file. Also, the ":version" command mentions the name of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 "user vimrc file" Vim looks for.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 810
diff changeset
43 For Unix and Macintosh this file is always used and is recommended:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 810
diff changeset
45 ~/.vimrc ~
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
18972
130acb903dbe Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18912
diff changeset
47 For MS-Windows you can use one of these:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 810
diff changeset
49 $HOME/_vimrc ~
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 810
diff changeset
50 $VIM/_vimrc ~
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10198
diff changeset
52 If you are creating the vimrc file for the first time, it is recommended to
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10198
diff changeset
53 put this line at the top: >
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10198
diff changeset
54
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10198
diff changeset
55 source $VIMRUNTIME/defaults.vim
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10198
diff changeset
56
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10198
diff changeset
57 This initializes Vim for new users (as opposed to traditional Vi users). See
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10198
diff changeset
58 |defaults.vim| for the details.
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10198
diff changeset
59
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 The vimrc file can contain all the commands that you type after a colon. The
21676
1b345fb68ae3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18972
diff changeset
61 simplest ones are for setting options. For example, if you want Vim to always
1b345fb68ae3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18972
diff changeset
62 start with the 'incsearch' option on, add this line your vimrc file: >
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 set incsearch
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 For this new line to take effect you need to exit Vim and start it again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 Later you will learn how to do this without exiting Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 This chapter only explains the most basic items. For more information on how
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 to write a Vim script file: |usr_41.txt|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 *05.2* The example vimrc file explained *vimrc_example.vim*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 In the first chapter was explained how the example vimrc (included in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 Vim distribution) file can be used to make Vim startup in not-compatible mode
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 (see |not-compatible|). The file can be found here:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 $VIMRUNTIME/vimrc_example.vim ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 In this section we will explain the various commands used in this file. This
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 will give you hints about how to set up your own preferences. Not everything
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 will be explained though. Use the ":help" command to find out more.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 >
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
86 " Get the defaults that most users want.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
87 source $VIMRUNTIME/defaults.vim
16023
dc766e1b0c95 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
88
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
89 This loads the "defaults.vim" file in the $VIMRUNTIME directory. This sets up
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
90 Vim for how most users like it. If you are one of the few that don't, then
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
91 comment out this line. The commands are explained below:
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
92 |defaults.vim-explained|
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
93
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
94 >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
95 if has("vms")
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
96 set nobackup
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
97 else
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
98 set backup
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
99 if has('persistent_undo')
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
100 set undofile
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
101 endif
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
102 endif
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
103
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
104 This tells Vim to keep a backup copy of a file when overwriting it. But not
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
105 on the VMS system, since it keeps old versions of files already. The backup
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
106 file will have the same name as the original file with "~" added. See |07.4|
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
107
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
108 This also sets the 'undofile' option, if available. This will store the
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
109 multi-level undo information in a file. The result is that when you change a
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
110 file, exit Vim, and then edit the file again, you can undo the changes made
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
111 previously. It's a very powerful and useful feature, at the cost of storing a
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
112 file. For more information see |undo-persistence|.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
113
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
114 The "if" command is very useful to set options
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
115 only when some condition is met. More about that in |usr_41.txt|.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
116
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
117 >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
118 if &t_Co > 2 || has("gui_running")
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
119 set hlsearch
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
120 endif
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
121
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
122 This switches on the 'hlsearch' option, telling Vim to highlight matches with
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
123 the last used search pattern.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
124
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
125 >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
126 augroup vimrcEx
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
127 au!
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
128 autocmd FileType text setlocal textwidth=78
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
129 augroup END
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
130
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
131 This makes Vim break text to avoid lines getting longer than 78 characters.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
132 But only for files that have been detected to be plain text. There are
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
133 actually two parts here. "autocmd FileType text" is an autocommand. This
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
134 defines that when the file type is set to "text" the following command is
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
135 automatically executed. "setlocal textwidth=78" sets the 'textwidth' option
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
136 to 78, but only locally in one file.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
137
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
138 The wrapper with "augroup vimrcEx" and "augroup END" makes it possible to
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
139 delete the autocommand with the "au!" command. See |:augroup|.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
140
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
141 >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
142 if has('syntax') && has('eval')
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
143 packadd! matchit
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
144 endif
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
145
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
146 This loads the "matchit" plugin if the required features are available.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
147 It makes the |%| command more powerful. This is explained at
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
148 |matchit-install|.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
149
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
150
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
151 ==============================================================================
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
152 *05.3* The defaults.vim file explained *defaults.vim-explained*
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
153
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
154 The |defaults.vim| file is loaded when the user has no vimrc file. When you
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
155 create a new vimrc file, add this line near the top to keep using it: >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
156
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
157 source $VIMRUNTIME/defaults.vim
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
158
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
159 Or use the vimrc_example.vim file, as explained above.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
160
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
161 The following explains what defaults.vim is doing.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
162
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
163 >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
164 if exists('skip_defaults_vim')
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
165 finish
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
166 endif
16023
dc766e1b0c95 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
167
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
168 Loading defaults.vim can be disabled with this command: >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
169 let skip_defaults_vim = 1
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
170 This has to be done in the system vimrc file. See |system-vimrc|. If you
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
171 have a user vimrc this is not needed, since defaults.vim will not be loaded
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
172 automatically.
16023
dc766e1b0c95 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
173
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
174 >
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 set nocompatible
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 As mentioned in the first chapter, these manuals explain Vim working in an
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 improved way, thus not completely Vi compatible. Setting the 'compatible'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 option off, thus 'nocompatible' takes care of this.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 set backspace=indent,eol,start
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 This specifies where in Insert mode the <BS> is allowed to delete the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 character in front of the cursor. The three items, separated by commas, tell
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 Vim to delete the white space at the start of the line, a line break and the
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
187 character before where Insert mode started. See 'backspace'.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
189 >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
190 set history=200
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
192 Keep 200 commands and 200 search patterns in the history. Use another number
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
193 if you want to remember fewer or more lines. See 'history'.
16023
dc766e1b0c95 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
194
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 set ruler
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 Always display the current cursor position in the lower right corner of the
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
199 Vim window. See 'ruler'.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 set showcmd
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 Display an incomplete command in the lower right corner of the Vim window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 left of the ruler. For example, when you type "2f", Vim is waiting for you to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 type the character to find and "2f" is displayed. When you press "w" next,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 the "2fw" command is executed and the displayed "2f" is removed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 +-------------------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 |text in the Vim window |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 |-- VISUAL -- 2f 43,8 17% |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 +-------------------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 ^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 'showmode' 'showcmd' 'ruler'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
218
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
219 >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
220 set wildmenu
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
221
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
222 Display completion matches in a status line. That is when you type <Tab> and
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
223 there is more than one match. See 'wildmenu'.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
224
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
225 >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
226 set ttimeout
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
227 set ttimeoutlen=100
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
228
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
229 This makes typing Esc take effect more quickly. Normally Vim waits a second
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
230 to see if the Esc is the start of an escape sequence. If you have a very slow
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
231 remote connection, increase the number. See 'ttimeout'.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
232
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
233 >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
234 set display=truncate
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
235
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
236 Show @@@ in the last line if it is truncated, instead of hiding the whole
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16023
diff changeset
237 line. See 'display'.
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
238
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 set incsearch
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
242 Display the match for a search pattern when halfway typing it. See
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
243 'incsearch'.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
244
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
245 >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
246 set nrformats-=octal
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
247
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
248 Do not recognize numbers starting with a zero as octal. See 'nrformats'.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 map Q gq
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 This defines a key mapping. More about that in the next section. This
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 defines the "Q" command to do formatting with the "gq" operator. This is how
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 it worked before Vim 5.0. Otherwise the "Q" command starts Ex mode, but you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 will not need it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 >
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
259 inoremap <C-U> <C-G>u<C-U>
16023
dc766e1b0c95 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
260
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
261 CTRL-U in insert mode deletes all entered text in the current line. Use
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
262 CTRL-G u to first break undo, so that you can undo CTRL-U after inserting a
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
263 line break. Revert with ":iunmap <C-U>".
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
264
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
265 >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
266 if has('mouse')
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
267 set mouse=a
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
268 endif
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
269
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
270 Enable using the mouse if available. See 'mouse'.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
271
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
272 >
27903
d19b7aee1925 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 21676
diff changeset
273 vnoremap _g y:exe "grep /" .. escape(@", '\\/') .. "/ *.c *.h"<CR>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274
43
f55897d6921d updated for version 7.0026
vimboss
parents: 22
diff changeset
275 This mapping yanks the visually selected text and searches for it in C files.
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
276 You can see that a mapping can be used to do quite complicated things. Still,
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
277 it is just a sequence of commands that are executed like you typed them.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 >
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
280 syntax on
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
282 Enable highlighting files in color. See |syntax|.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 *vimrc-filetype* >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 filetype plugin indent on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 This switches on three very clever mechanisms:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 1. Filetype detection.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 Whenever you start editing a file, Vim will try to figure out what kind of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 file this is. When you edit "main.c", Vim will see the ".c" extension and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 recognize this as a "c" filetype. When you edit a file that starts with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 "#!/bin/sh", Vim will recognize it as a "sh" filetype.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 The filetype detection is used for syntax highlighting and the other two
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 items below.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 See |filetypes|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 2. Using filetype plugin files
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 Many different filetypes are edited with different options. For example,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 when you edit a "c" file, it's very useful to set the 'cindent' option to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 automatically indent the lines. These commonly useful option settings are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 included with Vim in filetype plugins. You can also add your own, see
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 |write-filetype-plugin|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 3. Using indent files
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 When editing programs, the indent of a line can often be computed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 automatically. Vim comes with these indent rules for a number of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 filetypes. See |:filetype-indent-on| and 'indentexpr'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
310 *restore-cursor* *last-position-jump* >
32724
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
311 augroup RestoreCursor
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
312 autocmd!
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
313 autocmd BufReadPost *
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
314 \ let line = line("'\"")
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
315 \ | if line >= 1 && line <= line("$") && &filetype !~# 'commit'
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
316 \ && index(['xxd', 'gitrebase'], &filetype) == -1
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
317 \ | execute "normal! g`\""
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
318 \ | endif
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
319 augroup END
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 Another autocommand. This time it is used after reading any file. The
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 complicated stuff after it checks if the '" mark is defined, and jumps to it
32724
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
323 if so. It doesn't do that for a commit or rebase message, which are likely
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
324 a different one than last time, and when using xxd(1) to filter and edit
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
325 binary files, which transforms input files back and forth, causing them to
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
326 have dual nature, so to speak. See also |using-xxd|.
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
327
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
328 The backslash at the start of a line is used to continue the command from the
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
329 previous line. That avoids a line getting very long. See |line-continuation|.
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
330 This only works in a Vim script file, not when typing commands at the
83111104fb89 Update the vimscript code for restoring cursor position
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
331 command line.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
333 >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
334 command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
335 \ | wincmd p | diffthis
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
336
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
337 This adds the ":DiffOrig" command. Use this in a modified buffer to see the
16023
dc766e1b0c95 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
338 differences with the file it was loaded from. See |diff| and |:DiffOrig|.
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
339
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
340 >
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
341 set nolangremap
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
342
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
343 Prevent that the langmap option applies to characters that result from a
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
344 mapping. If set (default), this may break plugins (but it's backward
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
345 compatible). See 'langremap'.
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
346
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 ==============================================================================
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
348 *05.4* Simple mappings
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 A mapping enables you to bind a set of Vim commands to a single key. Suppose,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 for example, that you need to surround certain words with curly braces. In
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 other words, you need to change a word such as "amount" into "{amount}". With
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 the :map command, you can tell Vim that the F5 key does this job. The command
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 is as follows: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 :map <F5> i{<Esc>ea}<Esc>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 Note:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 When entering this command, you must enter <F5> by typing four
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 characters. Similarly, <Esc> is not entered by pressing the <Esc>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 key, but by typing five characters. Watch out for this difference
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 when reading the manual!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 Let's break this down:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 <F5> The F5 function key. This is the trigger key that causes the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 command to be executed as the key is pressed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 i{<Esc> Insert the { character. The <Esc> key ends Insert mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 e Move to the end of the word.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 a}<Esc> Append the } to the word.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 After you execute the ":map" command, all you have to do to put {} around a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 word is to put the cursor on the first character and press F5.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 In this example, the trigger is a single key; it can be any string. But when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 you use an existing Vim command, that command will no longer be available.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 You better avoid that.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 One key that can be used with mappings is the backslash. Since you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 probably want to define more than one mapping, add another character. You
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 43
diff changeset
382 could map "\p" to add parentheses around a word, and "\c" to add curly braces,
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 43
diff changeset
383 for example: >
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 :map \p i(<Esc>ea)<Esc>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 :map \c i{<Esc>ea}<Esc>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 You need to type the \ and the p quickly after another, so that Vim knows they
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 belong together.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 The ":map" command (with no arguments) lists your current mappings. At
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 least the ones for Normal mode. More about mappings in section |40.1|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 ==============================================================================
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
395 *05.5* Adding a package *add-package* *matchit-install*
8720
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
396
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
397 A package is a set of files that you can add to Vim. There are two kinds of
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
398 packages: optional and automatically loaded on startup.
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
399
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
400 The Vim distribution comes with a few packages that you can optionally use.
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
401 For example, the matchit plugin. This plugin makes the "%" command jump to
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
402 matching HTML tags, if/else/endif in Vim scripts, etc. Very useful, although
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
403 it's not backwards compatible (that's why it is not enabled by default).
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
404
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
405 To start using the matchit plugin, add one line to your vimrc file: >
8748
b1a19a2f73f0 commit https://github.com/vim/vim/commit/4f3f668c8486444e53163c29d2fc79bf47eb3c82
Christian Brabandt <cb@256bit.org>
parents: 8720
diff changeset
406 packadd! matchit
8720
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
407
8748
b1a19a2f73f0 commit https://github.com/vim/vim/commit/4f3f668c8486444e53163c29d2fc79bf47eb3c82
Christian Brabandt <cb@256bit.org>
parents: 8720
diff changeset
408 That's all! After restarting Vim you can find help about this plugin: >
8720
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
409 :help matchit
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
410
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
411 This works, because when `:packadd` loaded the plugin it also added the
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
412 package directory in 'runtimepath', so that the help file can be found.
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
413
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
414 You can find packages on the Internet in various places. It usually comes as
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
415 an archive or as a repository. For an archive you can follow these steps:
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
416 1. create the package directory: >
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
417 mkdir -p ~/.vim/pack/fancy
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
418 < "fancy" can be any name of your liking. Use one that describes the
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
419 package.
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
420 2. unpack the archive in that directory. This assumes the top
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
421 directory in the archive is "start": >
32004
a9b5ffbc0428 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 29314
diff changeset
422 cd ~/.vim/pack/fancy
8720
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
423 unzip /tmp/fancy.zip
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
424 < If the archive layout is different make sure that you end up with a
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
425 path like this:
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
426 ~/.vim/pack/fancy/start/fancytext/plugin/fancy.vim ~
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
427 Here "fancytext" is the name of the package, it can be anything
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
428 else.
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
429
33257
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
430 Adding the editorconfig package *editorconfig-install*
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
431
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
432 Similar to the matchit package, to load the distributed editorconfig plugin
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
433 when Vim starts, add the following line to your vimrc file: >
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
434 packadd! editorconfig
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
435
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
436 After restarting your Vim, the plugin is active and you can read about it at: >
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
437 :h editorconfig.txt
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
438
35056
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents: 34057
diff changeset
439
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents: 34057
diff changeset
440 Adding comment package *comment-install*
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents: 34057
diff changeset
441
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents: 34057
diff changeset
442 Load the plugin with this command: >
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents: 34057
diff changeset
443 packadd comment
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents: 34057
diff changeset
444 <
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents: 34057
diff changeset
445 This way you can use the plugin with the default key bindings `gc` and similar
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents: 34057
diff changeset
446 for commenting (which is a well-established mapping in the Vim community).
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents: 34057
diff changeset
447
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents: 34057
diff changeset
448 After restarting your Vim, the plugin is active and you can read about it at: >
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents: 34057
diff changeset
449 :h comment.txt
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents: 34057
diff changeset
450
8720
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
451 More information about packages can be found here: |packages|.
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
452
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
453 ==============================================================================
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
454 *05.6* Adding a plugin *add-plugin* *plugin*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 Vim's functionality can be extended by adding plugins. A plugin is nothing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 more than a Vim script file that is loaded automatically when Vim starts. You
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 can add a plugin very easily by dropping it in your plugin directory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 {not available when Vim was compiled without the |+eval| feature}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 There are two types of plugins:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 global plugin: Used for all kinds of files
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 filetype plugin: Only used for a specific type of file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 The global plugins will be discussed first, then the filetype ones
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 |add-filetype-plugin|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469
33257
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
470 GLOBAL PLUGINS *standard-plugin* *distributed-plugins*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 When you start Vim, it will automatically load a number of global plugins.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 You don't have to do anything for this. They add functionality that most
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 people will want to use, but which was implemented as a Vim script instead of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 being compiled into Vim. You can find them listed in the help index
33257
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
476 |standard-plugin-list|.
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
477
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
478 For locally installed plugins and packages (which come with a separated help
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
479 file) a similar list can be found in the help section |local-additions|.
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
480
f2e65ef623e8 runtime(help): Updated documentation on editorconfig
Christian Brabandt <cb@256bit.org>
parents: 33253
diff changeset
481 Also see |load-plugins|.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 *add-global-plugin*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 You can add a global plugin to add functionality that will always be present
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 when you use Vim. There are only two steps for adding a global plugin:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 1. Get a copy of the plugin.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 2. Drop it in the right directory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 GETTING A GLOBAL PLUGIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 Where can you find plugins?
14372
2a4a2dc35c55 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13963
diff changeset
493 - Some are always loaded, you can see them in the directory $VIMRUNTIME/plugin.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 - Some come with Vim. You can find them in the directory $VIMRUNTIME/macros
14372
2a4a2dc35c55 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13963
diff changeset
495 and its sub-directories and under $VIM/vimfiles/pack/dist/opt/.
800
d8f905020502 updated for version 7.0b
vimboss
parents: 548
diff changeset
496 - Download from the net. There is a large collection on http://www.vim.org.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 - They are sometimes posted in a Vim |maillist|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 - You could write one yourself, see |write-plugin|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499
800
d8f905020502 updated for version 7.0b
vimboss
parents: 548
diff changeset
500 Some plugins come as a vimball archive, see |vimball|.
d8f905020502 updated for version 7.0b
vimboss
parents: 548
diff changeset
501 Some plugins can be updated automatically, see |getscript|.
d8f905020502 updated for version 7.0b
vimboss
parents: 548
diff changeset
502
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 USING A GLOBAL PLUGIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 First read the text in the plugin itself to check for any special conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 Then copy the file to your plugin directory:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 system plugin directory ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 Unix ~/.vim/plugin/
18912
ccd16426a1f9 patch 8.2.0017: OS/2 and MS-DOS are still mentioned
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
511 PC $HOME/vimfiles/plugin or $VIM/vimfiles/plugin
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 Amiga s:vimfiles/plugin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 Macintosh $VIM:vimfiles:plugin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 Mac OS X ~/.vim/plugin/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 Example for Unix (assuming you didn't have a plugin directory yet): >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 mkdir ~/.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 mkdir ~/.vim/plugin
8795
aba2d0a01290 commit https://github.com/vim/vim/commit/7db8f6f4f85e5d0526d23107b2a5e2334dc23354
Christian Brabandt <cb@256bit.org>
parents: 8748
diff changeset
520 cp /tmp/yourplugin.vim ~/.vim/plugin
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521
8795
aba2d0a01290 commit https://github.com/vim/vim/commit/7db8f6f4f85e5d0526d23107b2a5e2334dc23354
Christian Brabandt <cb@256bit.org>
parents: 8748
diff changeset
522 That's all! Now you can use the commands defined in this plugin.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523
548
f43150a669dc updated for version 7.0155
vimboss
parents: 541
diff changeset
524 Instead of putting plugins directly into the plugin/ directory, you may
f43150a669dc updated for version 7.0155
vimboss
parents: 541
diff changeset
525 better organize them by putting them into subdirectories under plugin/.
f43150a669dc updated for version 7.0155
vimboss
parents: 541
diff changeset
526 As an example, consider using "~/.vim/plugin/perl/*.vim" for all your Perl
f43150a669dc updated for version 7.0155
vimboss
parents: 541
diff changeset
527 plugins.
541
3e19ea54eb07 updated for version 7.0153
vimboss
parents: 164
diff changeset
528
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 FILETYPE PLUGINS *add-filetype-plugin* *ftplugins*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 The Vim distribution comes with a set of plugins for different filetypes that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 you can start using with this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 :filetype plugin on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 That's all! See |vimrc-filetype|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 If you are missing a plugin for a filetype you are using, or you found a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 better one, you can add it. There are two steps for adding a filetype plugin:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 1. Get a copy of the plugin.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 2. Drop it in the right directory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 GETTING A FILETYPE PLUGIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 You can find them in the same places as the global plugins. Watch out if the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 type of file is mentioned, then you know if the plugin is a global or a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 filetype one. The scripts in $VIMRUNTIME/macros are global ones, the filetype
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 plugins are in $VIMRUNTIME/ftplugin.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 USING A FILETYPE PLUGIN *ftplugin-name*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 You can add a filetype plugin by dropping it in the right directory. The
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 name of this directory is in the same directory mentioned above for global
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 plugins, but the last part is "ftplugin". Suppose you have found a plugin for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 the "stuff" filetype, and you are on Unix. Then you can move this file to the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 ftplugin directory: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 mv thefile ~/.vim/ftplugin/stuff.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 If that file already exists you already have a plugin for "stuff". You might
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 want to check if the existing plugin doesn't conflict with the one you are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 adding. If it's OK, you can give the new one another name: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 mv thefile ~/.vim/ftplugin/stuff_too.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 The underscore is used to separate the name of the filetype from the rest,
10
4e2284e71352 updated for version 7.0002
vimboss
parents: 7
diff changeset
570 which can be anything. If you use "otherstuff.vim" it wouldn't work, it would
4e2284e71352 updated for version 7.0002
vimboss
parents: 7
diff changeset
571 be loaded for the "otherstuff" filetype.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572
18972
130acb903dbe Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18912
diff changeset
573 On MS-DOS like filesystems you cannot use long filenames. You would run into
130acb903dbe Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18912
diff changeset
574 trouble if you add a second plugin and the filetype has more than six
130acb903dbe Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18912
diff changeset
575 characters. You can use an extra directory to get around this: >
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 mkdir $VIM/vimfiles/ftplugin/fortran
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 copy thefile $VIM/vimfiles/ftplugin/fortran/too.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 The generic names for the filetype plugins are: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 ftplugin/<filetype>.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 ftplugin/<filetype>_<name>.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 ftplugin/<filetype>/<name>.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 Here "<name>" can be any name that you prefer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 Examples for the "stuff" filetype on Unix: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 ~/.vim/ftplugin/stuff.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 ~/.vim/ftplugin/stuff_def.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 ~/.vim/ftplugin/stuff/header.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 The <filetype> part is the name of the filetype the plugin is to be used for.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 Only files of this filetype will use the settings from the plugin. The <name>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 part of the plugin file doesn't matter, you can use it to have several plugins
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 for the same filetype. Note that it must end in ".vim".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 Further reading:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 |filetype-plugins| Documentation for the filetype plugins and information
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 about how to avoid that mappings cause problems.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 |load-plugins| When the global plugins are loaded during startup.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 |ftplugin-overrule| Overruling the settings from a global plugin.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 |write-plugin| How to write a plugin script.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 |plugin-details| For more information about using plugins or when your
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 plugin doesn't work.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 |new-filetype| How to detect a new file type.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 ==============================================================================
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
610 *05.7* Adding a help file *add-local-help*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 If you are lucky, the plugin you installed also comes with a help file. We
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 will explain how to install the help file, so that you can easily find help
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 for your new plugin.
8720
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
615 Let us use the "doit.vim" plugin as an example. This plugin comes with
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
616 documentation: "doit.txt". Let's first copy the plugin to the right
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
617 directory. This time we will do it from inside Vim. (You may skip some of
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
618 the "mkdir" commands if you already have the directory.) >
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 :!mkdir ~/.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 :!mkdir ~/.vim/plugin
8720
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
622 :!cp /tmp/doit.vim ~/.vim/plugin
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623
18972
130acb903dbe Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18912
diff changeset
624 The "cp" command is for Unix, on MS-Windows you can use "copy".
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 10
diff changeset
625
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 Now create a "doc" directory in one of the directories in 'runtimepath'. >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 :!mkdir ~/.vim/doc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 Copy the help file to the "doc" directory. >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631
8720
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
632 :!cp /tmp/doit.txt ~/.vim/doc
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 Now comes the trick, which allows you to jump to the subjects in the new help
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 file: Generate the local tags file with the |:helptags| command. >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 :helptags ~/.vim/doc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 Now you can use the >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640
8720
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
641 :help doit
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642
8720
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
643 command to find help for "doit" in the help file you just added. You can see
9380c37723f8 commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
644 an entry for the local help file when you do: >
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 :help local-additions
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 The title lines from the local help files are automagically added to this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 section. There you can see which local help files have been added and jump to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 them through the tag.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 For writing a local help file, see |write-local-help|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 ==============================================================================
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
655 *05.8* The option window
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 If you are looking for an option that does what you want, you can search in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 the help files here: |options|. Another way is by using this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 :options
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 This opens a new window, with a list of options with a one-line explanation.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 The options are grouped by subject. Move the cursor to a subject and press
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 <Enter> to jump there. Press <Enter> again to jump back. Or use CTRL-O.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 You can change the value of an option. For example, move to the "displaying
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 text" subject. Then move the cursor down to this line:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 set wrap nowrap ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 When you hit <Enter>, the line will change to:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 set nowrap wrap ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 The option has now been switched off.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 Just above this line is a short description of the 'wrap' option. Move the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 cursor one line up to place it in this line. Now hit <Enter> and you jump to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 the full help on the 'wrap' option.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 For options that take a number or string argument you can edit the value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 Then press <Enter> to apply the new value. For example, move the cursor a few
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 lines up to this line:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 set so=0 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 Position the cursor on the zero with "$". Change it into a five with "r5".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 Then press <Enter> to apply the new value. When you now move the cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 around you will notice that the text starts scrolling before you reach the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 border. This is what the 'scrolloff' option does, it specifies an offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 from the window border where scrolling starts.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 ==============================================================================
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
694 *05.9* Often used options
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 There are an awful lot of options. Most of them you will hardly ever use.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 Some of the more useful ones will be mentioned here. Don't forget you can
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 find more help on these options with the ":help" command, with single quotes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 before and after the option name. For example: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 :help 'wrap'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 In case you have messed up an option value, you can set it back to the
10
4e2284e71352 updated for version 7.0002
vimboss
parents: 7
diff changeset
704 default by putting an ampersand (&) after the option name. Example: >
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 :set iskeyword&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 NOT WRAPPING LINES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 Vim normally wraps long lines, so that you can see all of the text. Sometimes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 it's better to let the text continue right of the window. Then you need to
10
4e2284e71352 updated for version 7.0002
vimboss
parents: 7
diff changeset
713 scroll the text left-right to see all of a long line. Switch wrapping off
4e2284e71352 updated for version 7.0002
vimboss
parents: 7
diff changeset
714 with this command: >
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 :set nowrap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 Vim will automatically scroll the text when you move to text that is not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 displayed. To see a context of ten characters, do this: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 :set sidescroll=10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 This doesn't change the text in the file, only the way it is displayed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 WRAPPING MOVEMENT COMMANDS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 Most commands for moving around will stop moving at the start and end of a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 line. You can change that with the 'whichwrap' option. This sets it to the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 default value: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 :set whichwrap=b,s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 This allows the <BS> key, when used in the first position of a line, to move
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 the cursor to the end of the previous line. And the <Space> key moves from
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 the end of a line to the start of the next one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 To allow the cursor keys <Left> and <Right> to also wrap, use this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 :set whichwrap=b,s,<,>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 This is still only for Normal mode. To let <Left> and <Right> do this in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 Insert mode as well: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 :set whichwrap=b,s,<,>,[,]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 There are a few other flags that can be added, see 'whichwrap'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 VIEWING TABS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 When there are tabs in a file, you cannot see where they are. To make them
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 visible: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 :set list
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756
1278
f9537da5e66d updated for version 7.1
vimboss
parents: 1226
diff changeset
757 Now every tab is displayed as ^I. And a $ is displayed at the end of each
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 line, so that you can spot trailing spaces that would otherwise go unnoticed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 A disadvantage is that this looks ugly when there are many Tabs in a file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 If you have a color terminal, or are using the GUI, Vim can show the spaces
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 and tabs as highlighted characters. Use the 'listchars' option: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 :set listchars=tab:>-,trail:-
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 Now every tab will be displayed as ">---" (with more or less "-") and trailing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 white space as "-". Looks a lot better, doesn't it?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 KEYWORDS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 The 'iskeyword' option specifies which characters can appear in a word: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 :set iskeyword
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 < iskeyword=@,48-57,_,192-255 ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 The "@" stands for all alphabetic letters. "48-57" stands for ASCII
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 characters 48 to 57, which are the numbers 0 to 9. "192-255" are the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 printable latin characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 Sometimes you will want to include a dash in keywords, so that commands
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 like "w" consider "upper-case" to be one word. You can do it like this: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 :set iskeyword+=-
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 :set iskeyword
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 < iskeyword=@,48-57,_,192-255,- ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 If you look at the new value, you will see that Vim has added a comma for you.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 To remove a character use "-=". For example, to remove the underscore: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 :set iskeyword-=_
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 :set iskeyword
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 < iskeyword=@,48-57,192-255,- ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 This time a comma is automatically deleted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 ROOM FOR MESSAGES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 When Vim starts there is one line at the bottom that is used for messages.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 When a message is long, it is either truncated, thus you can only see part of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 it, or the text scrolls and you have to press <Enter> to continue.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 You can set the 'cmdheight' option to the number of lines used for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 messages. Example: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 :set cmdheight=3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 This does mean there is less room to edit text, thus it's a compromise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 Next chapter: |usr_06.txt| Using syntax highlighting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811
14519
5c5908e81e93 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 14372
diff changeset
812 Copyright: see |manual-copyright| vim:tw=78:ts=8:noet:ft=help:norl: