annotate runtime/doc/usr_06.txt @ 33128:b2c506f480c7 v9.0.1846

patch 9.0.1846: [security] crash in fullcommand Commit: https://github.com/vim/vim/commit/4c6fe2e2ea62469642ed1d80b16d39e616b25cf5 Author: Christian Brabandt <cb@256bit.org> Date: Sat Sep 2 19:30:03 2023 +0200 patch 9.0.1846: [security] crash in fullcommand Problem: crash in fullcommand Solution: Check for typeval correctly Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 02 Sep 2023 19:45:03 +0200
parents f8116058ca76
children 4635e43f2c6f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29314
f8116058ca76 release version 9.0
Bram Moolenaar <Bram@vim.org>
parents: 27036
diff changeset
1 *usr_06.txt* For Vim version 9.0. Last change: 2021 Nov 07
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 Using syntax highlighting
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 Black and white text is boring. With colors your file comes to life. This
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 not only looks nice, it also speeds up your work. Change the colors used for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 the different sorts of text. Print your text, with the colors you see on the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 |06.1| Switching it on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 |06.2| No or wrong colors?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 |06.3| Different colors
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 |06.4| With colors or without colors
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 |06.5| Printing with colors
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 |06.6| Further reading
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 Next chapter: |usr_07.txt| Editing more than one file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 Previous chapter: |usr_05.txt| Set your settings
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 Table of contents: |usr_toc.txt|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 *06.1* Switching it on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 It all starts with one simple command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 :syntax enable
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 That should work in most situations to get color in your files. Vim will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 automagically detect the type of file and load the right syntax highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 Suddenly comments are blue, keywords brown and strings red. This makes it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 easy to overview the file. After a while you will find that black&white text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 slows you down!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 If you always want to use syntax highlighting, put the ":syntax enable"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 command in your |vimrc| file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 If you want syntax highlighting only when the terminal supports colors, you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 can put this in your |vimrc| file: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 if &t_Co > 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 syntax enable
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 If you want syntax highlighting only in the GUI version, put the ":syntax
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 enable" command in your |gvimrc| file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 *06.2* No or wrong colors?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 There can be a number of reasons why you don't see colors:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 - Your terminal does not support colors.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 Vim will use bold, italic and underlined text, but this doesn't look
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 very nice. You probably will want to try to get a terminal with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 colors. For Unix, I recommend the xterm from the XFree86 project:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 |xfree-xterm|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 - Your terminal does support colors, but Vim doesn't know this.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 Make sure your $TERM setting is correct. For example, when using an
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 xterm that supports colors: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 setenv TERM xterm-color
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 or (depending on your shell): >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 TERM=xterm-color; export TERM
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 < The terminal name must match the terminal you are using. If it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 still doesn't work, have a look at |xterm-color|, which shows a few
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 ways to make Vim display colors (not only for an xterm).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 - The file type is not recognized.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 Vim doesn't know all file types, and sometimes it's near to impossible
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 to tell what language a file uses. Try this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 :set filetype
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 If the result is "filetype=" then the problem is indeed that Vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 doesn't know what type of file this is. You can set the type
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 manually: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 :set filetype=fortran
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 < To see which types are available, look in the directory
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 $VIMRUNTIME/syntax. For the GUI you can use the Syntax menu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 Setting the filetype can also be done with a |modeline|, so that the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 file will be highlighted each time you edit it. For example, this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 line can be used in a Makefile (put it near the start or end of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 file): >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 # vim: syntax=make
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 < You might know how to detect the file type yourself. Often the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 name extension (after the dot) can be used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 See |new-filetype| for how to tell Vim to detect that file type.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 - There is no highlighting for your file type.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 You could try using a similar file type by manually setting it as
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 mentioned above. If that isn't good enough, you can write your own
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 syntax file, see |mysyntaxfile|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 Or the colors could be wrong:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 - The colored text is very hard to read.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 Vim guesses the background color that you are using. If it is black
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 (or another dark color) it will use light colors for text. If it is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 white (or another light color) it will use dark colors for text. If
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 Vim guessed wrong the text will be hard to read. To solve this, set
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 the 'background' option. For a dark background: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 :set background=dark
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 < And for a light background: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 :set background=light
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 < Make sure you put this _before_ the ":syntax enable" command,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 otherwise the colors will already have been set. You could do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 ":syntax reset" after setting 'background' to make Vim set the default
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 colors again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 - The colors are wrong when scrolling bottom to top.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 Vim doesn't read the whole file to parse the text. It starts parsing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 wherever you are viewing the file. That saves a lot of time, but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 sometimes the colors are wrong. A simple fix is hitting CTRL-L. Or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 scroll back a bit and then forward again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 For a real fix, see |:syn-sync|. Some syntax files have a way to make
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 it look further back, see the help for the specific syntax file. For
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 example, |tex.vim| for the TeX syntax.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 *06.3* Different colors *:syn-default-override*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 If you don't like the default colors, you can select another color scheme. In
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 the GUI use the Edit/Color Scheme menu. You can also type the command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 :colorscheme evening
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 "evening" is the name of the color scheme. There are several others you might
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 want to try out. Look in the directory $VIMRUNTIME/colors.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 When you found the color scheme that you like, add the ":colorscheme" command
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 to your |vimrc| file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 You could also write your own color scheme. This is how you do it:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 1. Select a color scheme that comes close. Copy this file to your own Vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 directory. For Unix, this should work: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 !mkdir ~/.vim/colors
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 !cp $VIMRUNTIME/colors/morning.vim ~/.vim/colors/mine.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 This is done from Vim, because it knows the value of $VIMRUNTIME.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 2. Edit the color scheme file. These entries are useful:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 term attributes in a B&W terminal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 cterm attributes in a color terminal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 ctermfg foreground color in a color terminal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 ctermbg background color in a color terminal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 gui attributes in the GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 guifg foreground color in the GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 guibg background color in the GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 For example, to make comments green: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 :highlight Comment ctermfg=green guifg=green
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 Attributes you can use for "cterm" and "gui" are "bold" and "underline".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 If you want both, use "bold,underline". For details see the |:highlight|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 3. Tell Vim to always use your color scheme. Put this line in your |vimrc|: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 colorscheme mine
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 If you want to see what the most often used color combinations look like, use
671
83a006f81bac updated for version 7.0199
vimboss
parents: 7
diff changeset
182 this command: >
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183
671
83a006f81bac updated for version 7.0199
vimboss
parents: 7
diff changeset
184 :runtime syntax/colortest.vim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 You will see text in various color combinations. You can check which ones are
26057
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
187 readable and look nice. These aren't the only colors available to you though.
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
188 You can specify #rrggbb hex colors and you can define new names for hex
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
189 colors in |v:colornames| like so: >
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
190
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
191 let v:colornames['mine_red'] = '#aa0000'
27036
3e661b0cf500 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26100
diff changeset
192
26057
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
193 If you are authoring a color scheme for others to use, it is important
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
194 to define these colors only when they do not exist: >
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
195
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
196 call extend(v:colornames, {'mine_red': '#aa0000'}, 'keep')
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
197
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
198 This allows users of the color scheme to override the precise definition of
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
199 that color prior to loading your color scheme. For example, in a |.vimrc|
27036
3e661b0cf500 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26100
diff changeset
200 file: >
26057
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
201
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
202 runtime colors/lists/css_colors.vim
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
203 let v:colornames['your_red'] = v:colornames['css_red']
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
204 colorscheme yourscheme
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
205
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
206 As a color scheme author, you should be able to rely on some color names for
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
207 GUI colors. These are defined in `colors/lists/default.vim`. All such files
26100
babd9f1dbe12 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26057
diff changeset
208 found on the |'runtimepath'| are loaded each time the colorscheme command is
26057
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
209 run. A canonical list is provided by the vim distribution, which should
92c424550367 patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
210 include all X11 colors (previously defined in rgb.txt).
7
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 *06.4* With colors or without colors
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 Displaying text in color takes a lot of effort. If you find the displaying
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 too slow, you might want to disable syntax highlighting for a moment: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 :syntax clear
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 When editing another file (or the same one) the colors will come back.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 If you want to stop highlighting completely use: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 :syntax off
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 This will completely disable syntax highlighting and remove it immediately for
16944
d23afa4d8b63 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
227 all buffers. See |:syntax-off| for more details.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 *:syn-manual*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 If you want syntax highlighting only for specific files, use this: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 :syntax manual
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 This will enable the syntax highlighting, but not switch it on automatically
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 when starting to edit a buffer. To switch highlighting on for the current
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 buffer, set the 'syntax' option: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 :set syntax=ON
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 *06.5* Printing with colors *syntax-printing*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 In the MS-Windows version you can print the current file with this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 :hardcopy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 You will get the usual printer dialog, where you can select the printer and a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 few settings. If you have a color printer, the paper output should look the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 same as what you see inside Vim. But when you use a dark background the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 colors will be adjusted to look good on white paper.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 There are several options that change the way Vim prints:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 'printdevice'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 'printheader'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 'printfont'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 'printoptions'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 To print only a range of lines, use Visual mode to select the lines and then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 type the command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 v100j:hardcopy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 "v" starts Visual mode. "100j" moves a hundred lines down, they will be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 highlighted. Then ":hardcopy" will print those lines. You can use other
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 commands to move in Visual mode, of course.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 This also works on Unix, if you have a PostScript printer. Otherwise, you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 will have to do a bit more work. You need to convert the text to HTML first,
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
269 and then print it from a web browser.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 Convert the current file to HTML with this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
273 :TOhtml
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
274
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
275 In case that doesn't work: >
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
276
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 :source $VIMRUNTIME/syntax/2html.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 You will see it crunching away, this can take quite a while for a large file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 Some time later another window shows the HTML code. Now write this somewhere
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 (doesn't matter where, you throw it away later):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 :write main.c.html
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 Open this file in your favorite browser and print it from there. If all goes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 well, the output should look exactly as it does in Vim. See |2html.vim| for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 details. Don't forget to delete the HTML file when you are done with it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 Instead of printing, you could also put the HTML file on a web server, and let
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 others look at the colored text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 *06.6* Further reading
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 |usr_44.txt| Your own syntax highlighted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 |syntax| All the details.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 Next chapter: |usr_07.txt| Editing more than one file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301
14519
5c5908e81e93 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13963
diff changeset
302 Copyright: see |manual-copyright| vim:tw=78:ts=8:noet:ft=help:norl: