annotate runtime/kde-tips @ 204:a7547c77e563

updated for version 7.0060
author vimboss
date Tue, 15 Mar 2005 22:37:00 +0000
parents 4424b47a0797
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1 *vimtips.txt* This file comes from the Vim Online tip database. These tips
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2 were downloaded on Tue, 24 Sep 2002 15:27:26 -0700 More tips can be found at <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3 HREF="http://vim.sf.net/tip_index.php">http://vim.sf.net/tip_index.php</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4 A new tip file can be downloaded from <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5 HREF="http://vim.sf.net/tip_download.php">http://vim.sf.net/tip_download.php</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7 Thanks for using vim online.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9 <Tip category="KVim"> <html><center>the super star</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
10 HREF="http://vim.sf.net/tip_view.php?tip_id=1">http://vim.sf.net/tip_view.php?tip_id=1</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
12 When a discussion started about learning vim on the vim list Juergen Salk
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
13 mentioned the "*" key as something that he wished he had know earlier. When
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
14 I read the mail I had to go help on what the heck the "*" did. I also wish
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
15 I had known earlier...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
16
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
17 Using the "*" key while in normal mode searches for the word under the cursor.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
18
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
19 If that doesn't save you a lot of typing, I don't know what will.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
20
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
21 </pre></tip> </html> <Tip category="KVim"> <html><center>easy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
22 edit of files in the same directory</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
23 HREF="http://vim.sf.net/tip_view.php?tip_id=2">http://vim.sf.net/tip_view.php?tip_id=2</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
24
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
25 It was often frustrating when I would open a file deep in the code tree and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
26 then realize I wanted to open another file in that same directory. Douglas
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
27 Potts taught me a nice way to do this. Add the following snipit to your vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
28
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
29 " Edit another file in the same directory as the current file " uses
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
30 expression to extract path from current file's path " (thanks Douglas Potts)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
31 if has("unix")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
32 map ,e :e &lt;C-R&gt;=expand("%:p:h") . "/" &lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
33 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
34 map ,e :e &lt;C-R&gt;=expand("%:p:h") . "\" &lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
35 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
36
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
37 Then when you type ,e in normal mode you can use tab to complete to the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
38 file. You can also expand this to allow for spitting, etc. Very very nice.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
39
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
40 </pre></tip> </html> <Tip category="KVim"> <html><center>use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
41 vim to quickly compile java files</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
42 HREF="http://vim.sf.net/tip_view.php?tip_id=3">http://vim.sf.net/tip_view.php?tip_id=3</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
43
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
44 For a number of years I used vim on an SGI box. When I left my job at SGI
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
45 I went to a company that developed on PCs. For 2 years I used IDEs. I was
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
46 unhappy. I was frustrated. I couldn't figure out why. (Beyond my machine
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
47 crashing twice a day.) Finally I upgraded to windows 2000 (kind of stable!) and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
48 started using vim as an IDE. All was good. Here is how you use vim to compile
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
49 your java:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
50
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
51 1. While I'm sure this works with javac, javac is slow slow slow. So download
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
52 the Jikes complier first. (Jikes is from ibm, search on google for jikes
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
53 and you will find it..available on most platforms.)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
54
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
55 2. Add the following to your vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
56
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
57 set makeprg=jikes -nowarn -Xstdout +E % set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
58 errorformat=%f:%l:%c:%*\d:%*\d:%*\s%m
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
59
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
60 3. When you are editing a java file type :make and it will compile the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
61 current file and jump you to the first error in the file (if any). Read
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
62 ":help quickfix" for how to move between errors.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
63
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
64 To setup your classpath environment either launch gvim from a shell that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
65 has your classpath/path setup or use the "let" command to configure it in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
66 your vimrc.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
67
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
68 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
69 <html><center>Any word completion</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
70 HREF="http://vim.sf.net/tip_view.php?tip_id=4">http://vim.sf.net/tip_view.php?tip_id=4</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
71
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
72 Either when programming or writing, I tend to have some identifiers or words
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
73 that I use all the time. By sheer accident, I noticed the 'ctrl-n' command,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
74 that will attempt to complete the word under the cursor. Hit it once, and it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
75 will try to complete it with the first match in the current file. If there is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
76 no match, it will (at least in the case of C code) search through all files
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
77 included from the current one. Repeated invocations will cycle through all
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
78 found matches.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
79
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
80 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
81 <html><center>Quickly searching for a word</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
82 HREF="http://vim.sf.net/tip_view.php?tip_id=5">http://vim.sf.net/tip_view.php?tip_id=5</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
83
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
84 To search for a word under the cursor in the current file you can use either
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
85 the "*" or "#" keys.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
86
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
87 The "*" key will search for the word from the current cursor position to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
88 the end of the file. The "#" key will search for the word from the current
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
89 cursor position to the top of the file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
90
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
91 Note that the above two keys will search for the whole word and not the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
92 partial word. This is equivalent to using the &lt;word&gt; pattern in the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
93 search commands (/ and ?).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
94
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
95 To search for partial matches, you can use the "g*" and "g#" key sequence.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
96
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
97 You can also use the mouse to search for a word. This will only work in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
98 the GUI version of VIM (gvim) or a console version of VIM in an xterm which
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
99 accepts a mouse. Also, the 'mousemodel' should be set to 'extend'. Add the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
100 following line to your .vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
101
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
102 set mousemodel=extend
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
103
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
104 To search for a word under the cursor from the current cursor position to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
105 the end of the file, press the shift key and click on the word using the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
106 left mouse button. To search in the opposite direction, press the shift
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
107 key and click on the word using the the right mouse button.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
108
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
109 To get more help on these, use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
110
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
111 :help * :help # :help g* :help g# :help &lt;S-LeftMouse&gt; :help
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
112 &lt;S-RightMouse&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
113
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
114 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
115 <html><center>Using the % key</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
116 HREF="http://vim.sf.net/tip_view.php?tip_id=6">http://vim.sf.net/tip_view.php?tip_id=6</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
117
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
118 The % key can be used
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
119
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
120 1. To jump to a matching opening or closing parenthesis, square
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
121 bracket or a curly brace i.e. ([{}])
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
122 2. To jump to start or end of a C-style comment /* */. 3. To jump to a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
123 matching #if, #ifdef, #else, #elif, #endif C
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
124 preprocessor conditionals.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
125
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
126 To get more information about this, do
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
127
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
128 :help %
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
129
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
130 The % key can be extended to support other matching pairs by modifying the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
131 "matchpairs" option. Read the help on
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
132
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
133 :help matchpairs
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
134
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
135 </pre></tip> </html> <Tip category="KVim"> <html><center>Jumping
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
136 to the start and end of a code block</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
137 HREF="http://vim.sf.net/tip_view.php?tip_id=7">http://vim.sf.net/tip_view.php?tip_id=7</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
138
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
139 To jump to the beginning of a C code block (while, switch, if etc), use the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
140 [{ command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
141
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
142 To jump to the end of a C code block (while, switch, if etc), use the ]}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
143 command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
144
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
145 The above two commands will work from anywhere inside the code block.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
146
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
147 To jump to the beginning of a parenthesis use the [( command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
148
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
149 To jump to the end of a parenthesis use the ]) command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
150
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
151 To get more help on these commands, do
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
152
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
153 :help [{ :help ]} :help [( :help ])
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
154
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
155 </pre></tip> </html> <Tip category="KVim"> <html><center>Jumping
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
156 to the declaration of a local/global variable</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
157 HREF="http://vim.sf.net/tip_view.php?tip_id=8">http://vim.sf.net/tip_view.php?tip_id=8</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
158
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
159 'gd' command: To jump to the declaration of a local variable in a C program,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
160 position the cursor on the name of the variable and use the gd command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
161
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
162 'gD' command: To jump to the declaration of a global variable in a C program,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
163 position the cursor on the name of the variable and use the gD command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
164
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
165 </pre></tip> </html> <Tip category="KVim"> <html><center>Displaying
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
166 a variable/macro definition</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
167 HREF="http://vim.sf.net/tip_view.php?tip_id=9">http://vim.sf.net/tip_view.php?tip_id=9</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
168
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
169 To display the definition of a variable, place the cursor on the variable
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
170 and use the [i command. To display a macro definition, place the cursor on
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
171 the macro name and use the [d command. Note that these commands will work
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
172 most of the time (not all the time). To get more help on these commands, use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
173
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
174 :help [i :help [d
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
175
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
176 </pre></tip> </html> <Tip category="KVim"> <html><center>Jumping
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
177 to previosuly visited locations in a file</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
178 HREF="http://vim.sf.net/tip_view.php?tip_id=10">http://vim.sf.net/tip_view.php?tip_id=10</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
179
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
180 Vim remembers all the locations visited by you in a file in a session.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
181 You can jump to the older locations by pressing the Ctrl-O key. You can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
182 jump to the newer locations by pressing the Ctrl-I or the &lt;Tab&gt; key.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
183
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
184 To get more help on these keys, use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
185
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
186 :help CTRL-O :help CTRL-I :help jump-motions
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
187
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
188 </pre></tip> </html> <Tip category="KVim"> <html><center>Completing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
189 words quicky in insert mode</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
190 HREF="http://vim.sf.net/tip_view.php?tip_id=11">http://vim.sf.net/tip_view.php?tip_id=11</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
191
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
192 In Insert mode, press the Ctrl-p or Ctrl-n key to complete part of a word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
193 that has been typed.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
194
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
195 This is useful while typing C programs to complete long variable and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
196 function names. This also helps in avoiding typing mistakes.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
197
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
198 Note that using the 'complete' option, you can complete keywords defined in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
199 one of the include files, tag file, etc.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
200
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
201 To get more help on this, use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
202
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
203 :help i_Ctrl-N :help i_Ctrl-P :help ins-completion :help complete
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
204
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
205 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
206 <html><center>Converting tabs to spaces</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
207 HREF="http://vim.sf.net/tip_view.php?tip_id=12">http://vim.sf.net/tip_view.php?tip_id=12</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
208
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
209 To insert space characters whenever the tab key is pressed, set the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
210 'expandtab' option:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
211
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
212 set expandtab
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
213
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
214 With this option set, if you want to enter a real tab character use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
215 Ctrl-V&lt;Tab&gt; key sequence.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
216
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
217 To control the number of space characters that will be inserted when the tab
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
218 key is pressed, set the 'tabstop' option. For example, to insert 4 spaces
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
219 for a tab, use:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
220
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
221 set tabstop=4
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
222
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
223 After the 'expandtab' option is set, all the new tab characters entered will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
224 be changed to spaces. This will not affect the existing tab characters.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
225 To change all the existing tab characters to match the current tab settings,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
226 use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
227
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
228 :retab
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
229
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
230 To change the number of space characters inserted for indentation, use the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
231 'shiftwidth' option:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
232
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
233 set shiftwidth=4
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
234
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
235 For example, to get the following coding style,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
236 - No tabs in the source file - All tab characters are 4 space
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
237 characters
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
238
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
239 use the following set of options:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
240
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
241 set tabstop=4 set shiftwidth=4 set expandtab
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
242
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
243 Add the above settings to your .vimrc file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
244
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
245 To get more help on these options, use :help tabstop :help shiftwidth :help
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
246 expandtab
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
247
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
248 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
249 <html><center>Incremental search</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
250 HREF="http://vim.sf.net/tip_view.php?tip_id=13">http://vim.sf.net/tip_view.php?tip_id=13</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
251
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
252 To move the cursor to the matched string, while typing the search string,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
253 set the following option in the .vimrc file:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
254
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
255 set incsearch
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
256
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
257 You can complete the search by pressing the Enter key. To cancel the search,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
258 press the escape key.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
259
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
260 </pre></tip> </html> <Tip category="KVim"> <html><center>Highlighting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
261 all the search pattern matches</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
262 HREF="http://vim.sf.net/tip_view.php?tip_id=14">http://vim.sf.net/tip_view.php?tip_id=14</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
263
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
264 To highlight all the search pattern matches in a file set the following option:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
265
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
266 :set hlsearch
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
267
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
268 After this option is set, if you search for a pattern, all the matches in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
269 the file will be highlighted in yellow.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
270
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
271 To disable the highlighting temporarily, use the command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
272
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
273 :nohlsearch
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
274
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
275 This command will remove the highlighting for the current search.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
276 The highlighting will come back for the next search.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
277
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
278 To disable the highlighting completely, set the following option:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
279
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
280 :set nohlsearch
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
281
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
282 By default, the hlsearch option is turned off.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
283
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
284 To get more help on this option, use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
285
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
286 :help 'hlsearch' :help :nohlsearch
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
287
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
288 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
289 <html><center>Displaying status line always</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
290 HREF="http://vim.sf.net/tip_view.php?tip_id=15">http://vim.sf.net/tip_view.php?tip_id=15</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
291
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
292 To display the status line always, set the following option in your .vimrc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
293 file:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
294
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
295 set laststatus=2
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
296
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
297 The advantage of having the status line displayed always is, you can see
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
298 the current mode, file name, file status, ruler, etc.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
299
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
300 To get more help on this, use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
301
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
302 :help laststatus
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
303
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
304 </pre></tip> </html> <Tip category="KVim"> <html><center>Avoiding
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
305 the "Hit ENTER to continue" prompts</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
306 HREF="http://vim.sf.net/tip_view.php?tip_id=16">http://vim.sf.net/tip_view.php?tip_id=16</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
307
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
308 To avoid the "Hit ENTER to continue" prompt, use the 'shortmess' option.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
309 Add the following line to your .vimrc file:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
310
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
311 set shortmess=a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
312
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
313 Also, you can increase the height of the command line to 2
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
314
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
315 set cmdheight=2
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
316
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
317 The default command height is 1.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
318
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
319 To get more help on these options, use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
320
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
321 :help hit-enter :help shortmess :help cmdheight
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
322
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
323 </pre></tip> </html> <Tip category="KVim"> <html><center>Erasing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
324 previosuly entered characters in insert mode</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
325 HREF="http://vim.sf.net/tip_view.php?tip_id=17">http://vim.sf.net/tip_view.php?tip_id=17</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
326
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
327 In insert mode, to erase previously entered characters, set the following
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
328 option:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
329
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
330 set backspace=2
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
331
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
332 By default, this option is empty. If this option is empty, in insert mode,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
333 you can not erase characters entered before this insert mode started.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
334 This is the standard Vi behavior.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
335
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
336 To get more help on this, use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
337
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
338 :help 'backspace'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
339
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
340 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
341 <html><center>Cleanup your HTML</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
342 HREF="http://vim.sf.net/tip_view.php?tip_id=18">http://vim.sf.net/tip_view.php?tip_id=18</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
343
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
344 From Johannes Zellner on the vim list:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
345
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
346 You can use vim's makeprg and equalprg to clean up HTML. First download
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
347 html tidy from <A HREF="http://www.w3.org/People/Raggett/tidy/. Then use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
348 the following commands.">http://www.w3.org/People/Raggett/tidy/. Then use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
349 the following commands.</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
350
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
351 vim6? exe 'setlocal equalprg=tidy -quiet -f '.&errorfile setlocal makeprg=tidy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
352 -quiet -e %
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
353
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
354 vim5? exe 'set equalprg=tidy -quiet -f '.&errorfile set makeprg=tidy -quiet
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
355 -e %
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
356
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
357 At this point you can use make to clean up the full file or you can use =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
358 to clean up sections.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
359
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
360 :help = :help equalprg :help makeprg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
361
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
362 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
363 <html><center>line numbers...</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
364 HREF="http://vim.sf.net/tip_view.php?tip_id=19">http://vim.sf.net/tip_view.php?tip_id=19</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
365
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
366 I have started doing all my code reviews on a laptop because of the number
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
367 command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
368
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
369 :set number will put line numbers along the left side of a window
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
370
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
371 :help number
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
372
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
373 </pre></tip> </html> <Tip category="KVim"> <html><center>Are *.swp
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
374 and *~ files littering your working directory?</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
375 HREF="http://vim.sf.net/tip_view.php?tip_id=20">http://vim.sf.net/tip_view.php?tip_id=20</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
376
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
377 Have you ever been frustrated at swap files and backups cluttering up your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
378 working directory?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
379
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
380 Untidy:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
381 ons.txt ons.txt~ README README~ tester.py tester.py~
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
382
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
383 Here are a couple of options that can help:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
384
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
385 set backupdir=./.backup,.,/tmp set directory=.,./.backup,/tmp
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
386
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
387 This way, if you want your backups to be neatly grouped, just create
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
388 a directory called '.backup' in your working directory. Vim will stash
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
389 backups there. The 'directory' option controls where swap files go. If your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
390 working directory is not writable, Vim will put the swap file in one of the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
391 specified places.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
392
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
393 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
394 <html><center>easy pasting to windows apps</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
395 HREF="http://vim.sf.net/tip_view.php?tip_id=21">http://vim.sf.net/tip_view.php?tip_id=21</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
396
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
397 In Vim, the unnamed register is the " register, and the Windows Clipboard is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
398 the * register. This means that if you yank something, you have to yank it to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
399 the * register if you want to paste it into a Windows app. If this is too much
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
400 trouble, set the 'clipboard' option to 'unnamed'. Then you always yank to *.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
401
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
402 So pasting to windows apps doesn't require prefixing "* :
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
403
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
404 set clipboard=unnamed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
405
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
406 </pre></tip> </html> <Tip category="KVim"> <html><center>handle
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
407 common typos for :commands</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
408 HREF="http://vim.sf.net/tip_view.php?tip_id=22">http://vim.sf.net/tip_view.php?tip_id=22</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
409
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
410 I frequently hold the shift key for too long when typing, for instance :wq,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
411 and end up with :Wq. Vim then whines "Not an editor command: Wq"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
412
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
413 In my .vimrc, I have taught vim my common typos: command! Q quit command! W
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
414 write command! Wq wq " this one won't work, because :X is already a built-in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
415 command command! X xit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
416
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
417 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
418 <html><center>Vim xterm title</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
419 HREF="http://vim.sf.net/tip_view.php?tip_id=23">http://vim.sf.net/tip_view.php?tip_id=23</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
420
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
421 Check out your .vimrc. If 'set notitle' is an entry, comment it out with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
422 a quotation mark ("). Now your xterm should inherit the title from Vim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
423 e.g. 'Vim - ~/.vimrc'. This can be quite nice when programming and editing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
424 lots of files at the same time. by [jonasbn@wanadoo.dk]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
425
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
426 </pre></tip> </html> <Tip category="KVim"> <html><center>changing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
427 the default syntax highlighting</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
428 HREF="http://vim.sf.net/tip_view.php?tip_id=24">http://vim.sf.net/tip_view.php?tip_id=24</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
429
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
430 Here are some pointers to the vim documentation. Notice that the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
431 mechanism is different in vim 6.0 and vim 5.x.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
432
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
433 1. I want *.foo files to be highlighted like HTML files.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
434
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
435 :help new-filetype <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
436 HREF="http://www.vim.org/html/autocmd.html#new-filetype">http://www.vim.org/html/autocmd.html#new-filetype</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
437
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
438 2. I want to define a syntax file for *.bar files. Read the above and also
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
439
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
440 :help mysyntaxfile <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
441 HREF="http://www.vim.org/html/syntax.html#mysyntaxfile">http://www.vim.org/html/syntax.html#mysyntaxfile</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
442
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
443 3. I want to make a few changes to the existing syntax highlighting.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
444 Depending on the x in 5.x, either read the above and page down a few screens,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
445 or you may be able to skip right to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
446
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
447 :help mysyntaxfile-add <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
448 HREF="http://www.vim.org/html/syntax.html#mysyntaxfile-add">http://www.vim.org/html/syntax.html#mysyntaxfile-add</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
449
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
450 4. I want to change some of the colors from their defaults. Again, read
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
451
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
452 :help mysyntaxfile <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
453 HREF="http://www.vim.org/html/syntax.html#mysyntaxfile">http://www.vim.org/html/syntax.html#mysyntaxfile</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
454
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
455 </pre></tip> </html> <Tip category="KVim"> <html><center>color
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
456 highlighting on telnet (esp w/ SecureCRT)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
457 HREF="http://vim.sf.net/tip_view.php?tip_id=25">http://vim.sf.net/tip_view.php?tip_id=25</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
458
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
459 The following settings in .vimrc will enable color highlighting when using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
460 SecureCRT and may work on other telnet packages. The terminal type should
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
461 be selected as ANSI and color enabled.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
462
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
463 if !has("gui_running") set t_Co=8 set t_Sf=^[[3%p1%dm set t_Sb=^[[4%p1%dm endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
464
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
465 The ^[ is entered as "&lt;ctrl-v&gt;&lt;esc&gt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
466
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
467 </pre></tip> </html> <Tip category="KVim"> <html><center>Getting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
468 rid of ^M - mixing dos and unix</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
469 HREF="http://vim.sf.net/tip_view.php?tip_id=26">http://vim.sf.net/tip_view.php?tip_id=26</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
470
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
471 If you work in a mixed environment you will often open files that have ^M's
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
472 in them. An example would be this:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
473
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
474 ------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
475 import java.util.Hashtable; ^M import java.util.Properties; ^Mimport
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
476 java.io.IOException; import org.xml.sax.AttributeList; ^M import
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
477 org.xml.sax.HandlerBase; ^Mimport org.xml.sax.SAXException;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
478
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
479 /**^M
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
480 * XMLHandler: This class parses the elements contained^M * within a XML
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
481 message and builds a Hashtable^M
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
482
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
483 [snip] ------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
484
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
485 Notice that some programs are not consistent in the way they insert the line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
486 breaks so you end up with some lines that have both a carrage return and a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
487 ^M and some lines that have a ^M and no carrage return (and so blend into
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
488 one). There are two steps to clean this up.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
489
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
490 1. replace all extraneous ^M:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
491
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
492 :%s/^M$//g
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
493
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
494 BE SURE YOU MAKE the ^M USING "CTRL-V CTRL-M" NOT BY TYPING "CARROT M"! This
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
495 expression will replace all the ^M's that have carriage returns after them
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
496 with nothing. (The dollar ties the search to the end of a line)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
497
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
498 2. replace all ^M's that need to have carriage returns:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
499
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
500 :%s/^M//g
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
501
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
502 Once again: BE SURE YOU MAKE the ^M USING "CTRL-V CTRL-M" NOT BY TYPING
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
503 "CARROT M"! This expression will replace all the ^M's that didn't have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
504 carriage returns after them with a carriage return.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
505
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
506 Voila! Clean file. Map this to something if you do it frequently.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
507
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
508 :help ffs - for more info on file formats
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
509
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
510 thanks to jonathan merz, douglas potts, and benji fisher
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
511
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
512 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
513 <html><center>Convert hex to dec</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
514 HREF="http://vim.sf.net/tip_view.php?tip_id=27">http://vim.sf.net/tip_view.php?tip_id=27</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
515
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
516 when you check the output of objdump, you'll confused by the $0xFFFFFFc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
517 operand, this function translate the hexcamal to decimal. function! Hex2Dec()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
518 let lstr = getline(".") let hexstr = matchstr(lstr, '0x[a-f0-9]+')
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
519 while hexstr != ""
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
520 let hexstr = hexstr + 0 exe 's#0x[a-f0-9]+#'.hexstr."#" let lstr =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
521 substitute(lstr, '0x[a-f0-9]+', hexstr, "") let hexstr = matchstr(lstr,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
522 '0x[a-f0-9]+')
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
523 endwhile
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
524 endfunction usage: 5,8call Hex2Dec()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
525
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
526 </pre></tip> </html> <Tip category="KVim"> <html><center>add a line-number
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
527 to every line without cat or awk alike utilities.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
528 HREF="http://vim.sf.net/tip_view.php?tip_id=28">http://vim.sf.net/tip_view.php?tip_id=28</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
529
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
530 With Unix-like environment, you can use cat or awk to generate a line number
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
531 easily, because vim has a friendly interface with shell, so everything work
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
532 in vim as well as it does in shell. :%!call -n or :%!awk '{print NR,$0}'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
533
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
534 But, if you use vim in MS-DOS, of win9x, win2000, you loss these tookit.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
535 here is a very simple way to archive this only by vim: fu! LineIt()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
536 exe ":s/^/".line(".")."/"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
537 endf
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
538
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
539 Well, a sequence composed with alphabet is as easy as above:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
540 exe "s/^/".nr2char(line("."))."/"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
541
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
542 </pre></tip> </html> <Tip category="KVim"> <html><center>reverse
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
543 all the line with only 7 keystroke in vim</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
544 HREF="http://vim.sf.net/tip_view.php?tip_id=29">http://vim.sf.net/tip_view.php?tip_id=29</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
545
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
546 :g/^/m0 well, 1. : bring you to command-line mode(also known as ex-mode)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
547 from normal-mode(also known as command mode). 2. g means you'll take an
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
548 action through the whole file, generally perform a search, `v' also perform
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
549 a search but it match the line not match the canonical expression. 3. /
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
550 begins the regular express 4. ^ is a special character respect the start
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
551 of a line. 5. the second / ends the regular express and indicate that the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
552 remains is action to do. 6. m means move, `t` and `co' for copy, `d' for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
553 delete 7. 0 is the destination line.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
554
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
555 you can use :g/regexp/t$ to filter all lines and pick the match line together
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
556 and copy them to the end of the buffer or :g/regexp/y A to put them into a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
557 register(not eax, ebx...)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
558
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
559 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
560 <html><center>Increasing or decreasing numbers</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
561 HREF="http://vim.sf.net/tip_view.php?tip_id=30">http://vim.sf.net/tip_view.php?tip_id=30</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
562
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
563 To increase a number under or nearest to the right of the cursor, go to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
564 Normal mode and type:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
565 Ctrl-A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
566
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
567 To decrease, type:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
568 Ctrl-X
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
569
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
570 Using this in a macro simplifies generating number sequences a lot.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
571
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
572 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
573 <html><center>Find and Replace</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
574 HREF="http://vim.sf.net/tip_view.php?tip_id=31">http://vim.sf.net/tip_view.php?tip_id=31</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
575
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
576 To find and replace one or more occurences of a given text pattern with a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
577 new text string, use the s[ubstitute] command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
578
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
579 There are a variety of options, but these are what you most probably want:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
580
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
581 :%s/foo/bar/g find each occurance of 'foo' and replace it with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
582 'bar' without asking for confirmation
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
583
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
584 :%s/foo/bar/gc find each occurance of 'foo' and replace it with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
585 'bar' asking for confirmation first
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
586
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
587 :%s/&lt;foo&gt;/bar/gc find (match exact word only) and replace each
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
588 occurance of 'foo' with 'bar'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
589
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
590 :%s/foo/bar/gci find (case insensitive) and replace each occurance of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
591 'foo' with 'bar'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
592
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
593 :%s/foo/bar/gcI find (case sensitive) and replace each occurance of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
594 'foo' with 'bar'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
595
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
596 NB: Without the 'g' flag, replacement occurs only for the first occurrence
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
597 in each line.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
598
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
599 For a full description and some more interesting examples of the substitute
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
600 command refer to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
601
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
602 :help substitute
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
603
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
604 See also:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
605
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
606 :help cmdline-ranges :help pattern :help gdefault
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
607
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
608 </pre></tip> </html> <Tip category="KVim"> <html><center>Write
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
609 your own vim function(scripts)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
610 HREF="http://vim.sf.net/tip_view.php?tip_id=32">http://vim.sf.net/tip_view.php?tip_id=32</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
611
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
612 compare to C and shell(bash), herein is some vim specifics about vim-script:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
613 1. A function name must be capitalized.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
614 hex2dec is invalid Hex2dec is valid while in c and shell(bash), both
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
615 lowercase and uppercase is allowed.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
616 2. how to reference the parameters
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
617 fu! Hex2dec(var1, var2)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
618 let str=a:var1 let str2=a:var2
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
619 you must prefix the parameter name with "a:", and a:var1 itself is read-only
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
620 in c, you reference the parameter directly and the parameter is writable.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
621 3. how to implement variable parameter
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
622 fu! Hex2dec(fixpara, ...)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
623 a:0 is the real number of the variable parameter when you invoke the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
624 function, with :Hex2dec("asdf", 4,5,6), a:0=3, and a:1=4 a:2=5 a:3=6
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
625 you can combine "a:" and the number to get the value while i&lt;a:0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
626 exe "let num=a:".i let i=i+1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
627 endwhile in c, the function get the real number by checking the additional
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
628 parameter such as printf family, or by checking the special value such
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
629 as NULL
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
630 4. where is the vim-library
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
631 yes, vim has its own function-library, just like *.a in c :help functions
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
632 5. can I use += or ++ operator?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
633 Nop, += and ++ (and -=, -- and so on)operator gone away in vim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
634 6. How can I assign a value to a variables and fetch its value?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
635 let var_Name=value let var1=var2 like it does in c, except you must use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
636 let keyword
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
637 7. Can I use any ex-mode command in a function?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
638 As I know, yes, just use it directly, as if every line you type appears
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
639 in the familar :
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
640 8. Can I call a function recurse?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
641 Yes, but use it carefully to avoid infinte call.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
642 9. Can I call another function in a function?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
643 Course, like C does.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
644 10. Must I compile the function?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
645 No, you needn't and you can't, just :so script_name, after this you can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
646 call the function freely.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
647 11. Is it has integer and char or float data type?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
648 No, like perl, vim script justify the variable type depend upon the context
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
649 :let a=1 :let a=a."asdf" :echo a you'll get `1asdf' :let a=1 :let a=a+2
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
650 :echo a you'll get 3 But it differs from perl.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
651 12. Must I append a `;' in every statement?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
652 No, never do that. ; is required in C, and optional in shell for each
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
653 statement in a alone line. But is forbidden in vim. if you want combine
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
654 servals statement in one single line, use `|'. Take your mind that every
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
655 statement appears in function should be valid in ex-mode(except for some
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
656 special statement).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
657
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
658 </pre></tip> </html> <Tip category="KVim"> <html><center>toggle
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
659 off the line-number when enter on-line help</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
660 HREF="http://vim.sf.net/tip_view.php?tip_id=33">http://vim.sf.net/tip_view.php?tip_id=33</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
661
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
662 I like the line-number for myself editing. But I hate it in on-line help
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
663 page because it force the screen wrapped. :au filetype help :se nonu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
664
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
665 </pre></tip> </html> <Tip category="KVim"> <html><center>control
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
666 the position of the new window</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
667 HREF="http://vim.sf.net/tip_view.php?tip_id=34">http://vim.sf.net/tip_view.php?tip_id=34</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
668
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
669 :se splitbelow make the new window appears below the current window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
670 :se splitright make the new window appears in right.(only 6.0 version can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
671 do a vsplit)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
672
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
673 </pre></tip> </html> <Tip category="KVim"> <html><center>translate
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
674 // style comment to /* */and vice vesa</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
675 HREF="http://vim.sf.net/tip_view.php?tip_id=35">http://vim.sf.net/tip_view.php?tip_id=35</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
676
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
677 the `|' concatenate servals ex-command in one line. It's the key to translate
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
678 // style comments to /* */ style :g#^s{-}//#s##/*# | s#$#*/#
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
679
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
680 the `|' keep the current line matchs ^s{-}// to perform s#$#*/
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
681
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
682 /* ... */ ---&gt; //style :g#/*(.{-})*/#//1#
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
683
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
684 /* ....
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
685 .... .....
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
686 */ =====&gt; //...... //...... //...... style: ? Anyone implement it?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
687
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
688 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
689 <html><center>Using Gnu-info help in vim</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
690 HREF="http://vim.sf.net/tip_view.php?tip_id=36">http://vim.sf.net/tip_view.php?tip_id=36</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
691
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
692 K in normal bring you the man page about the keyword under current cursor.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
693 :nnoremap &lt;F1&gt; :exe ":!info ".expand("&lt;cword&gt;") Now press F1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
694 while the cursor is hold by a keyword such as printf will bring you to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
695 Gnu-info help page :h &lt;F1&gt; :h nnoremap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
696
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
697 </pre></tip> </html> <Tip category="KVim"> <html><center>The
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
698 basic operation about vim-boolean optionals</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
699 HREF="http://vim.sf.net/tip_view.php?tip_id=37">http://vim.sf.net/tip_view.php?tip_id=37</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
700
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
701 :set number switch the number on :set nonumber switch it off :set invnumber
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
702 or :set number! switch it inverse against the current setting :set number&
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
703 get the default value vim assums.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
704
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
705 replace number with any legal vim-boolean optionals, they all works well.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
706 for vim-non-boolean optionals :set optional& also works properly.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
707
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
708 </pre></tip> </html> <Tip category="KVim"> <html><center>Cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
709 one line at a time when :set wrap</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
710 HREF="http://vim.sf.net/tip_view.php?tip_id=38">http://vim.sf.net/tip_view.php?tip_id=38</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
711
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
712 If your tierd of the cursor jumping past 5 lines when :set wrap then add
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
713 these mappings to you vimrc file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
714
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
715 nnoremap j gj nnoremap k gk vnoremap j gj vnoremap k gk nnoremap &lt;Down&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
716 gj nnoremap &lt;Up&gt; gk vnoremap &lt;Down&gt; gj vnoremap &lt;Up&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
717 gk inoremap &lt;Down&gt; &lt;C-o&gt;gj inoremap &lt;Up&gt; &lt;C-o&gt;gk
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
718
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
719 What they do is remap the cursor keys to use there `g' equvilant. See :help gj
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
720
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
721 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
722 <html><center>Undo and Redo</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
723 HREF="http://vim.sf.net/tip_view.php?tip_id=39">http://vim.sf.net/tip_view.php?tip_id=39</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
724
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
725 To undo recent changes, use the u[ndo] command:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
726
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
727 u undo last change (can be repeated to undo preceding commands)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
728 U return the line to its original state (undo all changes in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
729 current line) CTRL-R Redo changes which were undone (undo the undo's).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
730
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
731 For a full description of the undo/redo commands refer to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
732
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
733 :help undo
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
734
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
735 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
736 <html><center>Insert a file</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
737 HREF="http://vim.sf.net/tip_view.php?tip_id=40">http://vim.sf.net/tip_view.php?tip_id=40</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
738
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
739 To insert the contents of a file (or the output of a system command) into
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
740 the current buffer, use the r[ead] command:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
741
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
742 Examples:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
743
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
744 :r foo.txt inserts the file foo.txt below the cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
745
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
746 :0r foo.txt inserts the file foo.txt above the first line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
747
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
748 :r !ls inserts a listing of your directory below the cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
749
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
750 :$r !pwd inserts the current working directory below the last line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
751
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
752 For more information about the r[ead] command refer to:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
753
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
754 :help read
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
755
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
756 See also:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
757
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
758 :help cmdline-ranges :help !cmd
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
759
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
760 </pre></tip> </html> <Tip category="KVim"> <html><center>Command-history
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
761 facilities for Oracle/sqlplus user</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
762 HREF="http://vim.sf.net/tip_view.php?tip_id=41">http://vim.sf.net/tip_view.php?tip_id=41</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
763
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
764 First of all, thanks Benji fisher, Stefan Roemer...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
765 and others in vim@vim.org which spend much time to answer questions,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
766 sometimes foolish question asked by someone like me. Without their I can't
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
767 get the final solution for my sqlplus work descripted follows.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
768 As Oracle user known, sqlplus has a very bad
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
769 command-line edition environment. It has no command-history, don't support
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
770 most of getline facilities. which MySQL and shell does it well. Even Microsoft
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
771 recogonize this point. In Windows2000, doskey is installed by default.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
772 Below is my vim-solution to sqlplus, which
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
773 record the command-history when you use edit(sqlplus builtin command) to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
774 open the editor specified by EDITOR environment variable. It saves the SQL
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
775 statement into a standalone file such as .sqlplus.history
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
776 Every time you open the file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
777 afiedt.buf(sqlplus's default command-buffer file), you get two splited windows,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
778 the buffer above is afiedt.buf, the buffer below is .sqlplus.history, you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
779 can see every SQL statement in the windows. If you want to use SQL statement
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
780 in line 5 to replace
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
781 the current command-buffer, just press 5K, then
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
782 :xa to back to you sqlplus. and use / to repeat the command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
783 saved in command-buffer file called afiedt.buf by default.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
784 It can't process multi-line SQL statement convinencely.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
785 Todo this, just use you favorite vim trick to do that:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
786 fu! VimSQL()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
787 nnoremap &lt;C-K&gt; :&lt;C-U&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
788 exe "let linenum=".v:count&lt;CR&gt;:1,$-1d&lt;CR&gt;&lt;C-W&gt;j:exe
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
789 lin enum."y"&lt;CR&gt;&lt;C-W&gt;kP
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
790 let linenum=line("$") 1,$-1w! &gt;&gt; ~/.sqlplus.history e
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
791 ~/.sqlplus.history execute ":$-".(linenum-1).",$m0" %!uniq if
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
792 line("$")&gt;100
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
793 101,$d
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
794 endif b# set splitbelow sp ~/.sqlplus.history au! BufEnter afiedt.buf
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
795 endf au BufEnter afiedt.buf call VimSQL()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
796
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
797 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
798 <html><center>Using marks</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
799 HREF="http://vim.sf.net/tip_view.php?tip_id=42">http://vim.sf.net/tip_view.php?tip_id=42</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
800
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
801 To mark one or more positions in a file, use the m[ark] command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
802
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
803 Examples:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
804
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
805 ma - set current cursor location as mark a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
806
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
807 'a - jump to beginning of line of mark a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
808
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
809 `a - jump to postition of mark a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
810
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
811 d'a - delete from current line to line of mark a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
812
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
813 d`a - delete from current cursor position to mark a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
814
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
815 c'a - change text from current line to line of mark a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
816
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
817 y`a - yank text to unnamed buffer from cursor to mark a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
818
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
819 :marks - list all the current marks
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
820
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
821 NB: Lowercase marks (a-z) are valid within one file. Uppercase marks (A-Z),
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
822 also called file marks, are valid between files.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
823
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
824 For a detailed description of the m[ark] command refer to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
825
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
826 :help mark
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
827
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
828 See also:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
829
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
830 :help various-motions
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
831
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
832 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
833 <html><center>Using abbreviations</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
834 HREF="http://vim.sf.net/tip_view.php?tip_id=43">http://vim.sf.net/tip_view.php?tip_id=43</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
835
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
836 To define abbreviations, use the ab[breviate] command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
837
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
838 Examples:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
839
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
840 :ab rtfm read the fine manual - Whenever you type 'rtfm' followed by a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
841 &lt;space&gt; (or &lt;esc&gt; or &lt;cr&gt;) vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
842 will expand this to 'read the fine manual'.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
843
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
844 :ab - list all defined abbreviations
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
845
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
846 :una[bbreviate] rtfm - remove 'rtfm' from the list of abbreviations
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
847
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
848 :abc[lear] - remove all abbreviations
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
849
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
850 NB: To avoid expansion in insert mode, type CTRL-V after the last character
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
851 of the abbreviation.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
852
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
853 For a detailed description of the ab[breviate] command and some more examples
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
854 refer to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
855
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
856 :help abbreviations
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
857
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
858 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
859 <html><center>Repeat last changes</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
860 HREF="http://vim.sf.net/tip_view.php?tip_id=44">http://vim.sf.net/tip_view.php?tip_id=44</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
861
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
862 Simple text changes in normal mode (e.g. "dw" or "J") can be repeated with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
863 the "." command. The last command-line change (those invoked with ":",
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
864 e.g. ":s/foo/bar") can be repeated with the "@:" command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
865
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
866 For more informations about repeating single changes refer to:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
867
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
868 :help single-repeat
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
869
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
870 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
871 <html><center>Using command-line history</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
872 HREF="http://vim.sf.net/tip_view.php?tip_id=45">http://vim.sf.net/tip_view.php?tip_id=45</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
873
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
874 You can recall previous command lines from a history table by hitting the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
875 &lt;Up&gt; and &lt;Down&gt; cursor keys in command-line mode. For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
876 this can be used to find the previous substitute command: Type ":s" and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
877 then &lt;Up&gt;.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
878
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
879 There are separate history tables for the ':' commands and for previous '/'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
880 or '?' search strings.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
881
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
882 To display the history of last entered commands or search strings, use the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
883 :his[tory] command:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
884
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
885 :his - Display command-line history.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
886
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
887 :his s - Display search string history.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
888
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
889
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
890 For a detailed description of the command-line history refer to:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
891
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
892 :help cmdline-history
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
893
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
894 See also:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
895
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
896 :help Cmdline-mode
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
897
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
898 </pre></tip> </html> <Tip category="KVim"> <html><center>Win32
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
899 binaries with perl, python, and tcl</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
900 HREF="http://vim.sf.net/tip_view.php?tip_id=46">http://vim.sf.net/tip_view.php?tip_id=46</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
901
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
902 &gt; Does anyone know if windows binaries of vim 5.7 are available with perl
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
903 and &gt; python support turned on?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
904
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
905 <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
906 HREF="ftp://vim.sourceforge.net/pub/vim/upload_binaries/">ftp://vim.sourceforge.net/pub/vim/upload_binaries/</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
907
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
908 <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
909 HREF="http://vim.sourceforge.net/bin_download/">http://vim.sourceforge.net/bin_download/</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
910
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
911 </pre></tip> </html> <Tip category="KVim"> <html><center>Swapping
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
912 characters, words and lines</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
913 HREF="http://vim.sf.net/tip_view.php?tip_id=47">http://vim.sf.net/tip_view.php?tip_id=47</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
914
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
915 To swap two characters or lines, use the following commands:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
916
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
917 xp - delete the character under the cursor and put it afterwards.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
918 (In other words, it swaps the characters.)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
919
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
920 ddp - delete the current line and put it afterwards.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
921 (In other words, it swaps the lines.)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
922
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
923 Unfortunately there is no universal solution to swap two words. You may
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
924 try the following ones, but don't expect too much of them:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
925
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
926 dawwP - delete the word under the cursor, move forward one word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
927 and put it back after the cursor. (In other words, it swaps
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
928 the current and following word.)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
929
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
930 dawbP - delete the word under the cursor, move backward on word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
931 and put it back after the cursor. (In other words, it swaps
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
932 the current and preceeding word.)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
933
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
934 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
935 <html><center>Moving around</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
936 HREF="http://vim.sf.net/tip_view.php?tip_id=48">http://vim.sf.net/tip_view.php?tip_id=48</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
937
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
938 You can save a lot of time when navigating through the text by using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
939 appropriate movements commands. In most cases the cursor keys, &lt;PageUp&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
940 or &lt;PageDown&gt; are NOT the best choice.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
941
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
942 Here is a selection of some basic movement commands that hopefully helps
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
943 you to acquire a taste for more:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
944
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
945 e - move to the end of a word w - move forward to the beginning of a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
946 word 3w - move forward three words b - move backward to the beginning of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
947 a word 3b - move backward three words
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
948
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
949 $ - move to the end of the line &lt;End&gt; - same as $ 0 -
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
950 move to the beginning of the line &lt;Home&gt; - same as 0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
951
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
952 ) - jump forward one sentence ( - jump backward one sentence
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
953
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
954 } - jump forward one paragraph { - jump backward one paragraph
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
955
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
956 H - jump to the top of the display M - jump to the middle of the display
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
957 L - jump to the bottom of the display
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
958
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
959 'm - jump to the beginning of the line of mark m `m - jump to the location
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
960 of mark m
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
961
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
962 G - jump to end of file 1G - jump to beginning of file 50G - jump to line 50
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
963
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
964 '' - return to the line where the cursor was before the latest jump `` -
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
965 return to the cursor position before the latest jump (undo the jump).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
966
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
967 % - jump to corresponding item, e.g. from an open brace to its
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
968 matching closing brace
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
969
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
970 For some more interesting movement commands (especially those for programmers)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
971 refer to:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
972
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
973 :help motion.txt
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
974
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
975 :help search-commands
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
976
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
977 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
978 <html><center>Switching case of characters</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
979 HREF="http://vim.sf.net/tip_view.php?tip_id=49">http://vim.sf.net/tip_view.php?tip_id=49</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
980
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
981 To switch the case of one or more characters use the "~", "gU" or "gu"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
982 commands.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
983
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
984 Examples:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
985
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
986 ~ - switch case of character under cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
987 (in visual-mode: switch case of highlighted text)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
988
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
989 3~ - switch case of next three characters
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
990
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
991 g~~ - switch case of current line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
992
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
993 U - in visual-mode: make highlighted text uppercase
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
994
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
995 gUU - make current line uppercase
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
996
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
997 u - in visual-mode: make highlighted text lowercase
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
998
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
999 guu - make current line lowercase
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1000
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1001 gUaw - make current word uppercase
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1002
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1003 guaw - make current word lowercase
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1004
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1005 For some more examples refer to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1006
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1007 :help ~
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1008
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1009 See also:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1010
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1011 :help simple-change
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1012
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1013 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1014 <html><center>Recovering files</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1015 HREF="http://vim.sf.net/tip_view.php?tip_id=50">http://vim.sf.net/tip_view.php?tip_id=50</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1016
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1017 If your computer has crashed while editing a file, you should be able to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1018 recover the file by typing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1019
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1020 vi -r &lt;filename&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1021
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1022 where &lt;filename&gt; is the name of the file you were editing at the time
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1023 of the crash. If you were editing without a file name, give an empty string
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1024 as argument:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1025
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1026 vim -r ""
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1027
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1028 To get a list of recoverable files start vim without arguments:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1029
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1030 vim -r
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1031
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1032 For more information about file recovery refer to:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1033
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1034 :help recovery
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1035
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1036 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1037 <html><center>Entering german umlauts</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1038 HREF="http://vim.sf.net/tip_view.php?tip_id=51">http://vim.sf.net/tip_view.php?tip_id=51</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1039
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1040 To enter german umlauts (or any other of those weired characters) not
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1041 available on your keyboard use 'digraphs':
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1042
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1043 In insert-mode type for example:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1044
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1045 CTRL-K "a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1046
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1047 CTRL-K ^e
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1048
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1049 which gives an 'ä' and 'e' with a hat.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1050
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1051 You can also set the digraph option:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1052
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1053 :set digraph (or :set dg)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1054
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1055 With digraph option set you can enter
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1056
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1057 " &lt;BS&gt; a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1058
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1059 ^ &lt;BS&gt; e
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1060
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1061 which gives the same result.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1062
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1063 To get a list of currently defined digraphs type
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1064
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1065 :dig[graphs]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1066
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1067 For more information about defining and using digraphs refer to:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1068
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1069 :help digraph.txt
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1070
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1071 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1072 <html><center>Scrolling synchronously</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1073 HREF="http://vim.sf.net/tip_view.php?tip_id=52">http://vim.sf.net/tip_view.php?tip_id=52</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1074
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1075 If you want to bind two or more windows such that when one window is scrolled,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1076 the other windows are scrolled simultaneously, set the 'scrollbind' option
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1077 for these windows:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1078
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1079 :set scrollbind
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1080
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1081 When a window that has 'scrollbind' set is scrolled, all other 'scrollbind'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1082 windows are scrolled the same amount, if possible.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1083
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1084 For more information about the 'scrollbind' option refer to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1085
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1086 :help scoll-binding
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1087
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1088 </pre></tip> </html> <Tip category="KVim"> <html><center>Better
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1089 colors for syntax highlighting</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1090 HREF="http://vim.sf.net/tip_view.php?tip_id=53">http://vim.sf.net/tip_view.php?tip_id=53</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1091
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1092 For syntax highlighting there are two sets of default color maps: One for a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1093 light and another one for a dark background. If you have a black background,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1094 use the following command to get a better color map for syntax highlighting:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1095
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1096 :set background=dark
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1097
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1098 You have to switch off and on again syntax highlighting to activate the new
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1099 color map:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1100
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1101 :syntax off :syntax on
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1102
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1103 For a detailled description of syntax highlighting refer to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1104
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1105 :help syntax.txt
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1106
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1107 See also the Vim syntax support file: $VIMRUNTIME/syntax/synload.vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1108
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1109 </pre></tip> </html> <Tip category="KVim"> <html><center>View
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1110 a Java Class File Decompiled thru Vim</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1111 HREF="http://vim.sf.net/tip_view.php?tip_id=54">http://vim.sf.net/tip_view.php?tip_id=54</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1112
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1113 Hi All, Wish u could view a Java Class File using Vim, Well ur query
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1114 ends here. First of all u will need a Java Decompiler to decompile the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1115 Class File. I would suggest the JAD decompiler by Pavel Kouznetsov <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1116 HREF="http://www.geocities.com/SiliconValley/Bridge/8617/jad.html">http://www.geocities.com/SiliconValley/Bridge/8617/jad.html</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1117
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1118 Its a command line decompiler and absolutely free. U can use any command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1119 line decompiler of ur choice.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1120
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1121 Next create a vimscript file called jad.vim as #########################
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1122 FILE START ################ augr class au! au bufreadpost,filereadpost
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1123 *.class %!d:jad.exe -noctor -ff -i -p % au bufreadpost,filereadpost
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1124 *.class set readonly au bufreadpost,filereadpost *.class set ft=java au
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1125 bufreadpost,filereadpost *.class normal gg=G au bufreadpost,filereadpost
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1126 *.class set nomodified augr END ######################## FILE END
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1127 #####################
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1128
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1129 Note:- Keep the Jad.exe in a directory with out white spaces. The -p options
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1130 directs JAD to send the output to standard output instead of a .jad file. Other
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1131 options are described on the JAD site.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1132
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1133 Next add the following line in the .vimrc file. so jad.vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1134
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1135 Next time u do vim abc.class. Viola u have the source code for abc.class.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1136
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1137 NOTE:- I have written the script so as to open the class file read only,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1138 So that u dont accidently modify it. U can also exted this script to unjar
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1139 a jar file and then view each file in the JAR file. thanks bhaskar Any
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1140 suggestions are welcome
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1141
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1142 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1143 <html><center>previous buffer</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1144 HREF="http://vim.sf.net/tip_view.php?tip_id=55">http://vim.sf.net/tip_view.php?tip_id=55</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1145
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1146 One of the keys to vim is buffer management. If I have to use another IDE
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1147 that makes me click on a tab every time I want to look at another file I'm
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1148 going to go postal.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1149
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1150 So of course you know about :ls which lists all the current open buffers. This
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1151 gets a little unweildly once you have a full project open so you can also use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1152 :b &lt;any snipit of text&gt; &lt;tab&gt; to complete to an open buffer. This
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1153 is really nice because you can type any fragment of a file name and it will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1154 complete to the matching file. (i.e. RequestManager.java can be completed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1155 using "tma"&lt;tab&gt; or "req"&lt;tab&gt; or "r.java"&lt;tab&gt;).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1156
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1157 Now for awhile I was also using :bn and :bp which jumps you to the next
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1158 and previous buffer respectively. I found I was often frustrated because I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1159 wanted :bp to be the previous buffer I was in, not the previous buffer in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1160 the list. So (drum roll) the reason I wrote this tip was because of:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1161
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1162 :b#
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1163
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1164 jump to the previous buffer you were in. Very very handy. The only thing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1165 nicer are tag, but that's a tip for another time.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1166
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1167 :help buffers :help bn :help bp
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1168
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1169 If anybody knows where to get help on # in this context please add notes.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1170
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1171 </pre></tip> </html> <Tip category="KVim"> <html><center>how
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1172 to avoid obliterating window layout</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1173 HREF="http://vim.sf.net/tip_view.php?tip_id=58">http://vim.sf.net/tip_view.php?tip_id=58</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1174
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1175 If you take the time to lay out several windows with vim (especially vertically
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1176 in version 6), you may be bummed when you hit an errant key and find that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1177 all but what one window disappears.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1178
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1179 What happens: while navigating between windows, you hit &lt;C-W&gt;j,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1180 &lt;C-W&gt;k, etc. At some point you accidently hit &lt;C-W&gt; but then
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1181 don't follow with a window command. Now hitting 'o' to start insert mode
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1182 issues a command equivalent to :only, and closes all windows execept for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1183 the one you are in (unless some windows have unsaved changes in them).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1184
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1185 How to avoid this: petition the vim-dev mailing list about how :only is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1186 sufficient for the infrequenty use this might get (j/k).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1187
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1188 Really: use mapping to disable the &lt;C-W&gt;o functionality; put this in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1189 your .vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1190
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1191 nnoremap &lt;C-W&gt;O :echo "sucker"&lt;CR&gt; nnoremap &lt;C-W&gt;o :echo
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1192 "sucker"&lt;CR&gt; nnoremap &lt;C-W&gt;&lt;C-O&gt; :echo "sucker"&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1193
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1194 references:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1195
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1196 :help :only :help CTRL-W_o
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1197
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1198 That is all. Scott
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1199
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1200 </pre></tip> </html> <Tip category="KVim"> <html><center>Applying
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1201 substitutes to a visual block</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1202 HREF="http://vim.sf.net/tip_view.php?tip_id=62">http://vim.sf.net/tip_view.php?tip_id=62</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1203
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1204 If you'd like to apply a substitute, or even any ex command, to a visual-block
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1205 selected text region (ctrl-v and move), then you'll want Stefan Roemer's <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1206 HREF="http://www.erols.com/astronaut/vim/vimscript/vis.vim . Just source
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1207 it in,">http://www.erols.com/astronaut/vim/vimscript/vis.vim . Just source
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1208 it in,</A><BR> and then press ":B". On the command line you'll see
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1209
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1210 :'&lt;,'&gt;BCtrl-V
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1211
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1212 Just continue with the substitute or whatever...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1213
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1214 :'&lt;,'&gt;B s/abc/ABC/g
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1215
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1216 and the substitute will be applied to just that block of text!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1217
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1218 Example: Ctrl-V Select..........|......Type ..................just
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1219 the central....|......:B s/abc/ABC/g ..................four
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1220 "abc"s..............| ..................----------------....|...-------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1221 ..................abcabcabcabc............|......abcabcabcabc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1222 ..................abcabcabcabc............|......abcABCABCabc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1223 ..................abcabcabcabc............|......abcABCABCabc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1224 ..................abcabcabcabc............|......abcabcabcabc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1225 (dots inserted to retain tabular format)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1226
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1227 </pre></tip> </html> <Tip category="KVim"> <html><center>Applying
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1228 substitutes to a visual block</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1229 HREF="http://vim.sf.net/tip_view.php?tip_id=63">http://vim.sf.net/tip_view.php?tip_id=63</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1230
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1231 If you'd like to apply a substitute, or even any ex command, to a visual-block
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1232 selected text region (ctrl-v and move), then you'll want Stefan Roemer's <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1233 HREF="http://www.erols.com/astronaut/vim/vimscript/vis.vim . Just source
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1234 it in,">http://www.erols.com/astronaut/vim/vimscript/vis.vim . Just source
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1235 it in,</A><BR> and then press ":B". On the command line you'll see
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1236
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1237 :'&lt;,'&gt;BCtrl-V
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1238
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1239 Just continue with the substitute or whatever...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1240
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1241 :'&lt;,'&gt;B s/abc/ABC/g
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1242
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1243 and the substitute will be applied to just that block of text!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1244
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1245 Example: Ctrl-V Select..........|......Type
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1246 ..................just the central.......|......:B
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1247 s/abc/ABC/g ..................four "abc"s.................|
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1248 ..................---------............|...-------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1249 ..................abcabcabcabc............|......abcabcabcabc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1250 ..................abcabcabcabc............|......abcABCABCabc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1251 ..................abcabcabcabc............|......abcABCABCabc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1252 ..................abcabcabcabc............|......abcabcabcabc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1253 (dots inserted to retain tabular format)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1254
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1255 </pre></tip> </html> <Tip category="KVim"> <html><center>Always set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1256 your working directory to the file you're editing</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1257 HREF="http://vim.sf.net/tip_view.php?tip_id=64">http://vim.sf.net/tip_view.php?tip_id=64</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1258
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1259 Sometimes I think it's helpful if your working directory is always the same
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1260 as the buffer you are editing. You need to put this in your .vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1261
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1262 function! CHANGE_CURR_DIR()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1263 let _dir = expand("%:p:h") exec "cd " . _dir unlet _dir
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1264 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1265
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1266 autocmd BufEnter * call CHANGE_CURR_DIR()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1267
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1268 Doing this will make a "cd" command to your the current buffer each time
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1269 you switch to it. This is actually similar to vimtip#2 but more automatic.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1270
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1271 You should see for more details: :help autocmd :help expand :help function
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1272
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1273 Note: This tip was contributed by somebody on the list a while ago (sorry
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1274 for no reference) and it has been extremely helpful to me. Thanks!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1275
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1276 </pre></tip> </html> <Tip category="KVim"> <html><center>Insert
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1277 line number into the actuall text of the file.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1278 HREF="http://vim.sf.net/tip_view.php?tip_id=65">http://vim.sf.net/tip_view.php?tip_id=65</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1279
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1280 Although :set number will add nice line number for you At time you may wish
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1281 to actually place the line numbers into the file. For example on GNU Unix
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1282 you can acomplish a simular task using cat -n file &gt; new_file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1283
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1284 In VIM you can use the global command to do this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1285
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1286 :g/^/exec "s/^/".strpart(line(".")." ", 0, 4)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1287
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1288 What this does is run the exec comand on every line that matches /^/ (All)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1289 The exec command taks a string and executes it as if it were typed in.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1290
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1291 line(".")." " -&gt; returns the number of the current line plus four spaces.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1292 strpart("123 ", 0, 4) -&gt; returns only the first four characters ("123 ").
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1293 "s/^/123 " -&gt; substituts the begining of the line with "123 ".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1294
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1295 </pre></tip> </html> <Tip category="KVim"> <html><center>Transfer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1296 text between two Vim 'sessions',</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1297 HREF="http://vim.sf.net/tip_view.php?tip_id=66">http://vim.sf.net/tip_view.php?tip_id=66</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1298
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1299 This one is a one of my favorites from Dr. Chip, and I haven't seen it come
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1300 across vim tips yet...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1301
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1302 Can use either visual, or marking to denote the text.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1303
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1304 " transfer/read and write one block of text between vim sessions " Usage: "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1305 `from' session: " ma " move to end-of-block " xw " " `to' session:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1306 " move to where I want block inserted " xr " if has("unix")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1307 nmap xr :r $HOME/.vimxfer&lt;CR&gt; nmap xw
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1308 :'a,.w! $HOME/.vimxfer&lt;CR&gt; vmap xr c&lt;esc&gt;:r
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1309 $HOME/.vimxfer&lt;CR&gt; vmap xw :w! $HOME/.vimxfer&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1310 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1311 nmap xr :r c:/.vimxfer&lt;CR&gt; nmap xw :'a,.w! c:/.vimxfer&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1312 vmap xr c&lt;esc&gt;:r c:/.vimxfer&lt;cr&gt; vmap xw
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1313 :w! c:/.vimxfer&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1314 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1315
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1316 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1317 <html><center>Ascii Value</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1318 HREF="http://vim.sf.net/tip_view.php?tip_id=67">http://vim.sf.net/tip_view.php?tip_id=67</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1319
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1320 Sometimes we, the programmers, need the value of a character, don't we?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1321 You can learn the ascii value of a character by pressing g and a keys.(ga)!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1322 It displays the value in dec, hex and octal...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1323
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1324 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1325 <html><center>Delete key</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1326 HREF="http://vim.sf.net/tip_view.php?tip_id=68">http://vim.sf.net/tip_view.php?tip_id=68</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1327
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1328 Don't worry if your delete key does not work properly. Just press
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1329 &lt;CTRL&gt;-Backspace. It works under both mode(insert or normal).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1330
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1331 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1332 <html><center>dot makes life easier</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1333 HREF="http://vim.sf.net/tip_view.php?tip_id=69">http://vim.sf.net/tip_view.php?tip_id=69</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1334
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1335 You can copy and paste the last changes you made in the last insert mode
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1336 without using y and p by pressing . (just dot). Vim memorizes the keys you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1337 pressed and echos them if you hit the dot key. You must be in command mode
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1338 as usual. It can be helpful...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1339
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1340 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1341 <html><center>running a command on all buffers</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1342 HREF="http://vim.sf.net/tip_view.php?tip_id=70">http://vim.sf.net/tip_view.php?tip_id=70</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1343
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1344 From Peter Bismuti on the vim list:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1345
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1346 How to global search and replace in all buffers with one command? You need
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1347 the AllBuffers command:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1348
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1349 :call AllBuffers("%s/string1/string2/g")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1350
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1351 "put this in a file and source it function AllBuffers(cmnd)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1352 let cmnd = a:cmnd let i = 1 while (i &lt;= bufnr("$"))
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1353 if bufexists(i)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1354 execute "buffer" i execute cmnd
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1355 endif let i = i+1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1356 endwhile
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1357 endfun
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1358
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1359 ":call AllBuffers("%s/foo/bar/ge|update")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1360
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1361 Thanks Peter!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1362
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1363 </pre></tip> </html> <Tip category="KVim"> <html><center>Transfer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1364 text between two gvim sessions using clipboard</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1365 HREF="http://vim.sf.net/tip_view.php?tip_id=71">http://vim.sf.net/tip_view.php?tip_id=71</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1366
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1367 If you use gvim, you can transfer text from one instance of gvim into another
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1368 one using clipboard. It is convenient to use * (star) register, like this:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1369
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1370 In one instance yank two lines into clipboard:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1371 "*2yy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1372 Paste it in another instance in normal mode:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1373 "*p
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1374 or in insert mode:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1375 &lt;Ctrl-R&gt;*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1376
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1377 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1378 <html><center>Remove unwanted empty lines</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1379 HREF="http://vim.sf.net/tip_view.php?tip_id=72">http://vim.sf.net/tip_view.php?tip_id=72</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1380
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1381 Sometimes to improve the readability of the document I insert empty lines,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1382 which will be later removed. To get rid off them try: :%g/^$/d This will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1383 remove a l l empty line in the document. Some other tipps you can find
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1384 under www.linuxclass.de/vim.phtml
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1385
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1386 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1387 <html><center>Using vim as calculator</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1388 HREF="http://vim.sf.net/tip_view.php?tip_id=73">http://vim.sf.net/tip_view.php?tip_id=73</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1389
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1390 Basic calculations can done within vim easily by typing (insert-mode): STRG
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1391 (=CTRL) + R followed by = then for example 2+2 and hit RETURN the result 4
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1392 will be printed in the document.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1393
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1394 Some other tipps you can find under www.linuxclass.de/vim.phtml
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1395
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1396 </pre></tip> </html> <Tip category="KVim"> <html><center>Using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1397 Vim as an outline processor</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1398 HREF="http://vim.sf.net/tip_view.php?tip_id=74">http://vim.sf.net/tip_view.php?tip_id=74</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1399
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1400 With the addition of folding, Vim6 can function as a high performance outline
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1401 processor. Simply :set ai and in insert mode use backspace to promote and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1402 tab to demote headlines.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1403
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1404 In command mode, &lt;&lt; promotes (n&lt;&lt; to promote multiple lines),
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1405 and &gt;&gt; demotes. Also, highlight several headlines and &lt; or &gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1406 to promote or demote.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1407
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1408 :set foldmethod=indent, and then your z commands can expand or collapse
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1409 headline trees, filewide or by the tree.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1410
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1411 The VimOutliner GPL distro contains the scripts and configs to easily
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1412 configure Vim6 as an outliner, including scripts to create tag files enabling
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1413 interoutline hyperlinking.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1414
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1415 The VimOutliner project is at <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1416 HREF="http://www.troubleshooters.com/projects/vimoutliner/index.htm.">http://www.troubleshooters.com/projects/vimoutliner/index.htm.</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1417
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1418 Steve (Litt) slitt@troubleshooters.com
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1419
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1420 </pre></tip> </html> <Tip category="KVim"> <html><center>Remap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1421 CAPSLOCK key in Windows 2000 Professional and NT4.0</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1422 HREF="http://vim.sf.net/tip_view.php?tip_id=75">http://vim.sf.net/tip_view.php?tip_id=75</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1423
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1424 If you're Windows 2000 Professional user and got tired to move your hands off
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1425 basic row when hitting &lt;ESC&gt; key here the solution (not for Windows 9x.):
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1426 remap CapsLock key as &lt;ESC&gt; key. It's located in useful position. Put
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1427 this lines into &lt;EscLock.reg&gt; file and start it in explorer.Reboot.Enjoy.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1428
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1429 REGEDIT4 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1430 "Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1431
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1432 To restore you capslock back just delete this entry from Registry and reboot.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1433 And below is remapping &lt;capslock&gt; as &lt;Left Control&gt;:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1434
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1435 REGEDIT4 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1436 "Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1437
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1438 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1439 <html><center>Folding for Quickfix</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1440 HREF="http://vim.sf.net/tip_view.php?tip_id=76">http://vim.sf.net/tip_view.php?tip_id=76</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1441
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1442 The Quickfix mode aims to "speed up the edit-compile-edit cycle" according to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1443 ':help quickfix'. After executing ':make' or ':grep' it is possible to skim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1444 through the list of errors/matches and the appropriate source code locations
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1445 with, for instance, the ':cnext' command. Another way to get a quick overview
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1446 is to use VIMs folding mode, to fold away all the error-free/match-free
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1447 regions. The script at the end of this message can be used for this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1448 purpose. It is at the moment not elaborate enough to put it up as a 'script';
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1449 but it might give someone inspiration to do so. Big restrictions / bugs are
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1450 as follows: 1. Vim Perl interface is required, i.e. the output of ':version'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1451 must contain '+perl' (People with Vim scripting knowledge might fix this)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1452 2. Works only for one file, i.e. the current buffer. 3. It's a quick hack.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1453 Sample usage: (a) edit a file, (b) do ':grep regexp %' to get a quickfix
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1454 error list and (c) ':source foldqf.vim' will fold as described Increasing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1455 the value of $CONTEXT gives you more context around the error regions.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1456
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1457 Here comes it, it should be 7 lines: ---foldqf.vim cwindow perl $CONTEXT = 0;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1458 perl @A = map { m/\|(\d+)\|/; $1 +0 } $curbuf-&gt;Get(1..$curbuf-&gt;Count());
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1459 close normal zD perl sub fold { VIM::DoCommand( $_[0] . ',' . ($_[1]) . "fold"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1460 ) if( $_[0] &lt; $_[1] ); } perl $last = 0; for (@A) { fold( $last+1+$CONTEXT,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1461 $_-1-$CONTEXT ); $last = $_; }; VIM::DoCommand(($A[-1]+1+$CONTEXT )
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1462 . ',$fold' );
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1463
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1464 </pre></tip> </html> <Tip category="KVim"> <html><center>Displaying
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1465 search results using folds</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1466 HREF="http://vim.sf.net/tip_view.php?tip_id=77">http://vim.sf.net/tip_view.php?tip_id=77</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1467
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1468 A guy I work with told me about a function that an old IBM text editor had
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1469 that he said was useful, and that is to create folds in the file after a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1470 search such that every line that is visible contains the search pattern(except
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1471 possibly the first). All lines that do not contain the search pattern are
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1472 folded up to the last occurence of the pattern or the top of the file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1473
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1474 One use for such a function is to be able to make a quick and dirty api of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1475 a source file. For example, if working in Java, you could run the function
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1476 using the pattern "public|protected|private" and ithe results would be that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1477 only the method headers would be visible (well, close enough).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1478
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1479 function! Foldsearch(search)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1480 normal zE "erase all folds to begin with normal G$
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1481 "move to the end of the file let folded = 0 "flag to set when
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1482 a fold is found let flags = "w" "allow wrapping in the search let
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1483 line1 = 0 "set marker for beginning of fold while search(a:search,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1484 flags) &gt; 0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1485 let line2 = line(".") "echo "pattern found at line #
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1486 " line2 if (line2 -1 &gt; line1)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1487 "echo line1 . ":" . (line2-1) "echo "A fold goes here."
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1488 execute ":" . line1 . "," . (line2-1) . "fold"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1489 let folded = 1 "at
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1490 least one fold has been found
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1491 endif let line1 = line2 "update marker let flags = "W"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1492 "turn off wrapping
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1493 endwhile
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1494 " Now create the last fold which goes to the end of the file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1495 normal $G let line2 = line(".")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1496 "echo "end of file found at line # " line2
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1497 if (line2 &gt; line1 && folded == 1)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1498 "echo line1 . ":" . line2 "echo "A fold goes here."
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1499 execute ":". line1 . "," . line2 . "fold"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1500 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1501 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1502
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1503 " Command is executed as ':Fs pattern'" command! -nargs=+ -complete=command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1504 Fs call Foldsearch(&lt;q-args&gt;) " View the methods and variables in a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1505 java source file." command! Japi Fs public\|protected\|private
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1506
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1507 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1508 <html><center>rotating mail signatures</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1509 HREF="http://vim.sf.net/tip_view.php?tip_id=78">http://vim.sf.net/tip_view.php?tip_id=78</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1510
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1511 For people using mutt and vim for mail, the following script will allow
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1512 you to insert a new signature (and again and again if you don\'t like the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1513 current one) at the bottom of your mail. This is usefull eg when you don\'t
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1514 want to send a potentially offensive quote to someone you don\'t know very
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1515 well (or a mailing list), but are too lazy to delete the quote, open your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1516 quotes file, and cut and paste another one in. (I put it here in \'tips\'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1517 and not in \'scripts\' because it is imo too short to be a \'real\' script)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1518
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1519 " rotate_sig.vim " Maintainer: Roel Vanhout &lt;roel@2e-systems.com&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1520 " Version: 0.1 " Last Change: Tuesday, June 12, 2001 " Mapping I use:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1521 " nmap ,r :call RotateSig()&lt;CR&gt; " Usage: " -Make sure you delimit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1522 your sig with '-- ', or adjust the script " -Adjust the last execute to a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1523 command that prints a sig to stdout " Known problems: " - You'll get an
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1524 error message when you're below the last " '^-- $' in your mail (nothing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1525 bad though - just an not- " found marker)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1526
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1527 function! RotateSig()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1528 normal mQG execute '?^-- $' execute ':nohl' normal o&lt;ESC&gt; normal
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1529 dG normal &lt;CR&gt; execute 'r !~/bin/autosig ~/.quotes \%' normal `Q
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1530 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1531
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1532 </pre></tip> </html> <Tip category="KVim"> <html><center>How to use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1533 :grep to get a clickable list of function names</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1534 HREF="http://vim.sf.net/tip_view.php?tip_id=79">http://vim.sf.net/tip_view.php?tip_id=79</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1535
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1536 The following function will make a :cwindow window with a line per function
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1537 in the current C source file. NOTE: It writes the file as a side effect.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1538
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1539 Invoke with ':call ShowFunc()' You may want to do :nmap &lt;somekey&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1540 :call ShowFunc()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1541
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1542 function! ShowFunc()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1543
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1544 let gf_s = &grepformat let gp_s = &grepprg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1545
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1546 let &grepformat = '%*\k%*\sfunction%*\s%l%*\s%f %*\s%m' let &grepprg =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1547 'ctags -x --c-types=f --sort=no -o -'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1548
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1549 write silent! grep % cwindow
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1550
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1551 let &grepformat = gf_s let &grepprg = gp_s
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1552
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1553 endfunc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1554
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1555 </pre></tip> </html> <Tip category="KVim"> <html><center>Restore
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1556 cursor to file position in previous editing session</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1557 HREF="http://vim.sf.net/tip_view.php?tip_id=80">http://vim.sf.net/tip_view.php?tip_id=80</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1558
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1559 Here's something for your &lt;.vimrc&gt; which will allow you to restore
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1560 your cursor position in a file over several editing sessions. This technique
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1561 uses the viminfo option:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1562
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1563 Ex. set viminfo='10,\"100,:20,%,n~/.viminfo
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1564 au BufReadPost * if line("'\"") &gt; 0|if line("'\"") &lt;=
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1565 line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1566
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1567 If you're on Unix, the viminfo is probably fine as is (but check up on Vim's
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1568 help for viminfo to see if you like the settings above). For Windows you'll
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1569 need to change the "n" suboption to something like
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1570
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1571 Ex. set viminfo='10,\"100,:20,%,nc:\\some\\place\\under\\Windoz\\_viminfo
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1572
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1573 This tip is a somewhat improved version of the example given for :he line()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1574 in the Vim on-line documentation.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1575
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1576 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1577 <html><center>Substitution of characters and lines in VIM is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1578 made far easier with the s and S commands</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1579 HREF="http://vim.sf.net/tip_view.php?tip_id=81">http://vim.sf.net/tip_view.php?tip_id=81</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1580
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1581 Substitute Characters ----------------------------------- I was just editing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1582 a file that contained the same leading string on many lines.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1583
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1584 example:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1585
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1586 foo_bar_baz1=a foo_bar_baz1=abc674 foo_bar_baz1=qrs foo_bar_baz1=m1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1587 foo_bar_baz1=bz90 foo_bar_baz1=bc ...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1588
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1589 Needing to only substitute a portion of the string, I referred to a VIM
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1590 reference card and discovered a command answering my need exactly. The s
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1591 command is used to subsitute a certain number of characters. In my example
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1592 file above, if I only needed to subsititute the characters foo_bar, I set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1593 the cursor on the first character where I'd like the subsitution to begin
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1594 and type 7s. VIM drops the characters foo_bar and goes to insert mode,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1595 waiting for the substitution text.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1596
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1597 Substitute Lines ----------------------- After years of using vi and VIM and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1598 always deleting multiple lines in order to replace them, I just discovered
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1599 the S command. If you need to subsitute three lines of text, simply type
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1600 3S. VIM drops the three lines and goes into insert mode, waiting for the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1601 subsitution text.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1602
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1603 </pre></tip> </html> <Tip category="KVim"> <html><center>letting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1604 variable values be overwritten in a script</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1605 HREF="http://vim.sf.net/tip_view.php?tip_id=82">http://vim.sf.net/tip_view.php?tip_id=82</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1606
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1607 this is a simple function i wrote to get the value of a variable from three
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1608 different places (in that order): the current buffer, the global setting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1609 or from the script itself.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1610
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1611 this allows me to set a default value for a configuration variable inside my
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1612 script and the user to change it on a global level by setting the same variable
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1613 with a g: prepended. then, they can further set it on a per-buffer level by
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1614 the the b: mechanism. one of the examples for this might be my comments script
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1615 (not uploaded). i have a variable in there that determines whether comment
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1616 characters (// for java, for example) are placed the beginning of the line or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1617 just before the first-non-blanks in the text. i set up a default in my script:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1618
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1619 let s:comments_hug_start_of_line=0 " comments should hug the text
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1620
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1621 that's fine as a default, but if i want to overwrite it for vim scripts,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1622 i just put the following in my ftplugin/vim.vim:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1623
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1624 let b:comments_hug_start_of_line=1 " vim comments should hug the first
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1625 column, always
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1626
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1627 " tries to return the buffer-specific value of a variable; if not
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1628 " found, tries to return the global value -- if that's not found "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1629 either, returns the value set in the script itself function! GetVar(varName)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1630 if (exists ("b:" . a:varName))
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1631 exe "let retVal=b:" . a:varName
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1632 elseif (exists ("g:" . a:varName))
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1633 exe "let retVal=g:" . a:varName
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1634 elseif (exists ("s:" . a:varName))
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1635 exe "let retVal=s:" . a:varName
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1636 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1637 retVal=-1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1638 endif return retVal
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1639 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1640
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1641 personally, i never let it get to the -1 state by always having an s: set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1642 with SOME default value.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1643
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1644 </pre></tip> </html> <Tip category="KVim"> <html><center>how
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1645 to indent (useful for source code)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1646 HREF="http://vim.sf.net/tip_view.php?tip_id=83">http://vim.sf.net/tip_view.php?tip_id=83</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1647
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1648 Here is the most useful vim command that I know of and I'm surprised that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1649 it's not yet in the tips list.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1650
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1651 I use the indent features of vim all the time. Basically, it lets you indent
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1652 your source code.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1653
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1654 SETUP: To make indentation work nicely I have the following in my .vimrc file:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1655 set et set sw=4 set smarttab
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1656
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1657 these make vim behave nicely when indenting, giving 4 spaces (not tabs)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1658 for each "tabstop".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1659
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1660 HOW TO USE: in command mode, == will indent the current line selecting a range
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1661 of lines (with shift-v) then == will indent your selection typing a number
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1662 then == will indent that many lines, starting from your cursor (you get the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1663 idea, there are many other things you can do to select a range of lines)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1664
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1665 Tell me that isn't great?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1666
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1667 </pre></tip> </html> <Tip category="KVim"> <html><center>Changing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1668 the behaviour of . to include visual mode</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1669 HREF="http://vim.sf.net/tip_view.php?tip_id=84">http://vim.sf.net/tip_view.php?tip_id=84</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1670
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1671 one of the things i do a lot in vim is to make a change to the beginning or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1672 end of the line (such as adding the text '// remove' at the end of java
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1673 debug code). a quick way of doing this is to use a to append the text to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1674 the end of the first line and then move down one, hit . (repeat last edit),
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1675 move down, hit . etc. etc. the following mapping allows one to simply
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1676 highlight the region in question and hit . -- it will automatically
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1677 execute the . once on each line:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1678
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1679 " allow the . to execute once for each line of a visual selection vnoremap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1680 . :normal .&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1681
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1682 another thing i do a lot is to record a quick macro in the "a" register
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1683 and then play it back a number of times. while @@ can be used to repeat the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1684 last register used, my recorded macros sometimes use other registers so @@
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1685 doesn't necessarily give me the same results as @a. also, i have mapped '
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1686 to ` because i like to go to the precise location of my marks -- always --
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1687 and never to the beginning of the line. this leaves my ` key unused. so:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1688
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1689 " make ` execute the contents of the a register nnoremap ` @a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1690
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1691 then, in keeping with the visual . above, i did the same for the ` -- is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1692 thexecutes @a once on each highlighed line.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1693
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1694 vnoremap ` :normal @a&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1695
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1696 as an example, say i have the following lines of java code:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1697
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1698 public String m_asdf; public String m_lkhj; public int m_hjkhjkh;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1699
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1700 and, for some reason, i need to get the following:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1701
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1702 "asdf" "lkhj" "hjkhjkh"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1703
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1704 i record the following into a:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1705
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1706 ^cf_"&lt;ESC&gt;$r"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1707
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1708 the ^ is because my java code is indented and i don't want to go to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1709 column 0 and the &lt;esc&gt; is an actual escape i hit to exit insert mode.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1710
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1711 then, i simply select (visually) the other lines (only two in case --
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1712 admittedly not an overly useful example) and just hit `.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1713
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1714 </pre></tip> </html> <Tip category="KVim"> <html><center>How to mimic
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1715 the vim 6.0 plugin feature with older versions</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1716 HREF="http://vim.sf.net/tip_view.php?tip_id=85">http://vim.sf.net/tip_view.php?tip_id=85</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1717
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1718 If you do not have vim 6.0, but would like to mimic the plugins directory
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1719 feature then copy and paste this into your vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1720
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1721 exec "source " . substitute(glob($VIM."/plugins/*.vim"), "\n", "\nsource ",
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1722 "g")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1723
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1724 It will automatically source every vim script file located in the vim/plugins
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1725 directory. Now, to add a new plugin, just drop the script in this directory
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1726 and vim will automatically find it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1727
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1728 </pre></tip> </html> <Tip category="KVim"> <html><center>Helps
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1729 undo 1 line when entered many</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1730 HREF="http://vim.sf.net/tip_view.php?tip_id=86">http://vim.sf.net/tip_view.php?tip_id=86</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1731
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1732 When U entered text, U cannot undo only 1 line, for example, when U press
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1733 "u", all entered in last "insert" text removed.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1734
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1735 If U add this line to .vimrc: inoremap &lt;Return&gt; &lt;Return&gt;^O^[
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1736 where "^O" or "^[" is 1 char "u" will undo (remove) only 1 line.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1737
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1738 </pre></tip> </html> <Tip category="KVim"> <html><center>Get
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1739 vim 5.x window in vim 6.x</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1740 HREF="http://vim.sf.net/tip_view.php?tip_id=87">http://vim.sf.net/tip_view.php?tip_id=87</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1741
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1742 The format of the window title in vim 5.x (well, at least for 5.7,.8, for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1743 Win32) used to be VIM - &lt;full filename with path&gt;. It's not in the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1744 win32 binary of 6.0an that I found. I want my old way back.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1745
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1746 Turns out, all that it takes to get it back is :set title titlestring=VIM\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1747 -\ %F "make sure that the window caption setting is turned on and set caption
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1748 to vim 5.x style
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1749
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1750 Oh, however, one thing I did like about the 6.0 style is that it puts the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1751 word "help" in the title when the current buffer is a help file; so, I just
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1752 tacked %h to my titlestring giving:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1753
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1754 :set title titlestring=VIM\ -\ %F\ %h "make sure that the window caption
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1755 setting is turned on and set caption to vim 5.x style
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1756
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1757 see also: :he 'titlestring' :he 'statusline' "for the format for titlestring
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1758
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1759 </pre></tip> </html> <Tip category="KVim"> <html><center>How
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1760 to maximize vim on entry (win32)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1761 HREF="http://vim.sf.net/tip_view.php?tip_id=88">http://vim.sf.net/tip_view.php?tip_id=88</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1762
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1763 Maybe it's just because I have far too small of a monitor, because I can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1764 get distracted while coding if I have other stuff on the screen, or because I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1765 starting using vim on a console, but I definitely like my vim window maximized.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1766 Anyway, sticking the following in your vimrc will always maximize your vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1767 window on startup.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1768
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1769 au GUIEnter * simalt ~x
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1770
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1771 :he win16-maximized
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1772
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1773 </pre></tip> </html> <Tip category="KVim"> <html><center>Get more
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1774 screen real estate by hidding toolbar and/or menus</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1775 HREF="http://vim.sf.net/tip_view.php?tip_id=89">http://vim.sf.net/tip_view.php?tip_id=89</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1776
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1777 I use gvim over console vim because gvim is much more readable (under Windows).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1778 However, that doesn't mean I want to dedicate screen space to things I'll
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1779 never use (i.e. the toolbar and the menus).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1780
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1781 Anyway, you can give the following a try if you'd like.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1782
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1783 set guioptions-=T "get rid of toolbar set guioptions-=m "get rid of menu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1784
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1785 Oh, yeah. If you decide that you don't really like being without your the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1786 toolbar or menus, issue the following:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1787
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1788 set guioptions+=T "bring back toolbar set guioptions+=m "bring back menu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1789
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1790 see also: :he 'guioptions
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1791
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1792 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1793 <html><center>Encryption</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1794 HREF="http://vim.sf.net/tip_view.php?tip_id=90">http://vim.sf.net/tip_view.php?tip_id=90</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1795
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1796 You can encrypt your texts by using vim. :X prompts for an encryption key.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1797 After writing your key, if you save your document it will be encrypted
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1798 and no one else (but you and vim) can read your documents. If you reopen
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1799 the file, VIM will ask for the key. If you want to disable encryption,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1800 just type :set key= if you forget your key you will lose your document.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1801 So please DO NOT forget your key,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1802
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1803
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1804 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1805 <html><center>Dictionary completions</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1806 HREF="http://vim.sf.net/tip_view.php?tip_id=91">http://vim.sf.net/tip_view.php?tip_id=91</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1807
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1808 This tip will will explain how to use the dictionary completion facilities
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1809 provided by vim. This can be useful if you use vim to type your email,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1810 edit code, etc.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1811
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1812 Dictionary completion is one of many search facilites provided by Insert mode
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1813 completion. It allows the user to get a list of keywords, based off of the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1814 current word at the cursor. This is useful if you are typing a long word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1815 (e.g. acknowledgeable) and don't want to finish typing or don't remember
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1816 the spelling.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1817
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1818 To start, we must first tell vim where our dictionary is located. This is done
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1819 via the 'dictionary' option. Below is an example. Your location may vary.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1820 See :help 'dictionary' for hints as to where you should look.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1821
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1822 :set dictionary-=/usr/share/dict/words
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1823 dictionary+=/usr/share/dict/words
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1824
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1825 Now, to use this list we have to enter insert mode completion. This is done
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1826 by hitting CTRL-X while in insert mode. Next, you have to specify what you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1827 want to complete. For dictionaries use CTRL-K. Once in this mode the keys
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1828 CTRL-N and CTRL-P will cycle through the matches. So, to complete the word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1829 "acknowledgeable" I would do the following in insert mode:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1830
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1831 acknow&lt;CTRL-X&gt;&lt;CTRL-K&gt;&lt;CTRL-N&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1832
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1833 It can be cumbersome to type CTRL-X CTRL-K for many different completions.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1834 So, vim gives us a shortcut. While in insert mode CTRL-N and CTRL-P
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1835 will cycle through a predetermined set of completion sources. By default,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1836 dictionary completion is not a part of this set. This set is defined by the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1837 'complete' option. Therefore, we must add dictionary to this as shown below:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1838
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1839 :set complete-=k complete+=k
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1840
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1841 Now, while in insert mode we can type the following to complete our example:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1842
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1843 acknow&lt;CTRL-N&gt;&lt;CTRL-N&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1844
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1845 This shortcut may not save a whole lot of typing. However, I find that it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1846 requires less hand movement to only worry myself with two key combinations,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1847 rather than 4.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1848
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1849 I find that the completion facilites provided by vim save me a *HUGE* amount
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1850 of typing. These savings can be realized in only a short amount of time if
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1851 you are editing some code with functions and variables that have long names
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1852 with underscores in them.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1853
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1854 For more help:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1855 help ins-completion help compl-dictionary help 'complete' help
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1856 'dictionary' help :set+=
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1857
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1858 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1859 <html><center>Reducing 'doc' directory size</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1860 HREF="http://vim.sf.net/tip_view.php?tip_id=92">http://vim.sf.net/tip_view.php?tip_id=92</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1861
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1862 As everyone knows, the $VIMRUNTIME/doc is increasing rapidly in size. The
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1863 directory contained so many plain-text documents that I often compress
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1864 them to save my diskspace. With the support of VIM's GZIP plugin,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1865 VIM will automatically uncompress the files when we need to read them.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1866 Here is my procedure: 1. If you have the source, go to 'runtime/doc'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1867 and edit 'doctags.c', change printf("%s\t%s\t/*", p1, argv[0]); to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1868 printf("%s\t%s.gz\t/*", p1, argv[0]);
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1869 then make. This is to modify the tag, or you'll have to change the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1870 'tags' file by hand if you don't have doctags.c.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1871 2. Edit the new generated 'tags' file to rename 'help.txt.gz' back to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1872 'help.txt' because it's hard-written in VIM executable binary.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1873 :% s/help\.txt\.gz/help\.txt/g
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1874 3. Copy the new 'tags' to $VIMRNUTIME/doc and run 'gzip *.txt; gunzip help.txt'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1875
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1876 On VIM 6.0an, we can reduce the original size (3302k) to 1326k. I don't
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1877 know if this helps, but if someone likes to compress documents... this can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1878 be reffered :)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1879
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1880
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1881 </pre></tip> </html> <Tip category="KVim"> <html><center>if you use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1882 'highlight search' feature, map a key to :noh</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1883 HREF="http://vim.sf.net/tip_view.php?tip_id=93">http://vim.sf.net/tip_view.php?tip_id=93</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1884
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1885 It is very convenient to use 'hlsearch' option. However it can be annoying
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1886 to have the highlight stick longer than you want it. In order to run it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1887 off you have to type at least 4 keystrokes, ":noh". So, it's a good idea
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1888 to map this to a key. I like to map it to control-n. This is the line I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1889 use in my .vimrc file to do it:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1890
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1891 nmap &lt;silent&gt; &lt;C-N&gt; :silent noh&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1892
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1893 </pre></tip> </html> <Tip category="KVim"> <html><center>Questions
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1894 & Answers about using tags with Vim</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1895 HREF="http://vim.sf.net/tip_view.php?tip_id=94">http://vim.sf.net/tip_view.php?tip_id=94</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1896
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1897 Using tags file with Vim ------------------------ This document gives you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1898 a idea about the various facilities available in Vim for using a tags file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1899 to browse through program source files. You can read the Vim online help,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1900 which explains in detail the tags support, using :help tagsearch.txt. You can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1901 also use the help keywords mentioned in this document to read more about a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1902 particular command or option. To read more about a particular command or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1903 option use, :help &lt;helpkeyword&gt; in Vim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1904
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1905 1. How do I create a tags file?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1906
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1907 You can create a tags file either using the ctags utility or using a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1908 custom script or utility.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1909
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1910 Help keyword(s): tag
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1911
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1912 2. Where can I download the tools to generate the tags file?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1913
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1914 There are several utilities available to generate the tags file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1915 Depending on the programming language, you can use any one of them.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1916
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1917 1. Exuberant ctags generates tags for the following programming
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1918 language files:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1919
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1920 Assembler, AWK, ASP, BETA, Bourne/Korn/Zsh Shell, C, C++, COBOL,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1921 Eiffel, Fortran, Java, Lisp, Make, Pascal, Perl, PHP, Python, REXX,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1922 Ruby, S-Lang, Scheme, Tcl, and Vim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1923
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1924 You can download exuberant ctags from <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1925 HREF="http://ctags.sourceforge.net/">http://ctags.sourceforge.net/</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1926
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1927 2. On Unix, you can use the /usr/bin/ctags utility. This utility
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1928 is present in most of the Unix installations.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1929
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1930 3. You can use jtags for generating tags file for java programs.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1931 You can download jtags from: <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1932 HREF="http://www.fleiner.com/jtags/">http://www.fleiner.com/jtags/</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1933
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1934 4. You can use ptags for generating tags file for perl programs.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1935 You can download ptags from: <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1936 HREF="http://www.eleves.ens.fr:8080/home/nthiery/Tags/">http://www.eleves.ens.fr:8080/home/nthiery/Tags/</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1937
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1938 5. You can download scripts from the following links for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1939 generating tags file for verilog files:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1940
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1941 <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1942 HREF="http://www.probo.com/vtags.htm">http://www.probo.com/vtags.htm</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1943 <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1944 HREF="http://www.cs.albany.edu/~mosh/Perl/veri-tags">http://www.cs.albany.edu/~mosh/Perl/veri-tags</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1945 <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1946 HREF="http://www.verilog.net/vrtags.txt">http://www.verilog.net/vrtags.txt</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1947
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1948 6. You can download Hdrtag from the following linke:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1949
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1950 <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1951 HREF="http://www.erols.com/astronaut/vim/index.html#Tags">http://www.erols.com/astronaut/vim/index.html#Tags</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1952
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1953 This utility generates tags file for the following programming languages:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1954 assembly, c/c++, header files, lex, yacc,LaTeX, vim, and Maple V.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1955
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1956 7. You can also use the following scripts which are part of the Vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1957 runtime files:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1958
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1959 pltags.pl - Create tags file for perl code tcltags - Create tags
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1960 file for TCL code shtags.pl - Create tags file for shell script
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1961
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1962 Help keyword(s): ctags
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1963
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1964 3. How do I generate a tags file using ctags?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1965
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1966 You can generate a tags file for all the C files in the current directory
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1967 using the following command:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1968
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1969 $ ctags *.c
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1970
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1971 You can generate tags file for all the files in the current directory
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1972 and all the sub-directories using (this applies only to exuberant ctags):
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1973
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1974 $ ctags -R .
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1975
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1976 You can generate tags file for all the files listed in a text file named
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1977 flist using (this applies only to exuberant ctags)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1978
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1979 $ ctags -L flist
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1980
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1981 4. How do I configure Vim to locate a tags file?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1982
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1983 You can set the 'tags' option in Vim to specify a particular tags file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1984
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1985 set tags=/my/dir/tags
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1986
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1987 Help keyword(s): 'tags', tags-option
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1988
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1989 5. How do I configure Vim to use multiple tags files?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1990
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1991 The 'tags' option can specify more than one tags file. The tag filenames
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1992 are separated using either comma or spaces.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1993
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1994 set tags=/my/dir1/tags, /my/dir2/tags
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1995
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1996 6. How do I configure Vim to locate a tags file in a directory tree?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1997
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1998 Note that the following will work only in Vim 6.0 and above. You can set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1999 the 'tags' option to make Vim search for the tags file in a directory tree.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2000 For example, if the 'tags' option is set like this:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2001
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2002 set tags=tags;/
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2003
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2004 Vim will search for the file named 'tags', starting with the current
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2005 directory and then going to the parent directory and then recursively to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2006 the directory one level above, till it either locates the 'tags' file or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2007 reaches the root '/' directory.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2008
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2009 Help keyword(s): file-searching
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2010
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2011 7. How do I jump to a tag?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2012
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2013 There are several ways to jump to a tag location.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2014 1. You can use the 'tag' ex command. For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2015
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2016 :tag &lt;tagname&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2017
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2018 will jump to the tag named &lt;tagname&gt;.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2019 2. You can position the cursor over a tag name and then press
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2020 Ctrl-].
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2021 3. You can visually select a text and then press Ctrl-] to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2022 jump to the tag matching the selected text.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2023 4. You can click on the tag name using the left mouse button,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2024 while pressing the &lt;Ctrl&gt; key.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2025 5. You can press the g key and then click on the tag name
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2026 using the left mouse button.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2027 6. You can use the 'stag' ex command, to open the tag in a new
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2028 window. For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2029
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2030 :stag func1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2031
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2032 will open the func1 definition in a new window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2033 7. You can position the cursor over a tag name and then press
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2034 Ctrl-W ]. This will open the tag location in a new window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2035
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2036 Help keyword(s): :tag, Ctrl-], v_CTRL_], &lt;C-LeftMouse&gt;,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2037 g&lt;LeftMouse&gt;, :stag, Ctrl-W_]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2038
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2039 8. How do I come back from a tag jump?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2040
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2041 There are several ways to come back to the old location from a tag jump.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2042 1. You can use the 'pop' ex command. 2. You can press Ctrl-t.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2043 3. You can click the right mouse button, while pressing the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2044 &lt;Ctrl&gt; key.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2045 4. You can press the g key and then click the right mouse
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2046 button.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2047
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2048 Help keyword(s): :pop, Ctrl-T, &lt;C-RightMouse&gt;, g&lt;RightMouse&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2049
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2050 9. How do I jump again to a previously jumped tag location?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2051
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2052 You can use the 'tag' ex command to jump to a previously jumped tag
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2053 location, which is stored in the tag stack.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2054
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2055 Help keyword(s): tag
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2056
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2057 10. How do I list the contents of the tag stack?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2058
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2059 Vim remembers the location from which you jumped to a tag in the tag stack.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2060 You can list the current tag stack using the 'tags' ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2061
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2062 Help keyword(s): :tags, tagstack
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2063
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2064 11. How do I jump to a particular tag match, if there are multiple
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2065 matching tags?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2066
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2067 In some situations, there can be more than one match for a tag.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2068 For example, a C function or definition may be present in more than one
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2069 file in a source tree. There are several ways to jump to a specific
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2070 tag from a list of matching tags.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2071
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2072 1. You can use the 'tselect' ex command to list all the tag
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2073 matches. For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2074
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2075 :tselect func1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2076
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2077 will list all the locations where func1 is defined. You can then
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2078 enter the number of a tag match to jump to that location.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2079 2. You can position the cursor over the tag name and press g]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2080 to get a list of matching tags.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2081 3. You can visually select a text and press g] to get a list
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2082 of matching tags.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2083 4. You can use the 'stselect' ex command. This will open the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2084 selected tag from the tag list in a new window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2085 5. You can position the cursor over the tag name and press
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2086 Ctrl-W g] to do a :stselect.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2087
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2088 Help keyword(s): tag-matchlist, :tselect, g], v_g], :stselect,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2089 Ctrl-W_g]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2090
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2091 12. I want to jump to a tag, if there is only one matching tag,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2092 otherwise a list of matching tags should be displayed. How do I do this?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2093
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2094 There are several ways to make Vim to jump to a tag directly, if there
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2095 is only one tag match, otherwise present a list of tag matches.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2096
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2097 1. You can use the 'tjump' ex command. For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2098
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2099 :tjump func1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2100
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2101 will jump to the definition func1, if it is defined only once.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2102 If func1 is defined multiple times, a list of matching tags will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2103 be presented.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2104 2. You can position the cursor over the tag and press g
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2105 Ctrl-].
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2106 3. You can visually select a text and press g Ctrl-] to jump
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2107 or list the matching tags.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2108 4. You can use the 'stjump' ex command. This will open the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2109 matching or selected tag from the tag list in a new window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2110 5. You can press Ctrl-W g Ctrl-] to do a :stjump.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2111
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2112 Help keyword(s): :tjump, g_Ctrl-], v_g_CTRL-], :stjump,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2113 Ctrl-W_g_Ctrl-]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2114
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2115 13. How do browse through a list of multiple tag matches?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2116
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2117 If there are multiple tag matches, you can browse through all of them
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2118 using several of the Vim ex commands.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2119
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2120 1. To go to the first tag in the list, use the 'tfirst' or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2121 'trewind' ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2122 2. To go to the last tag in the list, use the 'tlast' ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2123 3. To go to the next matching tag in the list, use the 'tnext' ex
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2124 command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2125 4. To go to the previous matching tag in the list, use the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2126 'tprevious' or 'tNext' ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2127
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2128 Help keyword(s): :tfirst, :trewind, :tlast, :tnext, :tprevious,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2129 :tNext
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2130
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2131 14. How do I preview a tag?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2132
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2133 You can use the preview window to preview a tag, without leaving the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2134 original window. There are several ways to preview a tag:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2135
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2136 1. You can use the 'ptag' ex command to open a tag in the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2137 preview window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2138 2. You can position the cursor on a tag name and press Ctrl-W
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2139 } to open the tag in the preview window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2140 3. You can use the 'ptselect' ex command to do the equivalent
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2141 of the 'tselect' ex command in the preview window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2142 4. You can use the 'ptjump' ex command to do the equivalent of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2143 the 'tjump' ex command in the preview window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2144 5. You can position the cursor on the tag and press Ctrl-W g}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2145 to do a :ptjump on the tag.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2146
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2147 Help keyword(s): :preview-window, :ptag, Ctrl-W_}, :ptselect,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2148 :ptjump, Ctrl-W_g}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2149
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2150 15. How do I browse through the tag list in a preview window?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2151
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2152 If there are multiple tag matches, you can browse through all of them
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2153 in the preview window using several of the Vim ex commands.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2154
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2155 1. To go to the first tag in the list, use the 'ptfirst' or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2156 'ptrewind' ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2157 2. To go to the last tag in the list, use the 'ptlast' ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2158 3. To go to the next matching tag in the list, use the 'ptnext' ex
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2159 command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2160 4. To go to the previous matching tag in the list, use the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2161 'ptprevious' or 'ptNext' ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2162
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2163 Help keyword(s): :ptfirst, :ptrewind, :ptlast, :ptnext,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2164 :ptprevious, :ptNext
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2165
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2166 16. How do I start Vim to start editing a file at a given tag match?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2167
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2168 While starting Vim, you can use the command line option '-t' to supply
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2169 a tag name. Vim will directly jump to the supplied tag location.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2170
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2171 Help keyword(s): -t
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2172
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2173 17. How do I list all the tags matching a search pattern?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2174
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2175 There are several ways to go through a list of all tags matching a pattern.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2176
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2177 1. You can list all the tags matching a particular regular
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2178 expression pattern by prepending the tag name with the '/'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2179 search character. For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2180
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2181 :tag /&lt;pattern&gt; :stag /&lt;pattern&gt; :ptag
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2182 /&lt;pattern&gt; :tselect /&lt;pattern&gt; :tjump
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2183 /&lt;pattern&gt; :ptselect /&lt;pattern&gt; :ptjump
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2184 /&lt;pattern&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2185
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2186 2. If you have the 'wildmenu' option set, then you can press
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2187 the &lt;Tab&gt; key to display a list of all the matching tags
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2188 in the status bar. You can use the arrow keys to move between
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2189 the tags and then use the &lt;Enter&gt; key to select a tag.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2190
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2191 3. If you don't have the 'wildmenu' option set, you can still
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2192 use the &lt;Tab&gt; key to browse through the list of matching
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2193 tags.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2194
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2195 Help keyword(s): tag-regexp, wildmenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2196
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2197 18. What options are available to control how Vim handles the tags
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2198 file?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2199
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2200 You can use the following options to control the handling of tags file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2201 by Vim:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2202
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2203 1. 'tagrelative' - Controls how the file names in the tags file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2204 are treated. When on, the filenames are relative to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2205 the directory where the tags file is present.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2206
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2207 2. 'taglength' - Controls the number of significant characters
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2208 used for recognizing a tag.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2209
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2210 3. 'tagbsearch' - Controls the method used to search the tags file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2211 for a tag. If this option is on, binary search is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2212 used to search the tags file. Otherwise, linear search
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2213 is used.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2214
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2215 4. 'tagstack' - Controls how the tag stack is used.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2216
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2217 Help keyword(s): 'tagrelative', 'taglength', 'tagbsearch',
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2218 'tagstack'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2219
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2220 19. Is it possible to highlight all the tags in the current file?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2221
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2222 Yes. Read the Vim online help on "tag-highlight".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2223
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2224 20. Is it possible to create a menu with all the tags in the current
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2225 file?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2226
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2227 Yes. It is possible to create a menu with all the tags in the current
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2228 file using a Vim script. Download the TagsMenu.vim script from the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2229 following link:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2230
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2231 <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2232 HREF="http://members.home.net/jayglanville/tagsmenu/TagsMenu.html">http://members.home.net/jayglanville/tagsmenu/TagsMenu.html</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2233
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2234 21. Is there a workaround to make the Ctrl-] key not to be treated as
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2235 the telnet escape character?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2236
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2237 The default escape characters for telnet in Unix systems is Ctrl-].
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2238 While using Vim in a telnet session, if you use Ctrl-] to jump to a tag,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2239 you will get the telnet prompt. There are two ways to avoid this problem:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2240
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2241 1. Map the telnet escape character to some other character using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2242 the "-e &lt;escape character&gt;" telnet command line option
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2243
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2244 2. Disable the telnet escape character using the "-E" telnet
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2245 command line option.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2246
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2247 Help keyword(s): telnet-CTRL-]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2248
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2249 </pre></tip> </html> <Tip category="KVim"> <html><center>How do I pipe
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2250 the output from ex commands into the text buffer?</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2251 HREF="http://vim.sf.net/tip_view.php?tip_id=95">http://vim.sf.net/tip_view.php?tip_id=95</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2252
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2253 This is a *request* for a tip. I need to be able to pipe the output of a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2254 :blah ex command into the vim text buffer for editing. I wanted to do this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2255 many times for different reasons and could never find a way!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2256
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2257 I would just love to be able to do :hi --&gt; textBuffer and examine the output
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2258 at my own leasure scrolling up and down and using vim search commands on it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2259 Same thing for :set all, and other things. Considering that cut and paste
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2260 is horrible in windows, I can't for example do :set guioptions? then cut
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2261 and paste! So I have to retype it, or cut and paste from the help manual.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2262 I really want to be able to pipe the output of ex commands into the text
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2263 buffer. Can someone help me?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2264
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2265 </pre></tip> </html> <Tip category="KVim"> <html><center>Cooperation
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2266 of Gvim and AutoCad [MTEXT]</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2267 HREF="http://vim.sf.net/tip_view.php?tip_id=96">http://vim.sf.net/tip_view.php?tip_id=96</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2268
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2269 You can - like me :o) - use gvim, like replacement of internal AutoCad
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2270 MTEXT editor. You need switch variable MTEXTED to "gvim" (or maybe fullpath,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2271 something like "c:\vim\vim60aq\gvim" ), and to your _vimrc you can put line:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2272
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2273 autocmd BufRead,BufNewFile *.tmp source c:\vim\aacad.vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2274
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2275 And when you edit MTEXT in acad, menu AutoCad will be for your use in gvim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2276 (only in INSERT and VISUAL mode)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2277
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2278 [NOTE: Only I can't start gvim like gvim -y (for any other person, not so
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2279 accustomed vith gvim) or start gvim from gvim.lnk or gvim.bat (I'am using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2280 windows95) and automatic skip to INSERT mode -latest word star, on end of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2281 script- is without functionality(?) Maybe someone advise me?? ]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2282
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2283 Well, script aacad.vim is listed here:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2284
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2285 "VIM menu for AutoCad's MTEXT editation "brz;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2286 mailto:brz@centrum.cz; 8. 8. 2001 " Version Mk.I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2287 "--------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2288
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2289 imenu &AutoCad.Insert.Space \~ vmenu &AutoCad.Insert.Space
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2290 &lt;Esc&gt;`&lt;i\~&lt;Esc&gt;% imenu &AutoCad.Insert.Backslash \\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2291 vmenu &AutoCad.Insert.Backslash &lt;Esc&gt;`&lt;i\\&lt;Esc&gt;% imenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2292 &AutoCad.Insert.Brackets \{\}&lt;Esc&gt;F\i vmenu &AutoCad.Insert.Brackets
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2293 &lt;Esc&gt;`&gt;a\}&lt;Esc&gt;`&lt;i\{&lt;Esc&gt;% imenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2294 &AutoCad.Insert.Paragraph \P vmenu &AutoCad.Insert.Paragraph
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2295 &lt;Esc&gt;`&gt;a\P&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2296
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2297 imenu &AutoCad.-SEP1- :
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2298
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2299 imenu &AutoCad.Colour.Red \C1; vmenu &AutoCad.Colour.Red
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2300 &lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C1;&lt;Esc&gt;% imenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2301 &AutoCad.Colour.Yellow \C2; vmenu &AutoCad.Colour.Yellow
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2302 &lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C2;&lt;Esc&gt;% imenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2303 &AutoCad.Colour.Green \C3; vmenu &AutoCad.Colour.Green
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2304 &lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C3;&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2305 imenu &AutoCad.Colour.Cyan \C4; vmenu &AutoCad.Colour.Cyan
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2306 &lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C4;&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2307 imenu &AutoCad.Colour.Blue \C5; vmenu &AutoCad.Colour.Blue
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2308 &lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C5;&lt;Esc&gt;% imenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2309 &AutoCad.Colour.Violet \C6; vmenu &AutoCad.Colour.Violet
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2310 &lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C6;&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2311 imenu &AutoCad.Colour.Black \C7; vmenu &AutoCad.Colour.Black
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2312 &lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C7;&lt;Esc&gt;% imenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2313 &AutoCad.Colour.D_Grey \C8; vmenu &AutoCad.Colour.D_Grey
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2314 &lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C8;&lt;Esc&gt;% imenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2315 &AutoCad.Colour.L_Grey \C9; vmenu &AutoCad.Colour.L_Grey
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2316 &lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C9;&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2317
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2318 imenu &AutoCad.Font.Arial \fArial; vmenu &AutoCad.Font.Arial
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2319 &lt;Esc&gt;`&lt;i\fArial;&lt;Esc&gt;% imenu &AutoCad.Font.Symbol \Fsymbol;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2320 vmenu &AutoCad.Font.Symbol &lt;Esc&gt;`&lt;i\Fsymbol;&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2321 imenu &AutoCad.Font.RomanC \Fromanc; imenu &AutoCad.Font.RomanC
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2322 &lt;Esc&gt;`&lt;i\Fromanc;&lt;Esc&gt;% imenu &AutoCad.Font.RomanS \Fromans;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2323 vmenu &AutoCad.Font.RomanS &lt;Esc&gt;`&lt;i\Fromans;&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2324 imenu &AutoCad.Font.RomanD \Fromand; vmenu &AutoCad.Font.RomanD
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2325 &lt;Esc&gt;`&lt;i\Fromand;&lt;Esc&gt;% imenu &AutoCad.Font.RomanT \Fromant;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2326 vmenu &AutoCad.Font.RomanT &lt;Esc&gt;`&lt;i\Fromant;&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2327
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2328 imenu &AutoCad.Size.0_5x \H0.5x; vmenu &AutoCad.Size.0_5x
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2329 &lt;Esc&gt;`&lt;i\H0.5x;&lt;Esc&gt;% imenu &AutoCad.Size.1_5x \H1.5x; vmenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2330 &AutoCad.Size.1_5x &lt;Esc&gt;`&lt;i\H1.5x;&lt;Esc&gt;% imenu &AutoCad.Size.2x
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2331 \H2x; vmenu &AutoCad.Size.2x &lt;Esc&gt;`&lt;i\H2x;&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2332 imenu &AutoCad.Size.3x \H3x; vmenu &AutoCad.Size.3x
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2333 &lt;Esc&gt;`&lt;i\H3x;&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2334
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2335 imenu &AutoCad.Effects.Set_Out_1_5 \T1.5; vmenu &AutoCad.Effects.Set_Out_1_5
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2336 &lt;Esc&gt;`&gt;a\T1;&lt;Esc&gt;`&lt;i\T1.5;&lt;Esc&gt;% imenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2337 &AutoCad.Effects.Set_Out_2 \T2; vmenu &AutoCad.Effects.Set_Out_2
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2338 &lt;Esc&gt;`&gt;a\T1;&lt;Esc&gt;`&lt;i\T2;&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2339
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2340 imenu &AutoCad.Effects.-SEP3- : imenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2341 &AutoCad.Effects.Tilt_15deg \Q15; vmenu &AutoCad.Effects.Tilt_15deg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2342 &lt;Esc&gt;`&gt;a\Q0;&lt;Esc&gt;`&lt;i\Q10;&lt;Esc&gt;% imenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2343 &AutoCad.Effects.Tilt_20deg \Q20; vmenu &AutoCad.Effects.Tilt_20deg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2344 &lt;Esc&gt;`&gt;a\Q0;&lt;Esc&gt;`&lt;i\Q20;&lt;Esc&gt;% imenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2345 &AutoCad.Effects.Tilt_30deg \Q30; vmenu &AutoCad.Effects.Tilt_30deg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2346 &lt;Esc&gt;`&gt;a\Q0;&lt;Esc&gt;`&lt;i\Q30;&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2347
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2348 imenu &AutoCad.Effects.-SEP4- : imenu &AutoCad.Effects.Change_Width_0_5x
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2349 \W0.5; vmenu &AutoCad.Effects.Change_Width_0_5x
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2350 &lt;Esc&gt;`&gt;a\W1;&lt;Esc&gt;`&lt;i\W0.5;&lt;Esc&gt;% imenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2351 &AutoCad.Effects.Change_Width_2x \W2; vmenu &AutoCad.Effects.Change_Width_2x
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2352 &lt;Esc&gt;`&gt;a\W1;&lt;Esc&gt;`&lt;i\W2;&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2353
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2354 imenu &AutoCad.Effects.-SEP5- : imenu &AutoCad.Effects.Justify_Down \A0;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2355 vmenu &AutoCad.Effects.Justify_Down &lt;Esc&gt;`&lt;i\A0;&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2356 imenu &AutoCad.Effects.Justify_Middle \A1; vmenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2357 &AutoCad.Effects.Justify_Middle &lt;Esc&gt;`&lt;i\A1;&lt;Esc&gt;%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2358 imenu &AutoCad.Effects.Justify_Up \A2; vmenu &AutoCad.Effects.Justify_Up
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2359 &lt;Esc&gt;`&lt;i\A2;&lt;Esc&gt;% imenu &AutoCad.Effects.Overlined_Characters
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2360 \O\o&lt;Esc&gt;F\i vmenu &AutoCad.Effects.Overlined_Characters
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2361 &lt;Esc&gt;`&gt;a\O&lt;Esc&gt;`&lt;i\o&lt;Esc&gt;% imenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2362 &AutoCad.Effects.Underlined_Characters \L\l&lt;Esc&gt;F\i
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2363 vmenu &AutoCad.Effects.Underlined_Characters
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2364 &lt;Esc&gt;`&gt;a\l&lt;Esc&gt;`&lt;i\L&lt;Esc&gt;% imenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2365 &AutoCad.Effects.Index_Top \S^;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2366
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2367 imenu &AutoCad.-SEP6- : imenu &AutoCad.Help &lt;CR&gt;&lt;CR&gt;***Quit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2368 Editor: press Alt-F4 and 'No' ***&lt;CR&gt;&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2369
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2370 star
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2371
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2372 </pre></tip> </html> <Tip category="KVim"> <html><center>How
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2373 do I add a current time string inside Vim?</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2374 HREF="http://vim.sf.net/tip_view.php?tip_id=97">http://vim.sf.net/tip_view.php?tip_id=97</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2375
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2376 This is a *request* for a tip. Sometimes (eg. editing HTML pages) I need
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2377 to add a timestamp string to my editing buffer. On UNIX systems, I can use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2378 :r!date
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2379 to get a localized date time string; but on Windows ('date' on Windows will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2380 query the user to input new date) or other platforms which does not have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2381 'date' command, how do I get a timestamp easily?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2382
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2383 </pre></tip> </html> <Tip category="KVim"> <html><center>Getting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2384 vim help from mailing lists and newsgroups.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2385 HREF="http://vim.sf.net/tip_view.php?tip_id=98">http://vim.sf.net/tip_view.php?tip_id=98</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2386
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2387 There have been a few "requests for tips" entered into the tips database
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2388 lately. If you have specific questions that aren't answered by the existing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2389 tips, there are a couple of resources that may be more appropriate:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2390
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2391 The mailing list vim@vim.org is for vim users. If you send an email
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2392 to vim-help@vim.org, you'll get a message back telling you how
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2393 to subscribe, as well as how to request old messages and contact
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2394 the list maintainer. This mailing list is also archived at <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2395 HREF="http://groups.yahoo.com/group/vim.">http://groups.yahoo.com/group/vim.</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2396
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2397 The newsgroup comp.editors discusses many different editors, but most of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2398 the traffic is about vim. When posting, it is appreciated if you include
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2399 "vim" in the subject line. The comp.editors newsgroup is archived at <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2400 HREF="http://groups.google.com/groups?hl=en&safe=off&group=comp.editors.">http://groups.google.com/groups?hl=en&safe=off&group=comp.editors.</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2401
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2402 Using the tips database for asking questions is not likely to work well.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2403 For example, if you ask a question titled "Searching for strings in a file"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2404 and I read this site and see that tip, I'm not going to read it if I already
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2405 know how to search for strings in a file. In comp.editors and vim@vim.org,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2406 people expect to find questions from others and are therefore more likely
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2407 to see your questions.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2408
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2409 After finding the answer to your question, please consider whether it would
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2410 make an appropriate tip, and if so, add it to the tips database.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2411
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2412 </pre></tip> </html> <Tip category="KVim"> <html><center>How to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2413 tell what syntax highlighting group *that* is!</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2414 HREF="http://vim.sf.net/tip_view.php?tip_id=99">http://vim.sf.net/tip_view.php?tip_id=99</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2415
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2416 Here's a (what should be a one-line) map to help you tell just what syntax
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2417 highlighting groups the item under the cursor actually is:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2418
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2419 map &lt;F10&gt; :echo "hi&lt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2420 . synIDattr(synID(line("."),col("."),1),"name") . '&gt; trans&lt;'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2421 . synIDattr(synID(line("."),col("."),0),"name") . "&gt; lo&lt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2422 . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . "&gt;"&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2423
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2424 Once known you can override the current highlighting with whatever you want.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2425 If you're debugging a syntax highlighting file (a rare occupation), sometimes
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2426 you'll wish to know the entire chain of syntax highlighting. For that,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2427 check out
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2428
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2429 <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2430 HREF="http://www.erols.com/astronaut/vim/vimscript/hilinks.vim">http://www.erols.com/astronaut/vim/vimscript/hilinks.vim</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2431
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2432 </pre></tip> </html> <Tip category="KVim"> <html><center>Jump to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2433 tag (e.g. help topic) with German keyboard (PC)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2434 HREF="http://vim.sf.net/tip_view.php?tip_id=100">http://vim.sf.net/tip_view.php?tip_id=100</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2435
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2436 You're a newbie in vim and need some ":help"? Well, help.txt reads:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2437
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2438 "Jump to a subject: Position the cursor on a tag between |bars| and hit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2439 CTRL-]."
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2440
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2441 Unfortunately there is no "]" key on German keyboards. On Win32 try CTRL-+
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2442 (Strg-+), on Linux console I use CTRL-AltGr-9 (Strg-AltGr-9).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2443
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2444 Kind regards
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2445
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2446 </pre></tip> </html> <Tip category="KVim"> <html><center>Change automatically
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2447 to the directory the file in the current buffer is in</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2448 HREF="http://vim.sf.net/tip_view.php?tip_id=101">http://vim.sf.net/tip_view.php?tip_id=101</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2449
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2450 To change automatically to the directory the file in the current buffer is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2451 in add a line (below) to the file .vimrc . The file .vimrc should have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2452 the following if-statement to control the autocmd feature:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2453
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2454 if has("autocmd")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2455
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2456 &lt; ... lot of autocmd stuff ... &gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2457
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2458 " Change to the directory the file in your current buffer is in autocmd
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2459 BufEnter * :cd %:p:h
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2460
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2461 endif " has("autocmd")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2462
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2463 Add the line above the endif and restart vim/gvim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2464
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2465 </pre></tip> </html> <Tip category="KVim"> <html><center>smart
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2466 mapping for tab completion</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2467 HREF="http://vim.sf.net/tip_view.php?tip_id=102">http://vim.sf.net/tip_view.php?tip_id=102</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2468
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2469 I'm used to complete words with &lt;tab&gt;, however when editing source
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2470 I can't just map that to vim keyword completion because I sometime need to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2471 insert real tabs, since it mostly happen when at the beginning of the line or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2472 after a ; and before a one line comma (java, c++ or perl anyone...) I've come
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2473 to find the following really usefull This is how you can map the &lt;tab&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2474 key in insert mode while still being able to use it when at the start of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2475 a line or when the preceding char is not a keyword character. in a script
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2476 file in a plugin directory or in your .vimrc file: first define a function
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2477 which returns a &lt;tab&gt; or a &lt;C-N&gt; depending on the context:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2478
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2479 function InsertTabWrapper()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2480 let col = col('.') - 1 if !col || getline('.')[col - 1] !~ '\k'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2481 return "\&lt;tab&gt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2482 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2483 return "\&lt;c-p&gt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2484 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2485 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2486
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2487 then define the appropriate mapping: inoremap &lt;tab&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2488 &lt;c-r&gt;=InsertTabWrapper()&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2489
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2490 the trick here is the use of the &lt;c-r&gt;= in insert mode to be able to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2491 call your function without leaving insert mode. :help i_CTRL-R Benoit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2492
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2493 </pre></tip> </html> <Tip category="KVim"> <html><center>Move
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2494 to next/previous line with same indentation</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2495 HREF="http://vim.sf.net/tip_view.php?tip_id=103">http://vim.sf.net/tip_view.php?tip_id=103</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2496
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2497 When working with Python and other languages which don't use braces, it's
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2498 useful to be able to jump to and from lines which have the same indentation
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2499 as the line you are currently on.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2500
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2501 nn &lt;M-,&gt; k:call search ("^". matchstr (getline (line (".")+ 1),
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2502 '\(\s*\)') ."\\S", 'b')&lt;CR&gt;^ nn &lt;M-.&gt; :call search ("^". matchstr
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2503 (getline (line (".")), '\(\s*\)') ."\\S")&lt;CR&gt;^
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2504
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2505 will map Alt-&lt; and Alt-&gt; in Normal mode to upward and downward searching
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2506 for lines with the same indent as the current line.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2507
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2508 </pre></tip> </html> <Tip category="KVim"> <html><center>using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2509 vim to complement Perl's DBI::Shell</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2510 HREF="http://vim.sf.net/tip_view.php?tip_id=104">http://vim.sf.net/tip_view.php?tip_id=104</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2511
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2512 DBI::Shell is a Perl module that is used as a shell interface to Perl's
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2513 popular DBI (database interface) package. Forget your favorite SQL navigation
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2514 gui and give this method a shot. This has only been tested in UNIX.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2515
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2516 1. run dbish (runs DBI::Shell; installed with DBI::Shell) and connect to any
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2517 database 2. in dbish, set /format box 3. enter your query 4. to execute query,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2518 type "/ | vim -"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2519
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2520 This runs the query and pipes the output to the standard input of vim. Here
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2521 are some follow-up tips: -use gvim instead of vim so a new window will pop
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2522 up -set nowrap once in vim -make a syntax highlighting file for me!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2523
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2524 -Adam Monsen
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2525
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2526 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2527 <html><center>combining move and scroll</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2528 HREF="http://vim.sf.net/tip_view.php?tip_id=105">http://vim.sf.net/tip_view.php?tip_id=105</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2529
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2530 I sometimes found myself moving down a few lines with j, then scrolling
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2531 down about the same number of lines with &lt;C-E&gt; to put the cursor in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2532 roughly the same place as it started. I decided I wanted to map &lt;C-J&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2533 (and &lt;C-K&gt;, respectively) to the move-and-scroll operation. First, I did
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2534
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2535 :map &lt;C-J&gt; &lt;C-E&gt;j
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2536
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2537 This was pretty good, but behaved funny at the beginning and end of files.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2538 Then, I realized that &lt;C-D&gt; already combined move and scroll, so I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2539 figured that giving &lt;C-D&gt; a count of 1 would do it:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2540
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2541 :map &lt;C-J&gt; 1&lt;C-D&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2542
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2543 Unfortunately, this permanently attaches a count to &lt;C-D&gt; (ugh!),
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2544 so I have to undo that:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2545
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2546 :map &lt;C-J&gt; 1&lt;C-D&gt;:set scroll=0&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2547
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2548 This has the drawback of not necessarily resetting scroll to its original
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2549 value, but since I never change scroll, it's good enough for me. It would be
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2550 nice if there were a version of &lt;C-D&gt; that did not have the side-affect
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2551 of changing scroll.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2552
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2553 Happy vimming, Andrew
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2554
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2555 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2556 <html><center>Supersimple one-line solution</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2557 HREF="http://vim.sf.net/tip_view.php?tip_id=106">http://vim.sf.net/tip_view.php?tip_id=106</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2558
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2559 Hallo, next solution for _most_simple_ signature rotater: You can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2560 only put one line to your .vimrc || _vimrc: map &lt;Leader&gt;ms :e
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2561 c:\sign.txt&lt;CR&gt;ggV/--&lt;CR&gt;k"*xG$a&lt;C-R&gt;&lt;C-O&gt;*&lt;Esc&gt;:w&lt;CR&gt;:bd&lt;CR&gt;G$a&lt;C-M&gt;&lt;Esc&gt;"*P
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2562
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2563 Must exist file (from eg above) c:\sign.txt, with content: -- first signature
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2564 -- second signature -- third signature --
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2565
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2566 When You finished mail, only call shortcut \ms and 'first signature' will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2567 be insert in your mail. In c:\sign.txt will be first signature pushed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2568 to the end of this file. When You want use other signature, only press
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2569 'u' and \ms again (Or You can change \ms to e.g. &lt;F12&gt;, indeed. )
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2570 You can change this and append one part like 'basic' from command and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2571 append 'changing' part from .signature file, as you like... Ok, one
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2572 unpleasant thing is here: your signature must not contain '--' (signature
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2573 separator)... Anyhow, I find it useful brz* &lt;brz@centrum.cz&gt; <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2574 HREF="http://brz.d2.cz/">http://brz.d2.cz/</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2575
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2576 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2577 <html><center>convert enum to string table</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2578 HREF="http://vim.sf.net/tip_view.php?tip_id=107">http://vim.sf.net/tip_view.php?tip_id=107</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2579
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2580 When testing your own C/C++ programs you sometimes wish to have a trace output,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2581 which shows you, which enum value is used. You can do this by creating
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2582 a string table for that enum type, which contains the enum identifyer as
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2583 a string. e.g. printf ("%s", MyEnumStringTable [ MyEnumVal] );
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2584
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2585 You can create the complete string table by - marking the lines containing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2586 the complete typedef enum - select menu C/C++.transform enum2Stringtab
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2587
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2588 You can create string table entries by - marking the lines within the typedef
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2589 enum - select menu C/C++.transform enum2String
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2590
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2591 This makes it easy to keep the enum (on changes) consistent to the string
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2592 table.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2593
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2594 Add the following lines to your _GVIMRC file: 31amenu C/C++.transform\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2595 enum2Stringtab :s#[ ]*\\(\\w\\+\\)#/* \\1 */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2596 "\\1"#&lt;CR&gt;o};&lt;ESC&gt;uOstatic const char* const Names[] =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2597 {&lt;ESC&gt;&lt;CR&gt;/sdfsdf&lt;CR&gt; 31vmenu C/C++.transform\ enum2Stringtab
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2598 :s#[ ]*\\(\\w\\+\\)#/* \\1 */ "\\1"#&lt;CR&gt;o};&lt;ESC&gt;uOstatic
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2599 const char* const Names[] = {&lt;ESC&gt;&lt;CR&gt;/sdfsdf&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2600
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2601 31amenu C/C++.transform\ enum2String :s#[ ]*\\(\\w\\+\\)#/*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2602 \\1 */ "\\1"#&lt;CR&gt;o}&lt;ESC&gt;/sdfsdf&lt;CR&gt; 31vmenu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2603 C/C++.transform\ enum2String :s#[ ]*\\(\\w\\+\\)#/* \\1 */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2604 "\\1"#&lt;CR&gt;o}&lt;ESC&gt;/sdfsdf&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2605
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2606 hint: '/sdfsdf' is added for deactivating search highlighting, ok, you'll
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2607 sure find a better way to do this.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2608
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2609 </pre></tip> </html> <Tip category="KVim"> <html><center>Toggle
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2610 a fold with a single keystroke</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2611 HREF="http://vim.sf.net/tip_view.php?tip_id=108">http://vim.sf.net/tip_view.php?tip_id=108</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2612
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2613 When viewing/editing a folded file, it is often needed to inspect/close
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2614 some fold. To speed up these operation use the following (put in your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2615 $HOME/.vimrc):
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2616
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2617 " Toggle fold state between closed and opened. " " If there is no fold at
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2618 current line, just moves forward. " If it is present, reverse it's state.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2619 fun! ToggleFold()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2620 if foldlevel('.') == 0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2621 normal! l
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2622 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2623 if foldclosed('.') &lt; 0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2624 . foldclose
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2625 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2626 . foldopen
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2627 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2628 endif " Clear status line echo
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2629 endfun
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2630
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2631 " Map this function to Space key. noremap &lt;space&gt; :call
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2632 ToggleFold()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2633
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2634 See :help folding for more information about folding.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2635
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2636 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2637 <html><center>jump between files</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2638 HREF="http://vim.sf.net/tip_view.php?tip_id=109">http://vim.sf.net/tip_view.php?tip_id=109</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2639
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2640 Often I know I'm likely to edit many files. I run 'vim *.pl' and get a whole
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2641 bunch of open files.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2642
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2643 To make jumping between files to a pleasure, I defined to mapss:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2644
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2645 map &lt;f1&gt; :previous&lt;cr&gt; map &lt;f2&gt; :next&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2646
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2647 Press F1 to go back and F2 to go forward.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2648
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2649 -- Kirill
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2650
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2651 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2652 <html><center>text-&gt;html table converter.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2653 HREF="http://vim.sf.net/tip_view.php?tip_id=110">http://vim.sf.net/tip_view.php?tip_id=110</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2654
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2655 Below are two functions and a mapping which will convert lines of plain
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2656 text into HTML table code. For example, you have several lines like:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2657 ----------------------------------------------- 1 2 3
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2658
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2659 4 5 6 --------------------------------------------------- by visualizing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2660 all the 7 lines and press &lt;F5&gt;, you can change the text into
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2661 &lt;table&gt;&lt;tr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2662 &lt;td&gt;1&lt;/td&gt; &lt;td&gt;2&lt;/td&gt; &lt;td&gt;3&lt;/td&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2663 &lt;/tr&gt;&lt;tr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2664 &lt;td&gt;4&lt;/td&gt; &lt;td&gt;5&lt;/td&gt; &lt;td&gt;6&lt;/td&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2665 &lt;/tr&gt;&lt;/table&gt; which will eventually render into a table. So the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2666 rule is: Every line is a table item, every empty line means starting of a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2667 new table row.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2668
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2669 "A text-&gt;html table code converter "By: Wenzhi Liang wzhliang@yahoo.com
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2670 "You can distribute/change this file freely as long as you keep the title
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2671 area. Thanks
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2672
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2673 func Table()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2674 let end=line("'&gt;") let start=line("'&lt;") let i=start
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2675
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2676 wh i &lt;= end
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2677 exe ":" . i let e=Empty() if e == 1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2678 exe "normal I&lt;/tr&gt;&lt;tr&gt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2679 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2680 exe "normal I&lt;td&gt;A&lt;/td&gt;&gt;&gt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2681 endif let i=i+1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2682 endwh
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2683
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2684 exe "normal o&lt;/tr&gt;&lt;/table&gt;&lt;&lt;" exe ":" . start exe
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2685 "normal O&lt;table&gt;&lt;tr&gt;&lt;&lt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2686 endfunc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2687
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2688 vmap &lt;F5&gt; &lt;ESC&gt;:call Table()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2689
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2690 func Empty()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2691 let line_nr= line (".") let a=getline ( line_nr ) let m=match(a,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2692 "\\S") if m == -1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2693 return 1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2694 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2695 return 0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2696 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2697 endfunc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2698
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2699 </pre></tip> </html> <Tip category="KVim"> <html><center>Printing with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2700 syntax highlighting independent of your normal highlighting</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2701 HREF="http://vim.sf.net/tip_view.php?tip_id=111">http://vim.sf.net/tip_view.php?tip_id=111</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2702
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2703 I have found it undesirable to use :hardcopy directly because it uses the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2704 current syntax highlighting to determine how to print the text. For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2705 I like to print comments in italics, but I don't like italic fonts on the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2706 screen. This tip will show you how to set up a colorscheme for printing and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2707 use it only when you print.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2708
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2709 I copied an existing colorscheme to ~/.vim/colors/print.vim, and changed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2710 all the lines like this:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2711
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2712 highlight Normal ctermbg=DarkGrey ctermfg=White guifg=White guibg=grey20
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2713 to this:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2714 highlight clear Normal
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2715
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2716 Then I set the syntax groups how I wanted them to be printed on the printer:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2717
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2718 highlight Comment term=italic cterm=italic gui=italic highlight
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2719 Constant term=bold cterm=bold gui=bold etc....
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2720
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2721 I then defined the following command in my .vimrc file:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2722
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2723 command! -nargs=* Hardcopy call DoMyPrint("&lt;args&gt;")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2724
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2725 And, finally, I defined this function in my .vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2726
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2727 function DoMyPrint(args)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2728 let colorsave=g:colors_name color print exec "hardcopy ".a:args exec
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2729 'color '.colorsave
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2730 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2731
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2732 After this is complete, you can do:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2733 :Hardcopy &gt; /tmp/out.ps
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2734 or just
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2735 :Hardcopy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2736 (Note the capital H)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2737
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2738 </pre></tip> </html> <Tip category="KVim"> <html><center>Back
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2739 and forth between indented lines again</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2740 HREF="http://vim.sf.net/tip_view.php?tip_id=112">http://vim.sf.net/tip_view.php?tip_id=112</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2741
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2742 Paul Wright posted a tip which explained how to jump back and forth between
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2743 lines with the same indentation level. I do this a lot, so I came up with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2744 this slightly more comprehensive solution.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2745
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2746 The example mappings below work as follows:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2747
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2748 [l and ]l jump to the previous or the next line with the same indentation
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2749 level as the one you're currently on.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2750
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2751 [L and ]L jump to the previous or the next line with an indentation level
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2752 lower than the line you're currently on.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2753
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2754 These movements also work in visual mode and (only as of one of the 6.0 alpha
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2755 versions) in operator pending mode, meaning that you can do a d]l. The motion
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2756 is specified as being exclusive when in operator pending mode.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2757
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2758 When might you use this? If you're writing programs in Python, Haskell,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2759 or editing XML files, they will be very useful. E.g. in XML you can jump to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2760 the outer enclosing tag, or the next matching tag. I use it for practically
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2761 anything I edit, so it's not limited to this.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2762
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2763 " " NextIndent() " " Jump to the next or previous line that has the same level
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2764 or a lower " level of indentation than the current line. " " exclusive (bool):
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2765 true: Motion is exclusive " false: Motion is inclusive "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2766 fwd (bool): true: Go to next line " false: Go to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2767 previous line " lowerlevel (bool): true: Go to line with lower indentation
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2768 level " false: Go to line with the same indentation level
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2769 " skipblanks (bool): true: Skip blank lines " false:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2770 Don't skip blank lines
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2771
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2772 function! NextIndent(exclusive, fwd, lowerlevel, skipblanks)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2773 let line = line('.') let column = col('.') let lastline = line('$')
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2774 let indent = indent(line) let stepvalue = a:fwd ? 1 : -1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2775
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2776 while (line &gt; 0 && line &lt;= lastline)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2777 let line = line + stepvalue if ( ! a:lowerlevel &&
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2778 indent(line) == indent ||
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2779 \ a:lowerlevel && indent(line) &lt; indent)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2780 if (! a:skipblanks || strlen(getline(line)) &gt; 0)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2781 if (a:exclusive)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2782 let line = line - stepvalue
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2783 endif exe line exe "normal " column . "|"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2784 return
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2785 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2786 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2787 endwhile
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2788 endfunc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2789
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2790 " Moving back and forth between lines of same or lower indentation.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2791 nnoremap &lt;silent&gt; [l :call NextIndent(0, 0, 0, 1)&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2792 nnoremap &lt;silent&gt; ]l :call NextIndent(0, 1, 0, 1)&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2793 nnoremap &lt;silent&gt; [L :call NextIndent(0, 0, 1, 1)&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2794 nnoremap &lt;silent&gt; ]L :call NextIndent(0, 1, 1, 1)&lt;cr&gt; vnoremap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2795 &lt;silent&gt; [l &lt;esc&gt;:call NextIndent(0, 0, 0, 1)&lt;cr&gt;m'gv''
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2796 vnoremap &lt;silent&gt; ]l &lt;esc&gt;:call NextIndent(0, 1, 0,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2797 1)&lt;cr&gt;m'gv'' vnoremap &lt;silent&gt; [L &lt;esc&gt;:call NextIndent(0, 0,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2798 1, 1)&lt;cr&gt;m'gv'' vnoremap &lt;silent&gt; ]L &lt;esc&gt;:call NextIndent(0,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2799 1, 1, 1)&lt;cr&gt;m'gv'' onoremap &lt;silent&gt; [l :call NextIndent(0, 0, 0,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2800 1)&lt;cr&gt; onoremap &lt;silent&gt; ]l :call NextIndent(0, 1, 0, 1)&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2801 onoremap &lt;silent&gt; [L :call NextIndent(1, 0, 1, 1)&lt;cr&gt; onoremap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2802 &lt;silent&gt; ]L :call NextIndent(1, 1, 1, 1)&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2803
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2804 </pre></tip> </html> <Tip category="KVim"> <html><center>Translator
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2805 in vim (Windows solution)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2806 HREF="http://vim.sf.net/tip_view.php?tip_id=113">http://vim.sf.net/tip_view.php?tip_id=113</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2807
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2808 Hallo, today I found script "translate.vim", but on Windows this will be
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2809 probably difficult to run it (maybe with Cygwin is it possible). I've simpler
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2810 solution of keymap for vim interlacing to dictionary: Must exist file with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2811 vocabulary (e.g. "an-cs.txt"), which is called for word under cursor. In
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2812 'normal' is only displayed window with translations, in 'insert' is word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2813 under cursor deleted and is insert selected form of word from translantion
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2814 window (select it by mouse and than press right button: It works fine on
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2815 W2k). Key _F12_ is looking for "word", shifted _S-F12_ is looking for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2816 "pattern". For windows is needed agrep, which is localy placed on <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2817 HREF="http://www.tgries.de/agrep/index.html">http://www.tgries.de/agrep/index.html</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2818
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2819 map &lt;F12&gt; b"*yw&lt;Esc&gt;:! c:/bin/agrep -wih
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2820 &lt;C-R&gt;* "c:/dict/an-cs.txt"&lt;CR&gt; imap &lt;F12&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2821 &lt;Esc&gt;b"*yw&lt;Esc&gt;:! c:/bin/agrep -wih &lt;C-R&gt;*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2822 "c:/dict/an-cs.txt"&lt;CR&gt;dwi &lt;C-R&gt;* map &lt;S-F12&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2823 b"*yw&lt;Esc&gt;:! c:/bin/agrep -ih &lt;C-R&gt;* "c:/dict/an-cs.txt"&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2824 imap &lt;S-F12&gt; &lt;Esc&gt;b"*yw&lt;Esc&gt;:! c:/bin/agrep -ih &lt;C-R&gt;*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2825 "c:/dict/an-cs.txt"&lt;CR&gt;dwi &lt;C-R&gt;*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2826
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2827 brz* &lt;brz@centrum.cz&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2828
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2829 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2830 <html><center>Browsing by paragraph</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2831 HREF="http://vim.sf.net/tip_view.php?tip_id=114">http://vim.sf.net/tip_view.php?tip_id=114</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2832
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2833 It can be done by reaching the blank lines in up and down directions just
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2834 by pressing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2835
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2836 { ---- For going to the blank line above the paragraph } ---- For
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2837 going to the blank line below the paragraph
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2838
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2839 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2840 <html><center>Browsing by paragraph</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2841 HREF="http://vim.sf.net/tip_view.php?tip_id=115">http://vim.sf.net/tip_view.php?tip_id=115</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2842
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2843 It can be done by reaching the blank lines in up and down directions just
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2844 by pressing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2845
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2846 { ---- For going to the blank line above the paragraph } ---- For
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2847 going to the blank line below the paragraph
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2848
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2849 </pre></tip> </html> <Tip category="KVim"> <html><center>Search all
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2850 occurances of the word under cursor in all the open files</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2851 HREF="http://vim.sf.net/tip_view.php?tip_id=116">http://vim.sf.net/tip_view.php?tip_id=116</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2852
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2853 Sometimes it is useful to know all the occurances of the word under cursor in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2854 all the open files. This can be done by pressing [I ( bracket and capital I )
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2855 . it shows the results found in the command window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2856
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2857 </pre></tip> </html> <Tip category="KVim"> <html><center>FAST
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2858 SEARCH ACROSS THE PROJECT</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2859 HREF="http://vim.sf.net/tip_view.php?tip_id=117">http://vim.sf.net/tip_view.php?tip_id=117</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2860
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2861 Searching for a word across the project wastes most of the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2862 developres time, which can be avoided by the use of GNU Id_utils
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2863 with VIM. The procedure needs to be followed is as follows:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2864 download GNU idutils 3.2d (mkid,lid,fid,fnid,xtokid) from <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2865 HREF="http://www.mossbayeng.com/~ron/vim/builds.html">http://www.mossbayeng.com/~ron/vim/builds.html</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2866
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2867 uncompress and store these files in the directory from where vim is running.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2868
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2869 goto the top level directory of the project, and run mkid, it will create ID
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2870 file in that directory (As it is time consuming process, so be patient). copy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2871 this file ID to the directory from where vim is running.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2872
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2873 USAGE:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2874
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2875 Put these lines in your .vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2876
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2877 map _u :call ID_search()&lt;Bar&gt;execute "/\\&lt;" . g:word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2878 . "\\&gt;"&lt;CR&gt; map _n :n&lt;Bar&gt;execute "/\\&lt;" . g:word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2879 . "\\&gt;"&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2880
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2881 function ID_search()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2882 let g:word = expand("&lt;cword&gt;") let x = system("lid --key=none
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2883 ". g:word) let x = substitute(x, "\n", " ", "g") execute "next " . x
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2884 endfun
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2885
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2886 To use it, place the cursor on a word, type "_u" and vim will load the file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2887 that contains the word. Search for the next ocurance of the word in the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2888 same file with "n". Go to the next file with "_n".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2889
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2890 The mapping of "_u" and "_n" can be done to some other key as per your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2891 preference but I use ^K and ^L for this purpose.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2892
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2893 </pre></tip> </html> <Tip category="KVim"> <html><center>Configuring
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2894 gVim as Internet Explorer 'View Source' editor</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2895 HREF="http://vim.sf.net/tip_view.php?tip_id=118">http://vim.sf.net/tip_view.php?tip_id=118</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2896
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2897 Within the registry, you can specify the source editor to be used by Internet
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2898 Explorer when {View|Source} is selected. Unfortunately, you can't specify a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2899 quoted filename argument here, i.e. "%1". The editor specified is supposed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2900 to handle filenames which contain spaces. This will cause problems for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2901 Vim because Vim treats each space as an argument separator. If an unquoted
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2902 filename contains spaces, Vim treats the filename as multiple arguments and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2903 will open multiple files instead of one. To workaround this problem a quoted
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2904 filename has to be passed to Vim. This can be done by creating the following
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2905 Visual Basic Script file gVim.vbs:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2906
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2907 '--- gVim.vbs -----------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2908 'function: Start gvim, combining multiple arguments to single file argument.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2909 'changes: 20010905: Quoted 'oWShell.Run' filename argument, allowing spaces.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2910 ' 20010518: Created. 'author: Freddy Vulto &lt;fvu@fvu.myweb.nl&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2911
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2912 ' Making variable declaration mandatory
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2913 option explicit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2914
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2915 dim oWShell, sArg, sFile
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2916
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2917 ' Create script object
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2918 set oWShell = CreateObject("wscript.shell")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2919 ' Loop through arguments
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2920 for each sArg in wscript.arguments
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2921 ' Add argument to filename
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2922 sFile = sFile & sArg & " "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2923 next
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2924 ' Remove excess space
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2925 sFile = Trim(sFile)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2926 ' Run Vim with file argument. Additional arguments: ' -R: View file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2927 readonly ' -c "set syntax=html": Use HTML syntax-highlighting ' NOTE:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2928 Use "-c ""set ft=html""" to make it work for Vim v6.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2929 oWShell.Run _
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2930 """D:\Programs\Vim\Vim58\gvim.exe """ & _ "-R """ & sFile & """ " & _
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2931 "-c ""set syntax=html"""
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2932
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2933 ' Destroy script object
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2934 set oWShell = NOTHING
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2935
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2936 The source editor now can be specified by adding the following key to the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2937 registry:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2938
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2939 HKEY_LOCAL_MACHINE |- Software
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2940 |- Microsoft
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2941 |- Internet Explorer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2942 |- View Source Editor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2943 |- Editor Name (Default) = D:\Programs\Vim\gvim.vbs
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2944
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2945 Freddy Vulto &lt;fvu@fvu.myweb.nl&gt; <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2946 HREF="http://fvu.myweb.nl/Projects/Vim/Web/vim.htm">http://fvu.myweb.nl/Projects/Vim/Web/vim.htm</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2947
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2948 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2949 <html><center>Explorer startup and shutdown</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2950 HREF="http://vim.sf.net/tip_view.php?tip_id=119">http://vim.sf.net/tip_view.php?tip_id=119</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2951
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2952 I really like the new explorer window, but I wanted it to function a little
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2953 more seemlessly in the editor. The following code does two things. First,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2954 the explorer is started when vim is started. I also noticed and fixed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2955 that the explorers size is not equal to the window size, hence the strange
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2956 behavior when popping between two windows. The other major function of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2957 the code is to close the explorer when it's the only window that's left.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2958 I'd actually like to take this a step further and close the window if the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2959 last _document_ window is closed. I'd prefer that multiple explorers or help
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2960 windows don't keep the application running - only having a file open keeps the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2961 application running. But I didn't see an easy way to do this... anyone else?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2962
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2963 BTW, thank you Bram for the help figuring this out.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2964
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2965 Code (which currently lives in my _vimrc):
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2966
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2967 " FILE BROWSER STARTUP func OpenFileWindow()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2968 " :runtime plugin/*.vim " this would be useful if you were
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2969 calling this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2970 " function from the .vimrc directly
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2971 let g:explDetailedList=1 " show size and date by default let
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2972 g:explVertical=1 " Split vertically let g:explStartRight=0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2973 " Put new explorer window to the left of the current window :Sexplore
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2974 set nonu set winwidth=15 " Make the width of the window match
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2975 the explorer setting "let g:explVertical=0 " Split vertically
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2976 doautocmd fileExplorer BufEnter " Forces the directory refresh to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2977 occur :winc l " change to the document window
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2978 endfunc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2979
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2980 func CloseIfLast()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2981 if exists("b:completePath") " this is how I determine that I'm
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2982 in an explorer window
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2983 let n = winnr() wincmd p if n == winnr()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2984 quit " quit the window
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2985 endif wincmd p
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2986 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2987 endfunc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2988
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2989 if has("autocmd")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2990 if !exists("rudyautocommands")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2991 let rudyautocommands = 1 autocmd VimEnter * call
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2992 OpenFileWindow() autocmd WinEnter * call CloseIfLast()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2993
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2994 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2995 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2996
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2997 </pre></tip> </html> <Tip category="KVim"> <html><center>Compiling
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2998 Java with Sun JDK (javac) within VIM</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2999 HREF="http://vim.sf.net/tip_view.php?tip_id=120">http://vim.sf.net/tip_view.php?tip_id=120</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3000
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3001 The $VIMRUNTIME/compiler has 'jikes.vim', but there's nothing for traditional
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3002 Sun JDK(javac), so I tried (Only tested on Win 2000):
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3003
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3004 " Vim Compiler File javac.vim " Compiler: Sun/IBM JDK: Javac
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3005
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3006 if exists("current_compiler")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3007 finish
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3008 endif let current_compiler = "javac"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3009
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3010 " Javac defaults to printing output on stderr and no options can convert,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3011 so we have to set 'shellpipe' setlocal shellpipe=2&gt; " 2&gt; works on Win
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3012 NT and UNIX setlocal makeprg=javac\ #&lt;.java setlocal errorformat=%f:%l:%m
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3013 " Sorry I'm not familiar with 'errorformat', so I set it very simple.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3014
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3015 </pre></tip> </html> <Tip category="KVim"> <html><center>Using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3016 vim as a syntax-highlighting pager</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3017 HREF="http://vim.sf.net/tip_view.php?tip_id=121">http://vim.sf.net/tip_view.php?tip_id=121</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3018
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3019 If you want to use Vim's syntax highlighting in a "more"-style pager, here's
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3020 one way to set it up:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3021
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3022 First, create a vimrc like the following -- I called mine ~/.vimrc.more
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3023
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3024 ---8&lt;---cut here---8&lt;--- " No compatibility -- necessary for mappings
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3025 to work. set nocompatible
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3026
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3027 " Status line set laststatus=0 set cmdheight=1 set nomodifiable "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3028 Only in version 6.0 set readonly
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3029
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3030 " Syntax colouring -- lines taken from syntax.txt discussion on colour xterms.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3031 " See ':help color-xterm'. Use appropriate lines for your own set-up.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3032 if has("terminfo")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3033 set t_Co=16 set t_Sf=[3%p1%dm set t_Sb=[4%p1%dm
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3034 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3035 set t_Co=16 set t_Sf=[3%dm set t_Sb=[4%dm
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3036 endif " My xterms have a navy-blue background, so I need this line too.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3037 set background=dark " Turn syntax on syntax on
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3038
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3039 " Key bindings. nmap b &lt;C-B&gt;&lt;C-G&gt; nmap q :q&lt;CR&gt; " To
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3040 type the following line, type *two* C-V's followed by two spaces. This "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3041 is how you map the spacebar. nmap ^V &lt;C-F&gt;&lt;C-G&gt; ---8&lt;---cut
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3042 here---8&lt;---
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3043
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3044 Then, to use this .vimrc, add an alias. If you're using tcsh, the syntax
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3045 will be something like:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3046
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3047 alias vmore "vim -u ~/.vimrc.more"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3048
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3049 Then you can type "vmore [filename]" to view a file in this "pager". Spacebar
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3050 will move down, 'b' will move back up, and 'q' quits. You can add mappings
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3051 for other keys if you want to, also.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3052
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3053 </pre></tip> </html> <Tip category="KVim"> <html><center>Skip
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3054 blank lines when folding text.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3055 HREF="http://vim.sf.net/tip_view.php?tip_id=122">http://vim.sf.net/tip_view.php?tip_id=122</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3056
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3057 I love the text folding capabilities of vim. I didn't like that it would
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3058 display the first line of the range as the "title" for the fold. I like
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3059 to write my comments with the "/*" on a line by itself. So I wrote this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3060 little function that will skip over anything that isn't a character, and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3061 then display whatever it finds after that character.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3062
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3063 Just include this in your ~/.vimrc (or ~/.gvimrc):
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3064
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3065 function GetFirstLineWithChars()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3066 let line_num = 0 let charline = matchstr(getline(v:foldstart),
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3067 '[a-zA-Z][a-zA-Z ]*') while strlen(charline) == 0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3068 let line_num = line_num + 1 let charline =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3069 matchstr(getline(v:foldstart + line_num), '[a-zA-Z][a-zA-Z ]*')
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3070 endw return charline
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3071 endfunction set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3072 foldtext='+'.v:folddashes.substitute(GetFirstLineWithChars(),'\\\/\\\/\\\|\\*\\\|\\*\\\|{{{\\d\\=','','g')
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3073 set fillchars=fold: hi folded guibg=black guifg=yellow gui=bold
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3074
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3075 And as an added bonus, for those new to text folding, add this to your .vimrc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3076 file too:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3077
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3078 autocmd BufWinLeave *.* mkview autocmd BufWinEnter *.* silent loadview
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3079
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3080 That way whatever folds you set won't get lost when you quit. I had that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3081 happen after spending 15 minutes folding up a 3000+ line file. Happy vimming!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3082
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3083 </pre></tip> </html> <Tip category="KVim"> <html><center>use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3084 functionality similar to the * search on multiple files</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3085 HREF="http://vim.sf.net/tip_view.php?tip_id=123">http://vim.sf.net/tip_view.php?tip_id=123</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3086
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3087 The use of star as in vimtip#1 and vimtip#5 is great, here is how to use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3088 this type of search accross a whole directory: Just add the mappings (or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3089 choose different letter combinations): map gr :grep &lt;cword&gt; *&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3090 map gr :grep &lt;cword&gt; %:p:h/*&lt;cr&gt; map gR :grep \b&lt;cword&gt;\b
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3091 *&lt;cr&gt; map GR :grep \b&lt;cword&gt;\b %:p:h/*&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3092
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3093 mapping one will search for the word under the cursor (like g*) in any of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3094 the files in the current directory mapping two will search for the word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3095 under the cursor (like g*) in any of the files in the same directory as the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3096 current file mapping three will search for the word under the cursor by itself
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3097 (i.e. surrounded by word boundary like *) in any of the files in the current
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3098 directory mapping four will search for the word under the cursor by itself
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3099 (i.e. surrounded by word boundary like *) in any of the files in the same
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3100 directory as the current file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3101
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3102 Benoit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3103
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3104 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3105 <html><center>Number a group of lines</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3106 HREF="http://vim.sf.net/tip_view.php?tip_id=124">http://vim.sf.net/tip_view.php?tip_id=124</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3107
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3108 Below is a way to number a set of lines. Here is an exaple before and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3109 after snapshot:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3110
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3111 apple bob pear tree
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3112
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3113 1 apple 2 bob 3 pear 4 tree
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3114
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3115 " Description: " This provides a command and a function. They both can be
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3116 called with or " without a range. In addition, they can be called with or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3117 without " arguments. Without a range they operate on the current line. " "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3118 There are two supported arguments. They are described below: " arg1 -&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3119 the number to start at. The default is one. This will " number
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3120 your selected lines sequentially. The start can be a " number,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3121 ., $, or, 'x (like getline). " arg2 -&gt; Text to append after numbers.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3122 The default is a space. " " Examples: " To provide your functionality:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3123 " :%Nlist 20 " :%call Nlist(20) " To make a list start at
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3124 1: " :'&lt;,'&gt;Nlist " :'&lt;,'&gt;call Nlist() " To
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3125 number the whole buffer (with it's actual line number): " :%Nlist "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3126 :%call Nlist() " To number a subset of lines with their line number (and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3127 put a '] ' in " front of every number): " :'&lt;,'&gt;Nlist . ]\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3128 " :'&lt;,'&gt;call Nlist(".", "] ")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3129
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3130 command! -nargs=* -range Nlist &lt;line1&gt;,&lt;line2&gt;call
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3131 Nlist(&lt;f-args&gt;) function! Nlist(...) range
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3132 if 2 == a:0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3133 let start = a:1 let append = a:2
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3134 elseif 1 == a:0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3135 let start = a:1 let append = " "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3136 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3137 let start = 1 let append = " "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3138 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3139
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3140 " try to work like getline (i.e. allow the user to pass in . $ or 'x)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3141 if 0 == (start + 0)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3142 let start = line(start)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3143 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3144
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3145 exe a:firstline . "," . a:lastline
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3146 . 's/^/\=line(".")-a:firstline+start.append/'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3147 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3148
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3149 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3150 <html><center>Auto commenting for "}"</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3151 HREF="http://vim.sf.net/tip_view.php?tip_id=125">http://vim.sf.net/tip_view.php?tip_id=125</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3152
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3153 I always wanted a script that would auto-comment the end of a conditional
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3154 block. So, I wrote one. This function searches for the previous matching
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3155 "{", grabs the line, and inserts it as a comment after the "}". If there
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3156 is no previous matching "{", it inserts nothing.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3157
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3158 So...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3159
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3160 if (test){
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3161
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3162 will generate:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3163 } // if (test)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3164
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3165 This is obviously not work if you use a different style. If you use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3166
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3167 if (test) {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3168
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3169 then substituting 'getline(".")', use 'getline(line(".") - 1)' should work.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3170
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3171 Put the following in your .vimrc: au BufNewFile,BufRead *.c,*.cc,*.C,*.h
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3172 imap } &lt;ESC&gt;:call CurlyBracket()&lt;CR&gt;a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3173
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3174 function CurlyBracket()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3175 let l:my_linenum = line(".") iunmap } sil exe "normal i}" imap }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3176 &lt;ESC&gt;:call CurlyBracket()&lt;CR&gt; let l:result1 = searchpair('{',
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3177 '', '}', 'bW') if (result1 &gt; 0)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3178 let l:my_string = substitute(getline("."), '^\s*\(.*\){', '\1', "")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3179 sil exe ":" . l:my_linenum sil exe "normal a //" . l:my_string
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3180 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3181 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3182
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3183 </pre></tip> </html> <Tip category="KVim"> <html><center>how do
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3184 I get rid of that bold stuff with my xterm?</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3185 HREF="http://vim.sf.net/tip_view.php?tip_id=126">http://vim.sf.net/tip_view.php?tip_id=126</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3186
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3187 Having problems setting up your syntax highlighting because everything is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3188 coming up in bold?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3189
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3190 You're probably using an 8 color xterm and setting up highlighting lines such
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3191 as hi Normal ... ctermfg=green . The solution: use numbers! 0=black, 1=red,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3192 2=green, 3=yellow, 4=blue, 5=magenta, 6=cyan, and 7=white. Vim tries to use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3193 "bright" colors when its given names (because Windoz machines prefer to use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3194 dim text unless its been made bold).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3195
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3196 Read more about it under :help highlight-ctermfg .
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3197
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3198 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3199 <html><center>Preview HTML files quickly</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3200 HREF="http://vim.sf.net/tip_view.php?tip_id=127">http://vim.sf.net/tip_view.php?tip_id=127</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3201
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3202 I've found while writing HTML files that it can become cumbersome when I have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3203 to switch to a web browser, load my page, and move back to VIM regularly to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3204 preview what I've written. I've come up with the following tricks.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3205
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3206 The first one requires that you have lynx (the text-based browser) installed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3207 on your computer (available from <A HREF="http://lynx.isc.org/release/).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3208 If your HTML page is primarily text, with few (if any) images, you can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3209 set up the following function and mapping:">http://lynx.isc.org/release/).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3210 If your HTML page is primarily text, with few (if any) images, you can set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3211 up the following function and mapping:</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3212
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3213 function PreviewHTML_TextOnly()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3214 let l:fname = expand("%:p" ) new set buftype=nofile nonumber exe "%!lynx
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3215 " . l:fname . " -dump -nolist -underscore -width " . winwidth( 0 )
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3216 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3217
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3218 map &lt;Leader&gt;pt :call PreviewHTML_TextOnly()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3219
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3220 This will open a new window and display your formatted HTML document in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3221 that window. Note that bold-face, italics, links, etc. will be lost --
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3222 all you will see is the text -- but the "-underscore" parameter to Lynx
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3223 causes any text that would have been bold, italicized, or underlined to be
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3224 displayed like _this_.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3225
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3226 The other trick requires that vim be running on your current machine, and that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3227 you be running a GUI of some sort (X-Windows, Windows, etc.). You can cause
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3228 vim to invoke your favorite browser and have it display the file, like this:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3229 function PreviewHTML_External()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3230 exe "silent !mozilla -remote \"openurl(file://" . expand( "%:p" ) . ")\""
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3231 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3232
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3233 map &lt;Leader&gt;pp :call PreviewHTML_External()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3234 If you don't use mozilla, you will need to modify the function to use your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3235 preferred browser.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3236
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3237 Happy vimming!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3238
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3239 </pre></tip> </html> <Tip category="KVim"> <html><center>grep,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3240 diff, patch, idutils, etc. for Windows systems</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3241 HREF="http://vim.sf.net/tip_view.php?tip_id=128">http://vim.sf.net/tip_view.php?tip_id=128</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3242
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3243 If you use Vim on Windows, and you wish you had some of those nifty
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3244 UNIX command-line tools,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3245 but do not feel like installing all of Cygwin, you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3246 can get many of the most-used tools from Ron Aaron's web site: <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3247 HREF="http://www.mossbayeng.com/~ron/vim/builds.html">http://www.mossbayeng.com/~ron/vim/builds.html</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3248 Since Ron is a big Vim fan (see <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3249 HREF="http://www.mossbayeng.com/~ron/vim/vimrant.html ) you can count
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3250 on">http://www.mossbayeng.com/~ron/vim/vimrant.html ) you can count on</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3251 these tools' working well with Vim. For some hints on how to use them,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3252 read :help :grep :help lid inside Vim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3253 Happy Vimming!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3254
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3255 </pre></tip> </html> <Tip category="KVim"> <html><center>Removing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3256 automatic comment leaders</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3257 HREF="http://vim.sf.net/tip_view.php?tip_id=129">http://vim.sf.net/tip_view.php?tip_id=129</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3258
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3259 If you include the "r" flag in the 'formatoptions' option (:help 'fo'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3260 , :help fo-table ) then the comment leader is inserted
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3261 automatically when you start a new line in a comment. For example, in TeX
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3262 the "%" character is the comment leader, and you might type
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3263
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3264 % This is a tex file. % The comment leaders on all lines but the first
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3265 were generated automatically. % This is the last line of the comment,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3266 but Vim will insert the comment leader on the next line. %
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3267
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3268 You can get rid of the comment leader (along with anything you may already
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3269 have typed on the line) without affecting the indent, if any, by typing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3270 "&lt;C-U&gt;" while in Insert mode.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3271
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3272 Related point: if you want to adjust the indent while in Insert mode,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3273 you can use "&lt;C-D&gt;" (to Decrease the indent)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3274 or "&lt;C-T&gt;" (to increase it). In the docs for Vim 6.0, this is described
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3275 in the users' manual, :help 30.4 .
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3276
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3277 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3278 <html><center>disabling default ftplugins</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3279 HREF="http://vim.sf.net/tip_view.php?tip_id=130">http://vim.sf.net/tip_view.php?tip_id=130</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3280
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3281 For an overview of ftplugins (filetype plugins) see
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3282
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3283 :help ftplugins
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3284
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3285 If you want to disable all ftplugins, or disable a particular default
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3286 ftplugin, see
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3287
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3288 :help :filetype :help ftplugin-overrule
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3289
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3290 If you have your own ftplugins, and you want to disable all the default
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3291 ones, then do NOT include a check for b:did_ftplugin in your ftplugin files,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3292 and add the line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3293
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3294 :autocmd BufEnter * let b:did_ftplugin = 1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3295
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3296 to your VIMRC file, BEFORE the ":filetype ftplugin on" line.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3297
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3298 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3299 <html><center>Scroll alternate window</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3300 HREF="http://vim.sf.net/tip_view.php?tip_id=131">http://vim.sf.net/tip_view.php?tip_id=131</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3301
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3302 This mapping allow you to quickly scroll inactive window when displaying
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3303 several windows concurrently.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3304
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3305 nmap &lt;silent&gt; &lt;M-Down&gt; :call ScrollOtherWindow("down")&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3306 nmap &lt;silent&gt; &lt;M-Up&gt; :call ScrollOtherWindow("up")&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3307
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3308 fun! ScrollOtherWindow(dir)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3309 if a:dir == "down"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3310 let move = "\&lt;C-E&gt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3311 elseif a:dir == "up"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3312 let move = "\&lt;C-Y&gt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3313 endif exec "normal \&lt;C-W&gt;p" . move . "\&lt;C-W&gt;p"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3314 endfun
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3315
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3316 PS: Original idea and discussion of this tip appeared on vim@vim.org mailing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3317 list, I'm just prettified it a little.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3318
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3319 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3320 <html><center>window zooming convenience</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3321 HREF="http://vim.sf.net/tip_view.php?tip_id=132">http://vim.sf.net/tip_view.php?tip_id=132</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3322
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3323 i frequently have multiple windows open in vim -- this reduces the number
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3324 of lines each window displays -- i almost always have my windows either all
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3325 the same size or the current one as big as possible.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3326
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3327 the following function can be toggled on or off by typing &lt;Leader&gt;max
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3328 (i can do this quite quickly); just change the mapping at the bottom to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3329 something else if you prefer.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3330
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3331 this causes the current window to be as big as possible (moving into another
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3332 window causes that one to become big) and all the others get very small.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3333 i actually use this ALL the time. turning it off (by typing the hotkey
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3334 sequence again) will cause all windows to have the same height.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3335
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3336 "toggles whether or not the current window is automatically zoomed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3337 function! ToggleMaxWins ()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3338 if exists ('g:windowMax')
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3339 au! maxCurrWin exe "normal \&lt;c-w&gt;=" unlet g:windowMax
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3340 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3341 augroup maxCurrWin " au BufEnter * exe "normal
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3342 \&lt;c-w&gt;_\&lt;c-w&gt;\&lt;bar&gt;" " " only max it vertically
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3343 au! BufEnter * exe "normal \&lt;c-w&gt;_" augroup END do maxCurrWin
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3344 BufEnter let g:windowMax=1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3345 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3346 endfunction map &lt;Leader&gt;max :call ToggleMaxWins ()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3347
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3348 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3349 <html><center>Windo and Bufdo</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3350 HREF="http://vim.sf.net/tip_view.php?tip_id=133">http://vim.sf.net/tip_view.php?tip_id=133</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3351
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3352 i like bufdo and windo but i don't like the fact that the commands end in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3353 a different window/buffer than from where i executed them. these versions
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3354 (starts with a capital letter) will restore the current window or buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3355 when the command's done.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3356
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3357 for example, to turn on line numbers everywhere, i use :Windo set nu --
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3358 :windo set nu does the trick also but leaves me in a different window than
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3359 where i started.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3360
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3361 " just like windo but restores the current window when it's done
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3362 function! WinDo(command)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3363 let currwin=winnr() execute 'windo ' . a:command execute currwin . 'wincmd w'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3364 endfunction com! -nargs=+ -complete=command Windo call WinDo(&lt;q-args&gt;)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3365
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3366 " just like bufdo but restores the current buffer when it's done
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3367 function! BufDo(command)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3368 let currBuff=bufnr("%") execute 'bufdo ' . a:command execute 'buffer '
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3369 . currBuff
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3370 endfunction com! -nargs=+ -complete=command Bufdo call BufDo(&lt;q-args&gt;)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3371
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3372 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3373 <html><center>View Source in IE6 using VIM</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3374 HREF="http://vim.sf.net/tip_view.php?tip_id=134">http://vim.sf.net/tip_view.php?tip_id=134</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3375
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3376 You can change the "View Source" editor of IE6 by adding the following to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3377 the Windows Registry. Change the path in case you installed VIM in another
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3378 location.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3379
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3380 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3381 Editor\Editor Name] @="C:\\vim\\vim60\\gvim.exe"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3382
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3383 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3384 <html><center>Vim buffer FAQ</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3385 HREF="http://vim.sf.net/tip_view.php?tip_id=135">http://vim.sf.net/tip_view.php?tip_id=135</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3386
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3387 Vim provides various commands and options to support editing multiple buffers.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3388 This document covers some of the questions asked about using multiple buffers
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3389 with Vim. You can get more detailed information about Vim buffer support using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3390 ":help windows.txt" in Vim. You can also use the help keywords mentioned in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3391 this document to read more about a particular command or option. To read more
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3392 about a particular command or option use, ":help &lt;helpkeyword&gt;" in Vim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3393
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3394 1. What is a Vim buffer?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3395 A buffer is a file loaded into memory for editing. All opened files
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3396 are associated with a buffer. There are also buffers not associated with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3397 any file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3398
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3399 Help keyword(s): windows-intro
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3400
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3401 2. How do I identify a buffer?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3402 Vim buffers are identified using a name and a number. The name of the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3403 buffer is the name of the file associated with that buffer. The buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3404 number is a unique sequential number assigned by Vim. This buffer number
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3405 will not change in a single Vim session.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3406
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3407 Help keyword(s): :buffers
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3408
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3409 3. How do I create a buffer?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3410 When you open a file using any of the Vim commands, a buffer is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3411 automatically created. For example, if you use the ":edit file" command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3412 to edit a file, a new buffer is automatically created.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3413
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3414 4. How do I add a new buffer for a file to the buffer list without opening
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3415 the file? You can add a new buffer for a file without opening it, using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3416 the ":badd" ex command. For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3417
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3418 :badd f1.txt :badd f2.txt
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3419
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3420 The above commands will add two new buffers for the files f1.txt and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3421 f2.txt to the buffer list.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3422
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3423 Help keyword(s): :badd
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3424
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3425 5. How do I get a list of all the existing buffers?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3426 You can get a list of all the existing buffers using the ":buffers" or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3427 ":ls" or ":files" ex command. This list is called the 'buffer list'.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3428
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3429 In Vim 6.0, to display all the buffers including unlisted buffers, use the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3430 ":buffers!" or ":ls!" or ":files!" ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3431
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3432 Help keyword(s): :buffers, :ls, :files
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3433
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3434 6. How do I delete a buffer?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3435 You can delete a buffer using the ":bdelete" ex command. You can use either
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3436 the buffer name or the buffer number to specify a buffer. For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3437
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3438 :bdelete f1.txt :bdelete 4
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3439
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3440 The above commands will delete the buffer named "f1.txt" and the fourth
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3441 buffer in the buffer list. The ":bdelete" command will remove the buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3442 from the buffer list.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3443
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3444 In Vim 6.0, when a buffer is deleted, the buffer becomes an unlisted-buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3445 and is no longer included in the buffer list. But the buffer name and other
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3446 information associated with the buffer is still remembered. To completely
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3447 delete the buffer, use the ":bwipeout" ex command. This command will remove
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3448 the buffer completely (i.e. the buffer will not become a unlisted buffer).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3449
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3450 Help keyword(s): :bdelete, :bwipeout
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3451
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3452 7. How do I delete multiple buffers?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3453 You can delete multiple buffers in several ways:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3454
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3455 1. Pass a range argument to the ":bdelete" command. For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3456
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3457 :3,5bdelete
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3458
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3459 This command will delete the buffers 3, 4 and 5.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3460 2. Pass multiple buffer names to the ":bdelete" command. For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3461
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3462 :bdelete buf1.txt buf2.c buf3.h
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3463
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3464 This command will delete buf1.txt, buf2.c and buf3.h buffers. In this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3465 example, after typing ":bdelete buf", you can press &lt;Ctrl-A&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3466 to expand all the buffer names starting with 'buf'.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3467
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3468 Help keyword(s): :bdelete, :bwipeout
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3469
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3470 8. How do I remove a buffer from a window?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3471 You can remove a buffer displayed in a window in several ways:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3472
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3473 1. Close the window or edit another buffer/file in that window. 2. Use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3474 the ":bunload" ex command. This command will remove the buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3475 from the window and unload the buffer contents from memory. The buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3476 will not be removed from the buffer list.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3477
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3478 Help keyword(s): :bunload
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3479
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3480 9. How do I edit an existing buffer from the buffer list?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3481 You can edit or jump to a buffer in the buffer list in several ways:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3482
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3483 1. Use the ":buffer" ex command passing the name of an existing buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3484 or the buffer number. Note that buffer name completion can be used
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3485 here by pressing the &lt;Tab&gt; key.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3486 2. You can enter the buffer number you want to jump/edit and press the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3487 Ctrl-^ key.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3488 3. Use the ":sbuffer" ex command passing the name of the buffer or the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3489 buffer number. Vim will split open a new window and open the specified
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3490 buffer in that window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3491 4. You can enter the buffer number you want to jump/edit and press the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3492 Ctrl-W ^ or Ctrl-W Ctrl-^ keys. This will open the specified buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3493 in a new window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3494
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3495 Help keyword(s): :buffer, :sbuffer, CTRL-W_^, CTRL-^
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3496
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3497 10. How do I browse through all the available buffers?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3498 You can browse through the buffers in the buffer list in several ways:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3499
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3500 1. To jump to the first buffer in the buffer list, use the ":bfirst" or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3501 ":brewind" ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3502 2. To jump to the first buffer in the buffer list in a new window, use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3503 the ":sbfirst" or ":sbrewind" ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3504 3. To edit the next buffer in the buffer list, use the ":bnext" ex
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3505 command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3506 4. To open the next buffer in the buffer list in a new window, use the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3507 ":sbnext" ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3508 5. To edit the previous buffer in the buffer list, use the ":bprevious"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3509 or ":bNext" ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3510 6. To open the previous buffer in the buffer list in a new window, use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3511 the ":sbprevious" or ":sbNext" ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3512 7. To open the last buffer in the buffer list, use the ":blast" ex
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3513 command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3514 8. To open the last buffer in the buffer list in a new window, use the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3515 ":sblast" ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3516
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3517 Help keyword(s): :bfirst, :brewind, :sbfirst, :sbrewind, :bnext,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3518 :sbnext, :bprevious, :bNext, :sbprevious, :sbNext,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3519 :blast, :sblast
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3520
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3521 11. How do I open all the buffers in the buffer list?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3522 You can open all the buffers present in the buffer list using the ":ball"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3523 or ":sball" ex commands.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3524
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3525 Help keyword(s): :ball, :sball
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3526
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3527 12. How do I open all the loaded buffers?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3528 You can open all the loaded buffers in the buffer list using the ":unhide"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3529 or ":sunhide" ex commands. Each buffer will be loaded in a separate
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3530 new window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3531
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3532 Help keyword(s): :unhide, :sunhide
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3533
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3534 13. How do I open the next modified buffer?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3535 You can open the next or a specific modified buffer using the ":bmodified"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3536 ex command. You can open the next or a specific modified buffer in a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3537 new window using the ":sbmodified" ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3538
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3539 Help keyword(s): :bmodified, :sbmodified
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3540
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3541 14. I am using the GUI version of Vim (gvim), is there a simpler way for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3542 using the buffers instead of the ex commands? Yes. In the GUI version of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3543 Vim, you can use the 'Buffers' menu, which simplifies the use of buffers.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3544 All the buffers in the buffer list are listed in this menu. You can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3545 select a buffer name from this menu to edit the buffer. You can also
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3546 delete a buffer or browse the buffer list.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3547
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3548 Help keyword(s): buffers-menu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3549
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3550 15. Is there a Vim script that simplifies using buffers with Vim?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3551 Yes. You can use the bufexplorer.vim script to simplify the process of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3552 using buffers. You can download the bufexplorer script from:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3553
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3554 <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3555 HREF="http://lanzarotta.tripod.com/vim.html">http://lanzarotta.tripod.com/vim.html</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3556
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3557 16. Is it possible to save and restore the buffer list across Vim sessions?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3558 Yes. To save and restore the buffer list across Vim session, include the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3559 '%' flag in the 'viminfo' option. Note that if Vim is invoked with a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3560 filename argument, then the buffer list will not be restored from the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3561 last session. To use buffer lists across sessions, invoke Vim without
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3562 passing filename arguments.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3563
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3564 Help keyword(s): 'viminfo', viminfo
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3565
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3566 17. How do I remove all the entries from the buffer list?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3567 You can remove all the entries in the buffer list by starting Vim with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3568 a file argument. You can also manually remove all the buffers using the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3569 ":bdelete" ex command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3570
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3571 18. What is a hidden buffer?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3572 A hidden buffer is a buffer with some unsaved modifications and is not
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3573 displayed in a window. Hidden buffers are useful, if you want to edit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3574 multiple buffers without saving the modifications made to a buffer while
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3575 loading other buffers.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3576
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3577 Help keyword(s): :buffer-!, 'hidden', hidden-buffer, buffer-hidden
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3578
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3579 19. How do I load buffers in a window, which currently has a buffer with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3580 unsaved modifications? By setting the option 'hidden', you can load
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3581 buffers in a window that currently has a modified buffer. Vim will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3582 remember your modifications to the buffer. When you quit Vim, you will be
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3583 asked to save the modified buffers. It is important to note that, if you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3584 have the 'hidden' option set, and you quit Vim forcibly, for example using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3585 ":quit!", then you will lose all your modifications to the hidden buffers.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3586
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3587 Help keyword(s): 'hidden'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3588
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3589 20. Is it possible to unload or delete a buffer when it becomes hidden?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3590 The following works only in Vim 6.0 and above. By setting the 'bufhidden'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3591 option to either 'hide' or 'unload' or 'delete', you can control what
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3592 happens to a buffer when it becomes hidden. When 'bufhidden' is set to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3593 'delete', the buffer is deleted when it becomes hidden. When 'bufhidden'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3594 is set to 'unload', the buffer is unloaded when it becomes hidden.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3595 When 'bufhidden' is set to 'hide', the buffer is hidden.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3596
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3597 Help keyword(s): 'bufhidden'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3598
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3599 21. How do I execute a command on all the buffers in the buffer list?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3600 In Vim 6.0, you can use the ":bufdo" ex command to execute an ex command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3601 on all the buffers in the buffer list.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3602
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3603 Help keyword(s): :bufdo
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3604
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3605 22. When I open an existing buffer from the buffer list, if the buffer is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3606 already displayed in one of the existing windows, I want Vim to jump to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3607 that window instead of creating a new window for this buffer. How do I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3608 do this? When opening a buffer using one of the split open buffer commands
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3609 (:sbuffer, :sbnext), Vim will open the specified buffer in a new window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3610 If the buffer is already opened in one of the existing windows, then
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3611 you will have two windows containing the same buffer. You can change
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3612 this behavior by setting the 'switchbuf' option to 'useopen'. With this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3613 setting, if a buffer is already opened in one of the windows, Vim will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3614 jump to that window, instead of creating a new window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3615
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3616 Help keyword(s): 'switchbuf'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3617
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3618 23. What information is stored as part of a buffer?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3619 Every buffer in the buffer list contains information about the last
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3620 cursor position, marks, jump list, etc.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3621
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3622 24. What is the difference between deleting a buffer and unloading a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3623 buffer? When a buffer is unloaded, it is not removed from the buffer list.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3624 Only the file contents associated with the buffer are removed from memory.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3625 When a buffer is deleted, it is unloaded and removed from the buffer list.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3626 In Vim 6, a deleted buffer becomes an 'unlisted' buffer.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3627
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3628 Help keyword(s): :bunload, :bdelete, :bwipeout, unlisted-buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3629
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3630 25. Is it possible to configure Vim, by setting some option, to re-use the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3631 number of a deleted buffer for a new buffer? No. Vim will not re-use the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3632 buffer number of a deleted buffer for a new buffer. Vim will always assign
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3633 the next sequential number for a new buffer. The buffer number assignment
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3634 is implemented this way, so that you can always jump to a buffer using the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3635 same buffer number. One method to achieve buffer number reordering is to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3636 restart Vim. If you restart Vim, it will re-assign numbers sequentially
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3637 to all the buffers in the buffer list (assuming you have properly set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3638 'viminfo' to save and restore the buffer list across vim sessions).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3639
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3640 Help keyword(s): :buffers
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3641
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3642 26. What options do I need to set for a scratch (temporary) buffer?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3643 The following works only in Vim 6.0 and above. You can set the the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3644 following options to create a scratch (temporary) buffer:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3645
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3646 :set buftype=nofile :set bufhidden=hide :setlocal noswapfile
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3647
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3648 This will create a buffer which is not associated with a file, which
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3649 does not have a associated swap file and will be hidden when removed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3650 from a window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3651
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3652 Help keyword(s): special-buffers, 'buftype'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3653
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3654 27. How do I prevent a buffer from being added to the buffer list?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3655 The following works only in Vim 6.0 and above. You can prevent a buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3656 from being added to the buffer list by resetting the 'buflisted' option.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3657
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3658 :set nobuflisted
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3659
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3660 Help keyword(s): 'buflisted'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3661
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3662 28. How do I determine whether a buffer is modified or not?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3663 There are several ways to find out whether a buffer is modified or not.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3664 The simplest way is to look at the status line or the title bar. If the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3665 displayed string contains a '+' character, then the buffer is modified.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3666 Another way is to check whether the 'modified' option is set or not.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3667 If 'modified' is set, then the buffer is modified. To check the value
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3668 of modified, use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3669
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3670 :set modified?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3671
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3672 You can also explicitly set the 'modified' option to mark the buffer as
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3673 modified like this:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3674
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3675 :set modified
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3676
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3677 Help keyword(s): 'modified'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3678
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3679 29. How can I prevent modifications to a buffer?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3680 The following works only in Vim 6.0 and above. You can prevent any
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3681 modification to a buffer by re-setting the 'modifiable' option. To reset
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3682 this option, use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3683
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3684 :set nomodifiable
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3685
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3686 To again allow modifications to the buffer, use:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3687
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3688 :set modifiable
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3689
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3690 Help keyword(s): 'modifiable'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3691
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3692 30. How do I set options specific to the current buffer?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3693 The following works only in Vim 6.0 and above. You can set Vim options
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3694 which are specific to a buffer using the "setlocal" command. For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3695
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3696 :setlocal textwidth=70
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3697
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3698 This will set the 'textwidth' option to 70 only for the current buffer.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3699 All other buffers will have the default or the previous 'textwidth' value.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3700
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3701 Help keyword(s): 'setlocal', local-options
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3702
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3703 31. How do I define mappings specific to the current buffer?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3704 The following works only in Vim 6.0 and above. You can define mappings
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3705 specific to the current buffer by using the keyword "&lt;buffer&gt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3706 in the map command. For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3707
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3708 :map &lt;buffer&gt; ,w /[.,;]&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3709
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3710 Help keyword(s): :map-local
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3711
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3712 32. How do I define abbreviations specific to the current buffer?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3713 The following works only in Vim 6.0 and above. You can define
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3714 abbreviations specific to the current buffer by using the keyword
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3715 "&lt;buffer&gt;" in the :abbreviate command. For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3716
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3717 :abb &lt;buffer&gt; FF for (i = 0; i &lt; ; ++i)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3718
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3719 Help keyword(s): :abbreviate-local
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3720
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3721 </pre></tip> </html> <Tip category="KVim"> <html><center>Remapping
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3722 Alt, Ctrl and Caps in Win2k</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3723 HREF="http://vim.sf.net/tip_view.php?tip_id=136">http://vim.sf.net/tip_view.php?tip_id=136</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3724
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3725 Since I installed Win2K on my laptop, I had been unable to locate a utilitie
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3726 that would simply enable me to remap my Crtl Alt and Caps the way I think they
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3727 should be and the way they were until MS kill all competition in computing,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3728 that is Crtl on the left of the letter A, Alt to the left bottom of the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3729 letter Z and Caps approximately until the C.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3730
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3731 After some research, I came across a tip posted here by juano@mindspring.com. I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3732 tried to make sense of it and then downloaded the MS scan keys map at the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3733 URL he mentionned.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3734
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3735 Extrapolating his tip, I wrote this ASCI file that I named keys2000.reg :
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3736
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3737 Regedit4 [HKey_Local_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3738 Layout] "Scancode
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3739 Map"=hex:00,00,00,00,00,00,00,00,04,00,00,00,3A,00,38,00,38,00,1D,00,1D,00,3A,00,00,00,00
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3740
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3741 Once you have saved this file, left click on it from Explorer and answer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3742 yes to the prompt "do you want to enter this into the registry".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3743
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3744 Reboot and you are done.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3745
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3746 A few explanations :04 stands for 3 remappings (Caps lock to Control, Control
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3747 to Alt and Alt to Caps Lock) plus the closing one which is always required
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3748 (1 remapping would require 02, 2 would require 03, and so on). 3A,00,38
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3749 remaps Caps to Left Alt, 38,00,1D remaps Left Alt to Left Ctrl and 1D,00,3A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3750 remaps Left Ctrl to Caps Lock since 3A=Caps, 1D=Left Ctrl and 38=Left Alt.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3751
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3752 Based on Juano tip and on this one, I believe a lot of remapping can be done
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3753 as long as you keep the separators 00 and remember to add one to the number
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3754 of remappings. What I do not know is how far you can extend this instruction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3755 without getting into trouble with the registry. At worst, if you keyboard does
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3756 not behave as expected, go into the registry and delete this instruction (be
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3757 careful here since it is easy to confuse this instruction with the Keyboard
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3758 LayoutS (S for emphasis) which must not be deleted.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3759
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3760 Again, thanks to Juano@mindspring.com who got me going and suggested I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3761 post my tip. Took me some time to retrieve the VIM Url but fortunately,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3762 I had printed his tip.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3763
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3764 Regards
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3765
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3766 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3767 <html><center>automatically wrap left and right</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3768 HREF="http://vim.sf.net/tip_view.php?tip_id=137">http://vim.sf.net/tip_view.php?tip_id=137</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3769
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3770 I hate it when I hit left (or h) and my screen flickers. I want it to go up
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3771 to the next line. Ditto fir right (or l). Below are two functions / mappings
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3772 to help with that. I'm pretty sure that if you remove the &lt;silent&gt;,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3773 then it will work in 5.x...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3774
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3775 nnoremap &lt;silent&gt; &lt;Left&gt; :call WrapLeft()&lt;cr&gt; nnoremap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3776 &lt;silent&gt; &lt;Right&gt; :call WrapRight()&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3777
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3778 nnoremap &lt;silent&gt; h :call WrapLeft()&lt;cr&gt; nnoremap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3779 &lt;silent&gt; l :call WrapRight()&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3780
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3781 function! WrapLeft()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3782 let col = col(".")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3783
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3784 if 1 == col
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3785 " don't wrap if we're on the first line if 1 == line(".")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3786 return
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3787 endif normal! k$
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3788 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3789 normal! h
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3790 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3791 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3792
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3793 function! WrapRight()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3794 let col = col(".") if 1 != col("$")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3795 let col = col + 1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3796 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3797
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3798 if col("$") == col
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3799 " don't wrap if we're on the last line if line("$") == line(".")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3800 return
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3801 endif normal! j1|
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3802 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3803 normal! l
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3804 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3805 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3806
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3807 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3808 <html><center>Getting name of the function</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3809 HREF="http://vim.sf.net/tip_view.php?tip_id=138">http://vim.sf.net/tip_view.php?tip_id=138</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3810
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3811 Hi All,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3812
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3813 While browsing code one always needs to know which function you are currently
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3814 looking. Getting the name is very painful when the functions are lengthy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3815 and you are currently browsing NOT near to the start of the function. You
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3816 can get the function's name by using this simple mapping.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3817
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3818 Just place this in your .vimrc.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3819
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3820 map _F ma[[k"xyy`a:echo @x&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3821
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3822 now _F will display which function you are currently in.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3823
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3824 Enjoy the power of Vim -Nitin Raut
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3825
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3826 PS: The working is as follows, mark the current line with a, jump to the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3827 previous '{' in the first column, go one line up, yank the line in register
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3828 x, return to the mark a, echo the value of register x, which is the wanted
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3829 function name.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3830
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3831 </pre></tip> </html> <Tip category="KVim"> <html><center>=,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3832 LaTeX tables, declarations, etc</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3833 HREF="http://vim.sf.net/tip_view.php?tip_id=139">http://vim.sf.net/tip_view.php?tip_id=139</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3834
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3835 Check out
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3836
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3837 <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3838 HREF="http://www.erols.com/astronaut/vim/textab.html">http://www.erols.com/astronaut/vim/textab.html</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3839
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3840 and see some examples of text alignment (its hopeless to do it here with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3841 proportional fonts). You'll be able to download textab source, a Windows-based
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3842 textab executable, and a scriptfile containing a convenient interface
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3843 (ttalign.vim). The textab program coupled with &lt;ttalign.vim&gt; lets you:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3844
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3845 1. align C language statements on their = += -= /= etc symbols 2. align C
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3846 language declararations: separate columns for types, *[, variable
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3847 names, initializations (=), and comments (// or /* .. */)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3848 3. align C/C++ language comments (//, /* .. */) 4. align C/C++ language
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3849 (ansi) function argument lists 5. align LaTeX tables on their && separators
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3850 6. align HTML tables with &lt;/TD&gt;&lt;TD&gt; separators 7. align on
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3851 several characters: &lt; ? : | @ ; (or modify them to handle whatever
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3852 alignment characters you want)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3853
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3854 </pre></tip> </html> <Tip category="KVim"> <html><center>tip
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3855 using embedded perl interpreter</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3856 HREF="http://vim.sf.net/tip_view.php?tip_id=140">http://vim.sf.net/tip_view.php?tip_id=140</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3857
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3858 When writing scripts using the embedded interpreter available if vim has the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3859 +perl ore +perl/dyn on gives you access to this powerfull and FAST scripting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3860 language (especially fast compared to vim scripts) there are some gotchas.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3861
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3862 First: never embed complex perl command in the body of a vim function this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3863 will be recompiled and evaled each time for a tremendous loss of time.instead
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3864 to it like this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3865
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3866 perl &lt;&lt; EOF sub mySub {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3867 #some usefull perl stuff
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3868 } EOF
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3869
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3870 function! MyFunction perl mySub "an argument", "another" endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3871
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3872 to pass computed argument to your perl sub use the vim exec command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3873 function! MyFunction exec "perl mySub " . aLocalVar . ", " b:aBufferLocalVar
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3874 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3875
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3876 It may be very hard to debug your perl sub since the output of the perl
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3877 compiler is somehow lost in the middle of nowhere and the debugger is not
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3878 available. When a compilation error occurs in your sub definition you'll get
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3879 an error message when you try to call it saying that the sub does not exists.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3880 One thing which I have found very usefull is to write a fake VIM module with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3881 stub methods which will allow you to use the command line perl interpretor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3882 to at least compile your program. You could make your stub smart enough to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3883 fake a vim and use the debugger. Here is a sample for such a fake module
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3884 defining just those method which I was using.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3885
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3886 package VIM; use diagnostics; use strict; sub VIM::Eval {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3887 $_ = shift;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3888
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3889 print "Eval $_\n";
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3890
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3891 {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3892 return
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3893 '^(?!!)([^\t]*)\t[^\t]*\t(.*);"\t([^\t]*)\tline:(\d*).*$'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3894 if (/g:TagsBase_pattern/); return $ARGV[0] if
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3895 (/b:fileName/); return '$3' if (/g:TagsBase_typePar/);
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3896 return '$1' if (/g:TagsBase_namePar/); return '$4' if
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3897 (/g:TagsBase_linePar/); return 'Ta&gs' if (/s:menu_name/);
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3898 return $ARGV[1] if (/g:TagsBase_groupByType/);
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3899 die "unknown eval $_";
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3900 }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3901 } sub VIM::Msg {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3902 my $msg = shift; print "MSG $msg\n";
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3903 } sub VIM::DoCommand {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3904 my $package; my $filename; my $line;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3905 ($package, $filename, $line) = caller;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3906
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3907 my $command = shift; print "at $filename $line\n"; print "DoCommand
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3908 $command\n";
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3909 } 1;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3910
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3911 Then you can copy other your perl code in a separate file and add a use VIM;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3912 at the top and your set to debug.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3913
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3914 Good Vimming good perling. Benoit PS: this tips are probably true for other
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3915 scripting languages
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3916
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3917 </pre></tip> </html> <Tip category="KVim"> <html><center>Add
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3918 your function heading with a keystroke</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3919 HREF="http://vim.sf.net/tip_view.php?tip_id=141">http://vim.sf.net/tip_view.php?tip_id=141</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3920
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3921 Below is a tip that the C/C++ Newbies may find interesting and handy to use.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3922 The following code will add a function heading and position your cursor just
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3923 after Description so that one can document as one proceeds with code.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3924
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3925 function FileHeading()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3926 let s:line=line(".") call
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3927 setline(s:line,"/***************************************************")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3928 call append(s:line,"* Description - ") call append(s:line+1,"*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3929 Author - Mohit Kalra") call append(s:line+2,"* Date
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3930 - ".strftime("%b %d %Y")) call append(s:line+3,"*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3931 *************************************************/") unlet s:line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3932 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3933
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3934 imap &lt;F4&gt; &lt;esc&gt;mz:execute FileHeading()&lt;RET&gt;`zjA
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3935
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3936 Where &lt;esc&gt; stands for ^V+ESC and &lt;RET&gt; for ^V+ENTER
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3937
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3938 </pre></tip> </html> <Tip category="KVim"> <html><center>Automatic
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3939 function end commenting for C++ and Java</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3940 HREF="http://vim.sf.net/tip_view.php?tip_id=142">http://vim.sf.net/tip_view.php?tip_id=142</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3941
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3942 Some people have a habit of adding the function name as a comment to the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3943 end of that function, if it is long, so that he/she knows which function the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3944 '}' ends. Here's a way to automate the process.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3945
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3946 Use the following abbreviation: iab }// } // END:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3947 &lt;esc&gt;10h%$?\w\+\s*(&lt;cr&gt;"xy/\s*(&lt;cr&gt;/{&lt;cr&gt;:nohl&lt;cr&gt;%$"xpa
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3948
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3949 If you now end the function with '}//', the follwoing string will be
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3950 automatically generated: '} //END: functionname'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3951
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3952 </pre></tip> </html> <Tip category="KVim"> <html><center>Use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3953 of Vim folds for javadocs</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3954 HREF="http://vim.sf.net/tip_view.php?tip_id=143">http://vim.sf.net/tip_view.php?tip_id=143</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3955
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3956 Hi,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3957
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3958 The fold-method marker can be effectively use to set the folds in your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3959 Java source. Define some marker and place it inside HTML comments &lt;!--
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3960 xx --&gt;. This way, it does not affect the Javadocs generated without the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3961 necessity of a seprate comment line. e.g.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3962
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3963 /**
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3964 * &lt;!-- zz.FOLDSTART class AbcClass --&gt; * The class description.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3965 * ... */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3966 public class AbcClass {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3967
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3968 /**
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3969 * &lt;!-- method zz.FOLDSTART someMethod() --&gt; * Method description.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3970 */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3971 public void someMethod();
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3972
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3973 ...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3974
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3975 } /* zz.END: AbcClass */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3976
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3977 /* Put this at the end of your file */ /* vim:fdm=marker
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3978 fmr=zz.FOLDSTART,zz.END fdl=2 fdc=2: */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3979
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3980 Now, the files will be opened with the methods neatly folded. You can use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3981 "zR" to open all folds (or click on the "+" at the left column).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3982
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3983 Sameer.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3984
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3985 </pre></tip> </html> <Tip category="KVim"> <html><center>recording
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3986 keystrokes by "q" for repested jobs</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3987 HREF="http://vim.sf.net/tip_view.php?tip_id=144">http://vim.sf.net/tip_view.php?tip_id=144</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3988
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3989 The most useful feature that I find in VIM is the "recording" feature (:help
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3990 recording). I have used this to automatically insert function headers,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3991 re-indent lines, and convert some 34 source files into HTML.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3992
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3993 This feature is most useful when you want to do some repeated jobs, which
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3994 you cant do easily using ".". You can set about writing a function, define
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3995 a mapping, etc, but then these things might take time. By recording, you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3996 can try out and find the actual keystrokes that does the job.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3997
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3998 To start recording, press "q" in normal mode followed by any of "0-9a-z".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3999 This will start recording the keystrokes to the register you choose. You can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4000 also see the word "recording" in the status(?) line. You can start the key
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4001 sequences that you want to record. You can go to insert mode and type if
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4002 you want.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4003
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4004 To stop recording, press "q" in the normal mode.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4005
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4006 To playback your keystrokes, press "@" followed by the character you choose.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4007 Pressing "@@" will repeat the same again.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4008
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4009 Sameer.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4010
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4011 </pre></tip> </html> <Tip category="KVim"> <html><center>Changing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4012 DOS style end of line to UNIX, or vise-versa</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4013 HREF="http://vim.sf.net/tip_view.php?tip_id=145">http://vim.sf.net/tip_view.php?tip_id=145</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4014
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4015 Those of us doomed to work in both the Unix and Windows world have many times
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4016 encountered files that were create/editted on systems other that the one
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4017 we are on at the time of our edits. We can easily correct the dreaded '^M'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4018 at the end of our Unix lines, or make files have more than one line in DOS by:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4019
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4020 To change from &lt;CR&gt;&lt;LF&gt; (DOS) to just &lt;LF&gt; (Unix): :set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4021 fileformat=unix :w
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4022
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4023 Or to change back the other way: :set fileformat=dos :w
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4024
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4025 It also works for Apple land: :set fileformat=mac :w
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4026
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4027 And to tell the difference: set statusline=%&lt;%f%h%m%r%=%{&ff}\ %l,%c%V\ %P
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4028 ^^^^^ This shows what the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4029 current file's format is.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4030
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4031 Happy Vimming!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4032
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4033 </pre></tip> </html> <Tip category="KVim"> <html><center>opening
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4034 multiple files from a single command-line</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4035 HREF="http://vim.sf.net/tip_view.php?tip_id=146">http://vim.sf.net/tip_view.php?tip_id=146</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4036
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4037 i use the :split command a lot -- both to open a second window containing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4038 the currently edited file and to edit a new file altogether (with the :split
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4039 &lt;filename&gt; option). however, i also like to be able to edit more than
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4040 one file and calling :sp multiple times is inconvenient. so, i created the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4041 following command, function and abbreviation:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4042
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4043 function! Sp(...)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4044 if(a:0 == 0)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4045 sp
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4046 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4047 let i = a:0 while(i &gt; 0)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4048 execute 'let file = a:' . i execute 'sp ' . file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4049
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4050 let i = i - 1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4051 endwhile
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4052 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4053 endfunction com! -nargs=* -complete=file Sp call Sp(&lt;f-args&gt;) cab sp Sp
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4054
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4055 this retains the behaviour of :sp in that i can still type :sp (the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4056 abbreviation takes care of that). :Sp takes any number of files and opens
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4057 them all up, one after the other.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4058
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4059 the things i have noticed are that this causes 'sp' to be expanded to 'Sp'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4060 everywhere, even in search patterns. also, prepending 'vert' doesn't work.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4061 if there is interest, i'll do that.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4062
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4063 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4064 <html><center>How to write a plugin</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4065 HREF="http://vim.sf.net/tip_view.php?tip_id=147">http://vim.sf.net/tip_view.php?tip_id=147</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4066
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4067 This tip gives a skeleton for writing a plugin; Vim's help files have plenty
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4068 of details (:he plugin, :he write-plugin, :he plugin-details).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4069
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4070 #
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4071 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4072 # Exit when your app has already been loaded (or "compatible" mode set)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4073 if exists("loaded_YourAppName") || &cp
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4074 finish
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4075 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4076
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4077 # Public Interface: # AppFunction: is a function you expect your users to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4078 call # PickAMap: some sequence of characters that will run your AppFunction #
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4079 Repeat these three lines as needed for multiple functions which will # be used
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4080 to provide an interface for the user if !hasmapto('&lt;Plug&gt;AppFunction')
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4081 map &lt;unique&gt; &lt;Leader&gt;PickAMap &lt;Plug&gt;AppFunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4082 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4083
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4084 # Global Maps: # map &lt;silent&gt; &lt;unique&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4085 &lt;script&gt; &lt;Plug&gt;AppFunction \ :set lz&lt;CR&gt;:call
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4086 &lt;SID&gt;AppFunc&lt;CR&gt;:set nolz&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4087
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4088 #
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4089 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4090
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4091 # AppFunction: this function is available vi the &lt;Plug&gt;/&lt;script&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4092 interface above fu! &lt;SID&gt;AppFunction() ..whatever..
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4093
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4094 # your script function can set up maps to internal functions
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4095 nmap &lt;silent&gt; &lt;left&gt; :set lz&lt;CR&gt;:silent! call
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4096 &lt;SID&gt;AppFunction2&lt;CR&gt;:set nolz&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4097
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4098 # your app can call functions in its own script and not worry about
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4099 name # clashes by preceding those function names with &lt;SID&gt; call
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4100 &lt;SID&gt;InternalAppFunction(...)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4101
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4102 # or you could call it with call s:InternalAppFunction(...) endf #
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4103 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4104
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4105 # InternalAppFunction: this function cannot be called from outside the #
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4106 script, and its name won't clash with whatever else the user has loaded
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4107 fu! &lt;SID&gt;InternalAppFunction(...) ..whatever.. endf
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4108
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4109 #
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4110 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4111
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4112 Plugins are intended to be "drop into &lt;.vim/plugin&gt;" and work.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4113 The problem that the &lt;Plug&gt;, &lt;SID&gt;, etc stuff is intended to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4114 resolve: what to do about functions that have the same names in different
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4115 plugins, and what to do about maps that use the same sequence of characters?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4116 The first problem is solved with &lt;SID&gt; (a script identifier number)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4117 that vim assigns: program with it and your users will be happier when your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4118 stuff works with all their other stuff. The second problem: what to about
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4119 those maps is addressed with &lt;Plug&gt;, &lt;unique&gt;, etc. Basically
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4120 the idea is: let the user know that there are clashes and don't overwrite
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4121 previously existing maps. Use the user's preferred map-introducer sequence
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4122 (I like the backslash, but there are many keyboards which make producing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4123 backslashes unpleasant, and those users usually prefer something else).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4124
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4125 What I like to do is to have a pair of start/stop maps to reduce my impact
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4126 on the namespace. When the starting map is used, it kicks off a starting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4127 function that introduces all the maps needed. When the stopping map is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4128 used, it not only removes the maps the starter made but restores any maps
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4129 the user had had that would have clashed. I also use the start/stop pair
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4130 of functions to set and restore options that cause my scripts difficulties.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4131
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4132 Check out DrawIt.vim's SaveMap() function for a way to save user maps.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4133 Restoring maps with it is easy:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4134
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4135 if b:restoremap != ""
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4136 exe b:restoremap unlet b:restoremap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4137 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4138
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4139 So you can see it sets up a string variable with all the maps that the user
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4140 had that would have clashed with my application.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4141
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4142 One final thing: if your application needs to share information between
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4143 its various functions, see if you can use s:varname (a variable that only
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4144 your script's functions can access) or b:varname (a variable that anything
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4145 associated with the buffer your application is running with can access)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4146 instead of using global variables.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4147
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4148 Good luck and happy Vimming!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4149
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4150 </pre></tip> </html> <Tip category="KVim"> <html><center>Make
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4151 great use of those homemade menus</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4152 HREF="http://vim.sf.net/tip_view.php?tip_id=148">http://vim.sf.net/tip_view.php?tip_id=148</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4153
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4154 Accidently discovered that using &lt;alt&gt;&lt;Menu Hotletter&gt;&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4155 (e.g &lt;alt&gt;b&lt;cr&gt; - for the buffer menu) causes the menu to break
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4156 out in a seperate window. Selecting the menu with the mouse and then hitting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4157 enter does not seem to do it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4158
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4159 I will have to learn to add hotletters to my menus now so that the mouse
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4160 can take a break.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4161
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4162 I am a total newbie with vim, but constantly amazed....
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4163
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4164 </pre></tip> </html> <Tip category="KVim"> <html><center>Automatically
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4165 update your diff upon writing.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4166 HREF="http://vim.sf.net/tip_view.php?tip_id=149">http://vim.sf.net/tip_view.php?tip_id=149</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4167
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4168 When trying to reconcile differences between files, and using the new 'diff'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4169 functionality in Vim 6.0 you may want to automatically update the differences
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4170 as you are working along. A convienent time is when you write out either of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4171 the files you are diff'ing. This autocmd will take care of doing that for you.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4172
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4173 " If doing a diff. Upon writing changes to file, automatically update the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4174 " differences au BufWritePost * if &diff ==
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4175 1 au BufWritePost * :diffupdate au BufWritePost
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4176 * endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4177
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4178 </pre></tip> </html> <Tip category="KVim"> <html><center>Generating
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4179 a column of increasing numbers</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4180 HREF="http://vim.sf.net/tip_view.php?tip_id=150">http://vim.sf.net/tip_view.php?tip_id=150</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4181
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4182 You can use the "Visual Incrementing" script from
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4183
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4184 <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4185 HREF="http://www.erols.com/astronaut/vim/index.html#VimFuncs">http://www.erols.com/astronaut/vim/index.html#VimFuncs</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4186
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4187 to convert a block of numbers selected via ctrl-v (visual block) into a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4188 column of increasing integers. Select the column, press :I&lt;CR&gt;, and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4189 the first line's number will be used as a starting value. Subsequent lines's
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4190 numbers will be incremented by one.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4191
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4192 If the ctrl-v block is "ragged right", which can happen when "$" is used to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4193 select the right hand side, the block will have spaces appended as needed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4194 to straighten it out. If the strlen of the count exceeds the visual-block
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4195 allotment of spaces, then additional spaces will be inserted.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4196
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4197 Example: Put cursor on topmost zero, select column with ctrl-v, then :I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4198
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4199 vector[0]= 1; vector[0]= 1; vector[0]= 1; vector[1]= 1;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4200 vector[0]= 1; --&gt; vector[2]= 1; vector[0]= 1; vector[3]= 1;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4201 vector[0]= 1; vector[4]= 1;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4202
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4203 This script works with both vim 5.7 (:so visincr.vim) or vim 6.0 (source it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4204 as for vim 5.7 or drop it into the .vim/plugin directory).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4205
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4206 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4207 <html><center>an ascii table</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4208 HREF="http://vim.sf.net/tip_view.php?tip_id=151">http://vim.sf.net/tip_view.php?tip_id=151</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4209
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4210 There is an ascii table in the vim-help files, but it's hard to find. Thus,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4211 I shall give a pointer to it:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4212
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4213 :help digraph-table
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4214
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4215 </pre></tip> </html> <Tip category="KVim"> <html><center>Dutch,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4216 English, German, Hungarian, and Yiddish</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4217 HREF="http://vim.sf.net/tip_view.php?tip_id=152">http://vim.sf.net/tip_view.php?tip_id=152</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4218
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4219 Under <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4220 HREF="http://www.erols.com/astronaut/vim/index.html#vimlinks_scripts">http://www.erols.com/astronaut/vim/index.html#vimlinks_scripts</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4221 are links to spelling checkers for Dutch, English, German, Hungarian,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4222 and Yiddish, all based on the original engspchk.vim. The spelling checker
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4223 provides as-you-type spell checking; with vim6.0 it will avoid checking on
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4224 partially typed words.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4225
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4226 Provided are several maps:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4227
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4228 \et : add word under cursor into database for just this file \es : save
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4229 word under cursor into database (permanently) \en : move cursor to the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4230 next spelling error \ep : move cursor to the previous spelling error
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4231 \ea : look for alternative spellings of word under cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4232
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4233 To use \ea you will need agrep:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4234
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4235 agrep source: <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4236 HREF="ftp://sunsite.unc.edu/pub/Linux/utils/text/agrep-2.04.tar.Z">ftp://sunsite.unc.edu/pub/Linux/utils/text/agrep-2.04.tar.Z</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4237 agrep Win exe: <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4238 HREF="http://www.tgries.de/agrep">http://www.tgries.de/agrep</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4239
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4240 To use the spell checkers just source it in:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4241
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4242 ex. so engspchk.vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4243
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4244 To read more about it see
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4245
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4246 <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4247 HREF="http://www.erols.com/astronaut/vim/index.html#Spelling">http://www.erols.com/astronaut/vim/index.html#Spelling</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4248
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4249 </pre></tip> </html> <Tip category="KVim"> <html><center>Making
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4250 Parenthesis And Brackets Handling Easier</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4251 HREF="http://vim.sf.net/tip_view.php?tip_id=153">http://vim.sf.net/tip_view.php?tip_id=153</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4252
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4253 1) ++++++++++++++++++++++++++ "Automatic" bracket setting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4254 +++++++++++++++++++++++++++++ 2) +++++++++++++ Further improvement of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4255 parenthesis/bracket expanding +++++++++++++++++ 3) ++++++++++++++++++++++++++++
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4256 "Late" bracketing of text +++++++++++++++++++++++++++++ 4)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4257 +++++++++++++++++++++++++++++ Conclusion ++++++++++++++++++++++++++++++++++++++
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4258 ++++
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4259
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4260 =======================================================================================
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4261
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4262 1) ++++++++++++++++++++++++++ "Automatic" bracket setting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4263 +++++++++++++++++++++++++++++
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4264
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4265 To automatically insert a closing parenthesis when typing an opening
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4266 parenthesis you can insert the following simple mapping to your vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4267
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4268 :inoremap ( ()&lt;ESC&gt;i
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4269
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4270 This ends up with the cursor between the opening and the closing parenthesis
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4271 in insert mode.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4272
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4273 You can apply this and the following tips, of course, with the kind of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4274 parenthesis/bracket character you want to, i.e. (, {, [, &lt; ..... and,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4275 pretty useful as well, quotation marks ",',.... (to be continued)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4276
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4277 2) +++++++++++++++ Further improvement of parenthesis/bracket expanding
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4278 ++++++++++++++++++
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4279
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4280 I you are ready with filling the parenthesis/brackets, you likely want to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4281 "escape" from the brackets again to continue coding. To make this pretty
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4282 comfortable, I invented the following kind of mappings, which get out of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4283 the last expanded parenthesis/bracket, regardless of the actual type of it,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4284 and enter append mode again. I mapped this kind of "getaway" with CTRL_j,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4285 you may use your favorite keystroke with it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4286
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4287 ...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4288 :inoremap ( ()&lt;ESC&gt;:let leavechar=")"&lt;CR&gt;i :inoremap [
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4289 []&lt;ESC&gt;:let leavechar="]"&lt;CR&gt;i
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4290 ...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4291 :imap &lt;C-j&gt; &lt;ESC&gt;:exec "normal f" . leavechar&lt;CR&gt;a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4292
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4293 Explanation: The variable "leavechar" contents the actual char which is to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4294 "escape" from.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4295
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4296 3) ++++++++++++++++++++++++++++ "Late" bracketing of text
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4297 +++++++++++++++++++++++++++++
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4298
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4299 Occasionally I later want already written text parts to put in parenthesis.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4300
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4301 I use the following macro, which brackets previously visually selected text.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4302 I mapped it with _(.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4303
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4304 :vnoremap _( &lt;ESC&gt;`&gt;a)&lt;ESC&gt;`&lt;i(&lt;ESC&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4305
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4306 Furthermore, a sort of mapping for bracketing a *single word* is conceivable.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4307 Because this is not as general like the kind of visual mode mapping, I use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4308 this kind of "word bracketing" only for surrounding the word right behind
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4309 the cursor in insert mode with **. I use the following macro to "emphasize"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4310 the word i just typed, for newsgroup articles.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4311
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4312 :imap _* &lt;Esc&gt;bi*&lt;Esc&gt;ea*&lt;Space&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4313
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4314 4) ++++++++++++++++++++++++++++++ Conclusion
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4315 ++++++++++++++++++++++++++++++++++++++++++
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4316
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4317 Since I use these macros, I never caused a syntax error because of missing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4318 brackets, and furthermore I can quickly insert parenthesis and qutotes into
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4319 code- and non-code files.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4320
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4321 JH 04.11.2001
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4322
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4323 </pre></tip> </html> <Tip category="KVim"> <html><center>Mappings
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4324 to facilitate the creation of text</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4325 HREF="http://vim.sf.net/tip_view.php?tip_id=154">http://vim.sf.net/tip_view.php?tip_id=154</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4326
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4327 " " Mappings to facilitate the creation of text " " Author: Suresh Govindachar
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4328 sgovindachar@yahoo.com " Date: November 5, 2001 " " While typing text to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4329 create a document, I often end up hitting " &lt;Esc&gt;, issuing some commands
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4330 (with or without ":") and getting back " to typing by issuing a command such
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4331 as "i", "O", "s" etc. " " I looked into using "set insertmode" to speed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4332 up such actions, but " found that too confusing. " " I have come up with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4333 a set of mappings that have speeded up my process " of creating documents.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4334 I have saved these mappings in a file, named " FullScreenVI.vim, in vim's
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4335 plugin directory. " " Perhaps you will find these mappings helpful too.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4336 " " Please send me feedback. "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4337
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4338 "To allow overriding the Alt key set winaltkeys=no "To enable viewing messages
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4339 from commands issued using the mappings presented here set cmdheight=2
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4340
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4341 "The fundamental mapping that makes full-screen editing possible imap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4342 &lt;A-o&gt; &lt;C-o&gt; imap &lt;A-;&gt; &lt;C-o&gt;:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4343
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4344 "Basic motions imap &lt;A-h&gt; &lt;Left&gt; imap &lt;A-j&gt; &lt;Down&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4345 imap &lt;A-k&gt; &lt;Up&gt; imap &lt;A-l&gt; &lt;Right&gt; imap &lt;A-f&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4346 &lt;PageDown&gt; imap &lt;A-b&gt; &lt;PageUp&gt; imap &lt;A-^&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4347 &lt;Home&gt; imap &lt;A-$&gt; &lt;End&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4348
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4349 "Numbers for repeats imap &lt;A-1&gt; &lt;C-o&gt;1 imap &lt;A-2&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4350 &lt;C-o&gt;2 imap &lt;A-3&gt; &lt;C-o&gt;3 imap &lt;A-4&gt; &lt;C-o&gt;4
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4351 imap &lt;A-5&gt; &lt;C-o&gt;5 imap &lt;A-6&gt; &lt;C-o&gt;6 imap &lt;A-7&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4352 &lt;C-o&gt;7 imap &lt;A-8&gt; &lt;C-o&gt;8 imap &lt;A-9&gt; &lt;C-o&gt;9
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4353
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4354 "Basic searches imap &lt;A-/&gt; &lt;C-o&gt;/ imap &lt;A-*&gt; &lt;C-o&gt;*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4355 imap &lt;A-#&gt; &lt;C-o&gt;# imap &lt;A-n&gt; &lt;C-o&gt;n imap &lt;A-N&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4356 &lt;C-o&gt;N
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4357
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4358 "Deleting imap &lt;A-x&gt; &lt;C-o&gt;x imap &lt;A-d&gt; &lt;C-o&gt;d imap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4359 &lt;A-D&gt; &lt;C-o&gt;D
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4360
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4361 "Yanking and putting imap &lt;A-y&gt; &lt;C-o&gt;y imap &lt;A-Y&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4362 &lt;C-o&gt;Y imap &lt;A-p&gt; &lt;C-o&gt;p imap &lt;A-P&gt; &lt;C-o&gt;P
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4363
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4364 "Common prefixes: marking, matching etc. imap &lt;A-~&gt; &lt;C-o&gt;~
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4365 imap &lt;A-m&gt; &lt;C-o&gt;m imap &lt;A-`&gt; &lt;C-o&gt;` imap &lt;A-"&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4366 &lt;C-o&gt;" imap &lt;A-%&gt; &lt;C-o&gt;% imap &lt;A-h&gt; &lt;C-o&gt;:h
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4367 imap &lt;A-s&gt; &lt;C-o&gt;:s
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4368
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4369 "Interacting with the 'outside' imap &lt;A-!&gt; &lt;C-o&gt;:! imap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4370 &lt;A-w&gt; &lt;C-o&gt;:w&lt;CR&gt; imap &lt;A-e&gt; &lt;C-o&gt;:e
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4371
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4372 "Other commands imap &lt;A-u&gt; &lt;C-o&gt;u imap &lt;A-.&gt; &lt;C-o&gt;.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4373
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4374 </pre></tip> </html> <Tip category="KVim"> <html><center>Decompile
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4375 Java .class files automatically</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4376 HREF="http://vim.sf.net/tip_view.php?tip_id=155">http://vim.sf.net/tip_view.php?tip_id=155</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4377
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4378 Here's a plugin to automatically decompile Java .class files as they're
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4379 read in. Tweak the javap flags for what you want to see. I didn't post
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4380 this as a script because it's too simple and it's really more useful for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4381 demonstrating how to read decompilable files (or other binary files that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4382 can be converted to text).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4383
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4384 function s:ReadClass(dir, classname)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4385 execute "cd " . a:dir execute "0read !javap -c " . a:classname 1 setlocal
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4386 readonly setlocal nomodified
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4387 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4388
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4389 autocmd BufReadCmd *.class
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4390 \ call &lt;SID&gt;ReadClass(expand("&lt;afile&gt;:p:h"),
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4391 expand("&lt;afile&gt;:t:r"))
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4392
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4393 </pre></tip> </html> <Tip category="KVim"> <html><center>describe
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4394 &lt;table name&gt; from vim</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4395 HREF="http://vim.sf.net/tip_view.php?tip_id=156">http://vim.sf.net/tip_view.php?tip_id=156</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4396
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4397 i had some trouble with the sqlplus scripts (probably my fault). but it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4398 seemed a little heavy for what i need, usually all i want is a listing of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4399 the columns for a given table while i'm whipping on some sql inside vim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4400
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4401 so i wrote a bash script (describe)...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4402
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4403 ~~~~~~~~~~~~~~~begin describe script #!/usr/bin/bash
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4404
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4405 f=aTempFile.sql u=&lt;uName&gt; p=&lt;pWord&gt; d=&lt;dBase&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4406
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4407 echo "/* describe for $1" echo "describe $1;" &gt; $f; echo "quit;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4408 &gt;&gt; $f;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4409
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4410 sqlplus -S $u/$p@$d @$f rm -f $f; echo " end describe for $1 */"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4411 ~~~~~~~~~~~~~~~end describe script
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4412
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4413 your path needs to include the script (as well as sqlplus), then from vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4414 you can just type....
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4415
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4416 :r !describe &lt;tableName&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4417
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4418 and you get a listing of the table columns slammed into wherever your cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4419 was, complete with java/c comments
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4420
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4421 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4422 <html><center>Incredible new functionality</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4423 HREF="http://vim.sf.net/tip_view.php?tip_id=157">http://vim.sf.net/tip_view.php?tip_id=157</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4424
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4425 if you get away from vim and get any other editor that was built *after*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4426 1970....
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4427
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4428 </pre></tip> </html> <Tip category="KVim"> <html><center>Using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4429 Computer Modern TT as gvim font (Win32)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4430 HREF="http://vim.sf.net/tip_view.php?tip_id=158">http://vim.sf.net/tip_view.php?tip_id=158</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4431
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4432 If you really like the Computer Modern typewriter font (as seen in most TeX
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4433 distributions) you can use it as the font in gvim! (looks excellent with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4434 font smoothing turned on)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4435
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4436 First, get hold of the free Blue Sky Type 1 PS versions of the CM fonts from
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4437 your local CTAN mirror. Unpack to a suitable directory.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4438
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4439 Next locate the cmtt8.pfb file and open it (in Vim, naturally ;) - find the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4440 line saying dup 32 /visiblespace put
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4441
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4442 and change it to dup 32 /space put
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4443
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4444 that is, inserting enough spaces to keep the file size exactly the same
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4445 (IMPORTANT!)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4446
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4447 Save the file in Mac format (:set fileformat=mac).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4448
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4449 Now install the cmtt.pfm file - in Win9x/NT4, you'll need Adobe Type Manager
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4450 (free download), but in Win2k, you can just drop the .pfm file into the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4451 Fonts folder.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4452
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4453 Now in your _gvimrc: set guifont=CMTT8:h11:cSYMBOL
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4454
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4455 (use whatever height you like instead of h11)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4456
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4457 ..and enjoy! It's the first scalable font I can bear to edit code in... %-)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4458
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4459 </pre></tip> </html> <Tip category="KVim"> <html><center>Keystroke
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4460 Saving Substituting and Searching</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4461 HREF="http://vim.sf.net/tip_view.php?tip_id=159">http://vim.sf.net/tip_view.php?tip_id=159</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4462
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4463 1) ++++++++++++++ Saving Keystrokes for common Searching
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4464 and Substituting +++++++++++ --- a) Searching b) Substituting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4465 --------------------------------------------------- 2) ++++ Searching for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4466 resp. Substituting of the current word under the cursor ++++++ --- a) Searching
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4467 b) Substituting ---------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4468 3) ++ Searching and Substituting for an arbitrary visually
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4469 selected part of text ++++ --- a) Searching b) Substituting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4470 ---------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4471 4) ++++++++++++++++++++++++++++++++ Conclusion
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4472 +++++++++++++++++++++++++++++++++++++
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4473
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4474 =====================================================================================
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4475
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4476 1) ++++++++++++++ Saving Keystrokes for common Substituting and Searching
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4477 +++++++++++
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4478
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4479 a) Searching ............ Sorry, there is not much that can be saved for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4480 common Searching. It's just hitting /mypattern&lt;RETURN&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4481
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4482 b) Substituting ......... I think, common substitution requires pretty many
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4483 keystrokes. So I use the following macro with my favorite substitution options:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4484
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4485 :map &lt;F4&gt; :%s//gc&lt;Left&gt;&lt;Left&gt;&lt;Left&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4486
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4487 This ends up with the cursor after the first '/' in the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4488 commandline. To complete it, you only have to enter -&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4489 myoldpattern/mynewpattern&lt;RETURN&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4490
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4491 Remark: I mapped it to &lt;F4&gt; (cause of tribute to the &lt;F4&gt; of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4492 the good old Norton Commander editor). You may map it where you want to.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4493
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4494 2) ++++ Searching for resp. Substituting of the current word under the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4495 cursor ++++++
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4496
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4497 a) Searching ............ If you don't know how to look for the next
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4498 occurence of the word under the cursor, you should *now* type :help * or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4499 :help star or refer to the tips vimtip #1 or vimtip #5 ((Tip within tip:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4500 To make your pattern more visible, look for :help hls))
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4501
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4502 b) Substituting ......... The following macro extends the one above with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4503 automatically inserting the current word under the cursor into the from -
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4504 pattern of the :s command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4505
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4506 :map &lt;S-F4&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4507 :%s/&lt;C-r&gt;&lt;C-w&gt;//gc&lt;Left&gt;&lt;Left&gt;&lt;Left&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4508
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4509 To complete it, just enter -&gt; mynewpattern&lt;RETURN&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4510
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4511 I use this i.e. for reliable and quickly renaming a variable in the entire
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4512 buffer. I mapped it to Shift-&lt;F4&gt;. You may map it to the keystroke
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4513 you want.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4514
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4515 Explanation: CTRL-v+CTRL-w expands to the word under the cursor.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4516
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4517 3) ++ Searching and Substituting for an arbitrary visually selected part of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4518 text ++++
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4519
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4520 If you want to look or substitute (for) an *arbritary* pattern (which
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4521 already exists at least once in your text), the following 2 mappings do it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4522 for you. The advantage is that you dont have to type again or cut & paste
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4523 the appropriate text but only have to visually select it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4524
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4525 a) Searching ...........
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4526
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4527 :vmap / y:execute "/".escape(@",'[]/\.*')&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4528
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4529 This immediately finds to the next occurence of the previously visually
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4530 selected text.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4531
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4532 b) Substituting .........
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4533
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4534 :vmap &lt;F4&gt; y:execute
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4535 "%s/".escape(@",'[]/\')."//gc"&lt;Left&gt;&lt;Left&gt;&lt;Left&gt;&lt;Left&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4536
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4537 Again, as in the mapping in chapter 2), you just have to complete it by
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4538 entering -&gt; mynewpattern&lt;RETURN&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4539
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4540 Explanation/Discussion: What both Substituting and Searching in this way
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4541 generally does is: - *y*anking the selected text - Inserting the visually
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4542 selected via adressing the '"' register with '@"' as a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4543 parameter of the escape() function going finally into the 'myoldpattern'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4544 part. The trickery problem is, if you have characters in your myoldpattern,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4545 which are regular expression chars, they are recognized and threated
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4546 accordingly. That is most likely not what you wanted. To escape them, these
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4547 chars have to be declared by the second parameter of the excape() function,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4548 which then escapes them with a backslash. The few characters above work
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4549 for me. If you run into problems, you should check for additional regexp
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4550 chars in your text, and try to escape them by adding them to the escape()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4551 function parameter.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4552
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4553 4) ++++++++++++++++++++++++++++++++ Conclusion
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4554 +++++++++++++++++++++++++++++++++++++
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4555
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4556 With the appropriate mappings in your vimrc you can save keystrokes when
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4557 Searching or Substituting and avoid typing errors. That way, you can take
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4558 lunch sooner
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4559
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4560 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4561 <html><center>Dutch spelling checker</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4562 HREF="http://vim.sf.net/tip_view.php?tip_id=161">http://vim.sf.net/tip_view.php?tip_id=161</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4563
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4564 Download at <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4565 HREF="http://www.thomer.com/thomer/vi/nlspchk.vim.gz.">http://www.thomer.com/thomer/vi/nlspchk.vim.gz.</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4566
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4567 This sciript is based on Charles E. Campbell's English spelling checker script
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4568 for ViM (<A HREF="http://users.erols.com/astronaut/vim/) and Piet Tutelaers'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4569 Dutch word list (http://www.ntg.nl/spell-nl-v5b/) using Thomas Köhler's
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4570 script (http://jeanluc-picard.de/vim/gerspchk/create). In other words, I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4571 didn't do much.">http://users.erols.com/astronaut/vim/) and Piet Tutelaers'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4572 Dutch word list (http://www.ntg.nl/spell-nl-v5b/) using Thomas Köhler's
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4573 script (http://jeanluc-picard.de/vim/gerspchk/create). In other words,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4574 I didn't do much.</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4575
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4576 </pre></tip> </html> <Tip category="KVim"> <html><center>write
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4577 plugin with explorer like interfaces</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4578 HREF="http://vim.sf.net/tip_view.php?tip_id=162">http://vim.sf.net/tip_view.php?tip_id=162</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4579
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4580 Several plugins use a text base interface based on a special buffer, this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4581 is the case of the standard explorer plugin, several bufexplorer plugins,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4582 the option buffer and others... Here is a quick guide in how to do this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4583
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4584 Writing a special buf script
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4585 | using a special buffer is a common technic when writing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4586 Vim scripts, it is used by | explorer, bufexplorer,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4587 DirDiff... | I'm currently writing one for TagsBase.vim | <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4588 HREF="http://vim.sourceforge.net/scripts/script.php?script_id=100
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4589 ">http://vim.sourceforge.net/scripts/script.php?script_id=100 </A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4590 | and I'll use this document to take notes on how to do it. |
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4591
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4592 Setting up the buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4593 Opening the window TODO
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4594
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4595 Using a setup function
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4596 Principle
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4597 | we can use a specific function to open and setup
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4598 the special buffer. s:SetupBuf()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4599 Setup Function advantage
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4600 | since the command will be defined in the main
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4601 script you | can use script local functions
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4602 Using a special filetype
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4603 Principle
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4604 | we can also use a new filetype and distribute a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4605 syntax and an ftplugin for this | filetype, the only
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4606 thing needed in this case is to set the | filetype
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4607 after creating the buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4608 Filetype advantage
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4609 | better separations of different parts of your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4610 script. If | the main function of your plugin is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4611 not to have this | special buffer then it is nice
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4612 to avoid clutering it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4613 Things which needs to be done to setup the buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4614 The buffer should not be listed and does not correspond to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4615 a file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4616 * setlocal buftype=nofile - options always local
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4617 to buffer * set nobuflisted * set bufhidden=delete *
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4618 set nomodifiable
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4619 Setup the syntax for this buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4620 | see :help syntax | This is usually done in two
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4621 steps, first describe the | syntax groups using :syn
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4622 commands then setup the | hilighting using :hi def
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4623 link commands. Usually it is | best to link the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4624 newly defined groups to predefine ones in | order
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4625 to make the coloring work fine with colorschemes.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4626 | You'll find the list of predefined group by doing:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4627 | :help group-name
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4628 Setup the special mappings
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4629 | since we have chosen to use the set nomodifiable
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4630 option | our buffer will never be in insert mode. All
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4631 our mapping | are in Normal, Visual or operator
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4632 pending, they should | therefore use the map, nmap,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4633 vmap and omap mapping command | plus the associated
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4634 'nore' version. I usually find it | better to use the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4635 'nore' version to avoid surprises due to | mapping
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4636 in the user configuration. | | We also want our
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4637 mappings to be local to the special | buffer so all
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4638 the commands will use the &lt;buffer&gt; modifier.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4639 | | Finally we want our mappings not to polute the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4640 status bar | so we use the &lt;silent&gt; modifier |
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4641 | Putting all this together we end up with mapping
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4642 commands | which look like: | noremap &lt;buffer&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4643 &lt;silent&gt; {lhs} {rhs}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4644 Setup the special command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4645 | we will then setup special commands for this buffer.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4646 Like | for the mapping there are some precautions to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4647 take: | we don't want an error message if the command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4648 is defined | twice so we use the command! variant. |
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4649 We want a command local to our buffer wo we use the |
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4650 -buffer attribute. The rests of the command attributes
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4651 | and options depend on the actual command. | So
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4652 our commands look like: | command! -buffer {attr}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4653 {cmd} {rep} | where attr is optional.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4654
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4655 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4656 <html><center>Toggle Search Highlighting</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4657 HREF="http://vim.sf.net/tip_view.php?tip_id=163">http://vim.sf.net/tip_view.php?tip_id=163</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4658
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4659 " Map H to toggle search highlighting map H :let &hlsearch =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4660 !&hlsearch&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4661
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4662 </pre></tip> </html> <Tip category="KVim"> <html><center>Make
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4663 non-ASCII characters displayed on console</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4664 HREF="http://vim.sf.net/tip_view.php?tip_id=164">http://vim.sf.net/tip_view.php?tip_id=164</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4665
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4666 I had a problem with VIM on the FreeBSD console: it didn't display characters
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4667 like German umlauts correctly, but escaped them with a tilde. The solution
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4668 is to teach VIM about printable characters. I use the following on my .vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4669
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4670 set isprint=@,128-255
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4671
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4672 </pre></tip> </html> <Tip category="KVim"> <html><center>Deleting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4673 a buffer without closing the window</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4674 HREF="http://vim.sf.net/tip_view.php?tip_id=165">http://vim.sf.net/tip_view.php?tip_id=165</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4675
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4676 I'm not sure if this functionality is already within Vim, but I sometimes I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4677 find it useful to keep a split window from closing when deleting a buffer.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4678 This has already been discussed on the vim@vim.org mailing list. However,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4679 I feel this solution is a little easier to use.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4680
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4681 " Put this into .vimrc or make it a plugin. " Mapping :Bclose to some
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4682 keystroke would probably be more useful. " I like the way buflisted()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4683 behaves, but some may like the behavior " of other buffer testing functions.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4684
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4685 command! Bclose call &lt;SID&gt;BufcloseCloseIt()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4686
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4687 function! &lt;SID&gt;BufcloseCloseIt()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4688 let l:currentBufNum = bufnr("%") let l:alternateBufNum = bufnr("#")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4689
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4690 if buflisted(l:alternateBufNum)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4691 buffer #
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4692 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4693 bnext
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4694 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4695
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4696 if bufnr("%") == l:currentBufNum
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4697 new
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4698 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4699
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4700 if buflisted(l:currentBufNum)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4701 execute("bdelete ".l:currentBufNum)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4702 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4703 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4704
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4705 </pre></tip> </html> <Tip category="KVim"> <html><center>Mapping
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4706 caps lock to esc in XWindows</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4707 HREF="http://vim.sf.net/tip_view.php?tip_id=166">http://vim.sf.net/tip_view.php?tip_id=166</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4708
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4709 (This originally appeared on the vim mailing list as post by Adam Monsen <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4710 HREF="http://groups.yahoo.com/group/vim/message/19856)">http://groups.yahoo.com/group/vim/message/19856)</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4711
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4712 If you want to completely swap caps lock and escape, you have to replace
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4713 the "Lock" on caps lock. Drop this file in your home dir:&lt;br&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4714 -----------start------------&lt;br&gt; ! Swap caps lock and escape&lt;br&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4715 remove Lock = Caps_Lock&lt;br&gt; keysym Escape = Caps_Lock&lt;br&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4716 keysym Caps_Lock = Escape&lt;br&gt; add Lock = Caps_Lock&lt;br&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4717 ------------end-------------&lt;br&gt; and call it ".speedswapper". Then
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4718 open a terminal and type&lt;br&gt; $ xmodmap .speedswapper&lt;br&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4719 and you'll be twice as efficient in vim. Who needs caps lock anyway? The
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4720 swapping lasts for the duration of the X session, so you can put it in a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4721 .xinitrc or similar startup file. As far as other people using my laptop,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4722 I'd rather they didn't! Using a Dvorak layout might protect me even more... :)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4723
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4724 </pre></tip> </html> <Tip category="KVim"> <html><center>Using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4725 vim as a man-page viewer under Unix</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4726 HREF="http://vim.sf.net/tip_view.php?tip_id=167">http://vim.sf.net/tip_view.php?tip_id=167</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4727
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4728 To use vim as a man-page viewer involves setting an environment variable:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4729
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4730 sh, ksh: export MANPAGER="col -b | view -c 'set ft=man nomod nolist'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4731 -" csh : setenv MANPAGER "col -b | view -c 'set ft=man nomod nolist' -"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4732
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4733 Put one of the above two lines into your &lt;.profile&gt; or &lt;.login&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4734 file as appropriate for your shell.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4735
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4736 The man pages will then be displayed with vim called as "view" and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4737 will use the &lt;man.vim&gt; syntax highlighting. I myself use some
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4738 additional highlighting which is enabled by putting the following file into
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4739 &lt;.vim/after/syntax/man.vim&gt;. I usually use the &lt;astronaut&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4740 colorscheme (also available from this archive); those who use bright
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4741 backgrounds may find the colors selected for manSubSectionStart and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4742 manSubSection something they'll want to change:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4743
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4744 ---------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4745 " DrChip's additional &lt;man.vim&gt; stuff
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4746
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4747 syn match manSectionHeading "^\s\+[0-9]\+\.[0-9.]*\s\+[A-Z].*$"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4748 contains=manSectionNumber syn match manSectionNumber
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4749 "^\s\+[0-9]\+\.[0-9]*" contained syn region manDQString
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4750 start='[^a-zA-Z"]"[^", )]'lc=1 end='"' contains=manSQString
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4751 syn region manSQString start="[ \t]'[^', )]"lc=1 end="'"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4752 syn region manSQString start="^'[^', )]"lc=1 end="'"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4753 syn region manBQString start="[^a-zA-Z`]`[^`, )]"lc=1 end="[`']"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4754 syn region manBQSQString start="``[^),']" end="''"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4755 syn match manBulletZone transparent "^\s\+o\s" contains=manBullet
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4756 syn case match syn keyword manBullet contained o syn match manBullet
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4757 contained "\[+*]" syn match manSubSectionStart "^\*" skipwhite
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4758 nextgroup=manSubSection syn match manSubSection ".*$" contained
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4759
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4760 hi link manSectionNumber Number hi link manDQString String hi
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4761 link manSQString String hi link manBQString String hi
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4762 link manBQSQString String hi link manBullet Special hi
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4763 manSubSectionStart term=NONE cterm=NONE gui=NONE ctermfg=black
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4764 ctermbg=black guifg=navyblue guibg=navyblue hi manSubSection
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4765 term=underline cterm=underline gui=underline ctermfg=green guifg=green set ts=8
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4766 ---------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4767
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4768
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4769 </pre></tip> </html> <Tip category="KVim"> <html><center>Viewing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4770 the actual XPM data in GVIM</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4771 HREF="http://vim.sf.net/tip_view.php?tip_id=168">http://vim.sf.net/tip_view.php?tip_id=168</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4772
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4773 GVIM has an excellent syntax highlighting for XPM images, but sometimes
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4774 it's useful to view the actual data. This can be achieved by searching for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4775 everything, type in "/." and all characters will be highlighted and therefore
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4776 the old colouring is lost. To regain the normal highlighting you can search
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4777 for a non-existent sequence, like "/foo".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4778
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4779 </pre></tip> </html> <Tip category="KVim"> <html><center>&lt;Tab&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4780 = &lt;C-I&gt; and &lt;Esc&gt; = &lt;C-[&gt;</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4781 HREF="http://vim.sf.net/tip_view.php?tip_id=169">http://vim.sf.net/tip_view.php?tip_id=169</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4782
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4783 An FAQ on the vim users' mailing list is whether &lt;Tab&gt; and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4784 &lt;C-I&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4785 can be mapped to different things. The answer is no. As I understand it,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4786 this is a low level issue: &lt;Tab&gt; and &lt;C-I&gt; are different names
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4787 for the same ASCII code, and there is no way for vim to tell them apart.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4788 Similarly, &lt;Esc&gt; and &lt;C-[&gt; are the same thing.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4789
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4790 </pre></tip> </html> <Tip category="KVim"> <html><center>Repeating
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4791 a sequence of commands without defining a macro</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4792 HREF="http://vim.sf.net/tip_view.php?tip_id=170">http://vim.sf.net/tip_view.php?tip_id=170</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4793
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4794 Imagine.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4795
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4796 You have just finished a complicated modification of a file, involving
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4797 numerous replace commands :%s/xxx/yyyy/g, and other ex commands.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4798
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4799 Then you realize, you have done it a little bit wrong, and you have to begin
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4800 all the operation again, just to change one replace string, or do one more
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4801 operation "somewhere 10 commands ago".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4802
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4803 Or you realize, you will have to do the same stuff tomorrow with another file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4804
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4805 or you realize, you want to perform the same sequence of commands, you have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4806 typed a few days ago
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4807
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4808 You should have made it a macro (normal command q), but you haven't.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4809
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4810 Nothing is lost yet.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4811
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4812 You go to the command line (by typing :) and press Ctrl+F. (Ctrl+F in other
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4813 modes scrolls the screen)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4814
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4815 You get a temporary window, listing the history of command line.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4816 It is possible to yank appropriate lines here, make a new file called
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4817 $VIMRUNTIME/macros/something.vim put those lines here, edit them and save
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4818
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4819 see :help cedit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4820
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4821 Then you can call the macro using :source something.vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4822
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4823 You might want to set variable 'history' to a higher number then default in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4824 your vimrc file like :set history=300 see :help history :help vimrc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4825
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4826 </pre></tip> </html> <Tip category="KVim"> <html><center>Do
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4827 you know the "g/" and "g?" commands?</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4828 HREF="http://vim.sf.net/tip_view.php?tip_id=171">http://vim.sf.net/tip_view.php?tip_id=171</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4829
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4830 Directly from the Vim Todo list:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4831
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4832 7 For Visual mode: Command to do a search for the string in the marked area.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4833 Only when less than two lines. Use "g/" and "g?".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4834
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4835 In other words, a way to search for visually selected text !! :-)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4836
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4837 "==== vsearch.vim ====
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4838
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4839 " Visual mode search
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4840
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4841 vmap g/ :call VsearchPatternSave()&lt;cr&gt;/&lt;c-r&gt;/&lt;cr&gt; vmap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4842 g? :call VsearchPatternSave()&lt;cr&gt;?&lt;c-r&gt;/&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4843
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4844 function! VsearchPatternSave()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4845 let l:temp = @@ normal gvy let @/ = substitute(escape(@@, '/\'), "\n",
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4846 "\\\\n", "g") let @@ = l:temp unlet l:temp
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4847 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4848
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4849 "==== END ====
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4850
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4851 Normally, this file should reside in the plugins directory and be
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4852 automatically sourced. If not, you must manually source this file using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4853 ':source vsearch.vim'.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4854
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4855 In Visual mode, highlight the text for searching. Then you can use the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4856 default visual key mappings
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4857
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4858 g/ - search forwards g? - search backwards
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4859
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4860 Visual searches behave like normal searches. The 'n' and 'N' commands
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4861 work as they should, and the search history correctly records each search.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4862 Multi-line searches behave as they should (this corrects the 'yank-only'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4863 method mentioned in the Vim help files). Block visual searches do not
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4864 work yet. Hopefully, someone can figure out a way to do this easily.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4865
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4866 I've only tested this on Win2000 and Redhat Linux 7.1. I'm not really clear
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4867 on how the carriage returns are dealt with on other systems.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4868
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4869 Anyway, enjoy!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4870
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4871 </pre></tip> </html> <Tip category="KVim"> <html><center>Using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4872 Ispell on a highlighted region</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4873 HREF="http://vim.sf.net/tip_view.php?tip_id=172">http://vim.sf.net/tip_view.php?tip_id=172</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4874
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4875 Suppose you would like to use Ispell to check a word or region that you've
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4876 visually highlighted. The following macro will do the job. Just type
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4877 Shift-Insert while in visual mode.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4878
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4879 vnoremap &lt;S-Insert&gt; &lt;C-C&gt;`&lt;v`&gt;s&lt;Space&gt;&lt;Esc&gt;mq:e
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4880 ispell.tmp&lt;CR&gt;i&lt;C-R&gt;"&lt;Esc&gt;:w&lt;CR&gt;:! xterm
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4881 -bg ivory -fn 10x20 -e ispell %&lt;CR&gt;&lt;CR&gt;:e
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4882 %&lt;CR&gt;&lt;CR&gt;ggVG&lt;Esc&gt;`&lt;v`&gt;s&lt;Esc&gt;:bwipeout!&lt;CR&gt;:!rm
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4883 ispell.tmp*&lt;CR&gt;`q"_s&lt;C-R&gt;"&lt;Esc&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4884
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4885 This is based on Chip Campbell's macro which uses Ispell on the whole file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4886 (in normal mode).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4887
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4888 noremap &lt;S-Insert&gt; :w&lt;CR&gt;:! xterm -bg ivory -fn 10x20 -e ispell
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4889 %&lt;CR&gt;&lt;Space&gt;:e %&lt;CR&gt;&lt;Space&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4890
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4891 Carl Mueller
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4892
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4893 </pre></tip> </html> <Tip category="KVim"> <html><center>Switch
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4894 between splits very fast (for multi-file editing)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4895 HREF="http://vim.sf.net/tip_view.php?tip_id=173">http://vim.sf.net/tip_view.php?tip_id=173</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4896
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4897 I am a Web developer and I use Vim as my primary editor.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4898
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4899 Most programming projects (and Web programming projects, in particular)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4900 are spread out over multiple files, which you often want to have open
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4901 concurrently. If you don't already know, Vim supports this very well! Just use:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4902
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4903 :sp name-of-another-file-to-edit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4904
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4905 My problems were that (1) it took too long to move between files, and (2)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4906 the files were taking up too much room on the screen.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4907
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4908 (1) In order to move to the file in the split above my current window, I was
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4909 typing Ctrl-W, Up (move up a window) Ctrl-W, _ (maximize the menu). That's
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4910 four keystrokes (more if you count Ctrl and Shift), and they are all over
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4911 the keyboard. To help avoid this problem, I created this mapping in my .vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4912
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4913 map &lt;C-J&gt; &lt;C-W&gt;j&lt;C-W&gt;_ map &lt;C-K&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4914 &lt;C-W&gt;k&lt;C-W&gt;_
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4915
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4916 Now I can hold down Ctrl and move between windows with the standard Vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4917 movement keys. Much, much quicker!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4918
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4919 (2) By default, Vim displays the current line of each minimized file, which
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4920 (to me) isn't much help and takes up too much screen real estate. I use this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4921 line in my .vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4922
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4923 set wmh=0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4924
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4925 This sets the minimum window height to 0, so you can stack many more files
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4926 before things get crowded. Vim will only display the filename.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4927
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4928 Hope this helps those of you who are working on projects with large numbers
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4929 of files you're constantly flipping through. Happy Vimming!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4930
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4931 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4932 <html><center>Footnotes</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4933 HREF="http://vim.sf.net/tip_view.php?tip_id=174">http://vim.sf.net/tip_view.php?tip_id=174</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4934
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4935 ab (1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4936 [1]&lt;esc&gt;:/^--\s/-1/&lt;cr&gt;o&lt;insert&gt;&lt;cr&gt;Footnotes:&lt;cr&gt;----------&lt;cr&gt;[1]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4937 ab (2 [2]&lt;esc&gt;:/^Footnotes\:/+2/&lt;cr&gt;o&lt;insert&gt;[2]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4938 ab (3 [3]&lt;esc&gt;:/^Footnotes\:/+3/&lt;cr&gt;o&lt;insert&gt;[3] ab
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4939 (4 [4]&lt;esc&gt;:/^Footnotes\:/+4/&lt;cr&gt;o&lt;insert&gt;[4] ab (5
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4940 [5]&lt;esc&gt;:/^Footnotes\:/+5/&lt;cr&gt;o&lt;insert&gt;[5]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4941
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4942 </pre></tip> </html> <Tip category="KVim"> <html><center>how to make
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4943 VIM as ur default editor even without root ac.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4944 HREF="http://vim.sf.net/tip_view.php?tip_id=175">http://vim.sf.net/tip_view.php?tip_id=175</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4945
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4946 hi, if u have installed vim in your home directory somewhere and u don't have a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4947 root account, and you want to make VIM the default editor for anything u do.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4948 i.e if ur using SQLplus and want to edit a sql command. normally typing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4949 edit brings up the vi editor and not vim editor. to solve this problem.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4950 define these three variables in your .profile VIM=&lt;base directory where
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4951 vim executable is placed&gt; VIMRUNTIME=&lt;base direcoty where vim runtimes
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4952 are kept&gt; EDITOR=$VIM/vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4953
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4954 note if u have installed vim with another name, say vim.exe then change
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4955 EDITOR=$VIM/vim to EDITOR=$VIM/vim.exe
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4956
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4957 source the .profile and viola. next time u start an editor from any program
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4958 u have the vim editor.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4959
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4960 Njoy.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4961
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4962 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4963 <html><center>Autocheckout from perforce</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4964 HREF="http://vim.sf.net/tip_view.php?tip_id=176">http://vim.sf.net/tip_view.php?tip_id=176</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4965
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4966 The following code automatically checks out files from perforce when the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4967 user modifies them. It first confirms the check-out with the user.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4968
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4969 (Perforce is a commercial version control system. I imagine this could be
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4970 modified for RCS, CVS, etc., but I don't use those.)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4971
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4972 I'm a vim newbie -- I've used vi since 1984, but just started with vim a couple
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4973 days ago. Color me impressed! Please excuse any stupidity in the code..
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4974
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4975 Note that this function needs the "P4HOME" environment variable to be set.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4976 I could extract it by invoking "p4 client", but I don't want to invoke p4
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4977 every time I start vim. So I assume the user sets it in the environment.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4978
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4979 " Set a buffer-local variable to the perforce path, if this file is under
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4980 the perforce root. function IsUnderPerforce()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4981 if exists("$P4HOME")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4982 if expand("%:p") =~ ("^" . $P4HOME)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4983 let b:p4path = substitute(expand("%:p"), $P4HOME, "//depot", "")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4984 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4985 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4986 endfunction " Confirm with the user, then checkout a file from perforce.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4987 function P4Checkout()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4988 if exists("b:p4path")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4989 if (confirm("Checkout from Perforce?", "&Yes\n&No", 1) == 1)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4990 call system("p4 edit " . b:p4path . " &gt; /dev/null") if
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4991 v:shell_error == 0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4992 set noreadonly
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4993 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4994 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4995 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4996 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4997
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4998 if !exists("au_p4_cmd")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4999 let au_p4_cmd=1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5000
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5001 au BufEnter * call IsUnderPerforce() au FileChangedRO * call P4Checkout()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5002 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5003
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5004 </pre></tip> </html> <Tip category="KVim"> <html><center>Highlight
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5005 matching brackets as one moves in normal mode (plugin)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5006 HREF="http://vim.sf.net/tip_view.php?tip_id=177">http://vim.sf.net/tip_view.php?tip_id=177</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5007
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5008 Check out <A HREF="http://www.erols.com/astronaut/vim/index.html#VimFuncs
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5009 for">http://www.erols.com/astronaut/vim/index.html#VimFuncs for</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5010 a plugin script which highlights matching brackets. The script has two
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5011 always-on maps:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5012 \[i : start [HiMtchBrkt] mode \[s : stop [HiMtchBrkt] mode
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5013 The plugin will save all user maps and options that the plugin uses and will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5014 restore them when the mode is stopped.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5015
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5016 </pre></tip> </html> <Tip category="KVim"> <html><center>Making
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5017 a "derived" colorscheme without copy & paste</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5018 HREF="http://vim.sf.net/tip_view.php?tip_id=178">http://vim.sf.net/tip_view.php?tip_id=178</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5019
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5020 Suppose there's a colorscheme that you're pretty fond of, but hate one or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5021 two particular aspects about. For example, I love the "blue" colorscheme
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5022 that ships with vim, but I find it's colors for the non-active status line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5023 to be unreadable. Here's how to create a colorscheme which extends "blue"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5024 without copying it to a new file and editing it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5025
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5026 In my ~/.vim/colors, I created a "my-blue.vim" file with these contents:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5027
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5028 "these lines are suggested to be at the top of every colorscheme hi clear
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5029 if exists("syntax_on")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5030 syntax reset
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5031 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5032
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5033 "Load the 'base' colorscheme - the one you want to alter runtime
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5034 colors/blue.vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5035
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5036 "Override the name of the base colorscheme with the name of this custom one
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5037 let g:colors_name = "my-blue"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5038
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5039 "Clear the colors for any items that you don't like hi clear StatusLine hi
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5040 clear StatusLineNC
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5041
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5042 "Set up your new & improved colors hi StatusLine guifg=black guibg=white hi
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5043 StatusLineNC guifg=LightCyan guibg=blue gui=bold
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5044
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5045 That's all there is to it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5046
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5047 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5048 <html><center>Simplify help buffer navigation</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5049 HREF="http://vim.sf.net/tip_view.php?tip_id=179">http://vim.sf.net/tip_view.php?tip_id=179</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5050
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5051 Vim is distributed with comprehensive help system, which has basic hyperlink
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5052 support - you can press &lt;C-]&gt; over |some subject| or 'some option'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5053 to read more about particular term.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5054
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5055 The following mappings simplify help buffer navigation: pressing s(or S)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5056 will find next(previous) subject from cursor position pressing o(or O) will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5057 find next(previous) option from cursor position pressing Enter will jump to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5058 subject under cursor pressing Backspace will return from the last jump
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5059
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5060 Put them into help filetype plugin (like ~/.vim/ftplugin/help.vim on UNIX).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5061
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5062 nmap &lt;buffer&gt; &lt;CR&gt; &lt;C-]&gt; nmap &lt;buffer&gt; &lt;BS&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5063 &lt;C-T&gt; nmap &lt;buffer&gt; o /'[a-z]\{2,\}'&lt;CR&gt; nmap &lt;buffer&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5064 O ?'[a-z]\{2,\}'&lt;CR&gt; nmap &lt;buffer&gt; s /\|\S\+\|&lt;CR&gt; nmap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5065 &lt;buffer&gt; S ?\|\S\+\|&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5066
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5067 </pre></tip> </html> <Tip category="KVim"> <html><center>Reload
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5068 your filetype/syntax plugin</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5069 HREF="http://vim.sf.net/tip_view.php?tip_id=180">http://vim.sf.net/tip_view.php?tip_id=180</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5070
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5071 Ever tried to write/debug your own filetype/syntax plugin?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5072
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5073 It's an iterative process which involves editing plugin code and testing it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5074 on some sample file. To see changes you made in your plugin simply do :e
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5075 on sample file. This will force Vim to reload all buffer-specific files,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5076 including your plugin.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5077
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5078 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5079 <html><center>get the vim patched source</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5080 HREF="http://vim.sf.net/tip_view.php?tip_id=181">http://vim.sf.net/tip_view.php?tip_id=181</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5081
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5082 Hi, there has been a number of person (including) asking in the vim list how
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5083 to keep up with Bram's incredible bug correction and patch writing skills, but
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5084 there is a great way to do this! Use the cvs source which is available at <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5085 HREF="http://sourceforge.net/cvs/?group_id=8">http://sourceforge.net/cvs/?group_id=8</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5086 it is kept up to date and its a lot easier than applying all the patch
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5087 in order. Benoit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5088
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5089 </pre></tip> </html> <Tip category="KVim"> <html><center>Keep
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5090 your cursor centered vertically on the screen</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5091 HREF="http://vim.sf.net/tip_view.php?tip_id=182">http://vim.sf.net/tip_view.php?tip_id=182</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5092
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5093 i hope i don't hear a collective 'DUH!' from around the world but i just
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5094 did this and i think it's kinda cool.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5095
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5096 in your .vimrc add...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5097
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5098 map j jzz map k kzz
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5099
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5100 so whenever you go up or down, vim does that and then re-centers. obviously it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5101 doesn't work when you page up/ down.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5102
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5103 </pre></tip> </html> <Tip category="KVim"> <html><center>Select
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5104 a buffer from those matching a pattern</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5105 HREF="http://vim.sf.net/tip_view.php?tip_id=183">http://vim.sf.net/tip_view.php?tip_id=183</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5106
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5107 The :bu command will take a pattern as an argument and jump to the matching
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5108 buffer. However, it's not very helpful if there is more than one buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5109 matching the pattern. In that case, it will jump to the first match, which
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5110 may not be what you want. The following function and user-command will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5111 print a list of the matching buffers in the command-line area, and allow
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5112 you to select one of the matching buffers by number.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5113
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5114 "Select from buffers matching a certain pattern "the 'pattern' argument
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5115 shouldn't be prepended with a slash
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5116
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5117 function! BufSel(pattern)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5118 let bufcount = bufnr("$") let currbufnr = 1 while currbufnr &lt;= bufcount
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5119 if(bufexists(currbufnr))
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5120 let currbufname = bufname(currbufnr) if(match(currbufname, a:pattern)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5121 &gt; -1)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5122 echo currbufnr . ": ". bufname(currbufnr)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5123 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5124 endif let currbufnr = currbufnr + 1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5125 endwhile let desiredbufnr = input("Enter buffer number: ")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5126 if(strlen(desiredbufnr) != 0)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5127 exe ":bu ". desiredbufnr
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5128 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5129 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5130
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5131 "Bind the BufSel() function to a user-command command! -nargs=1 Bs :call
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5132 BufSel("&lt;args&gt;")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5133
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5134 </pre></tip> </html> <Tip category="KVim"> <html><center>How
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5135 to obscure text instantaneously</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5136 HREF="http://vim.sf.net/tip_view.php?tip_id=184">http://vim.sf.net/tip_view.php?tip_id=184</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5137
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5138 Hi, Lets say your writing some imp. doc. and your colleague comes along. you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5139 don't wan't him to see what you are typing. so u start fumbling to type
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5140 :wq! or switch with Alt-TAB. etc. but wouldn't it be nice to just obsucre the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5141 text temporarily, so that u don't have to quit or swith to another application
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5142 using Alt-tab. (and if u don;t have any other window open u can;t even use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5143 alt-tab) well rot-13 comes to help. vim has a built in rot-13 encoder.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5144
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5145 jut put the follwoing in your .vimrc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5146
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5147 map &lt;F3&gt; ggVGg?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5148
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5149 so next time some body comes along just press &lt;F3&gt; and all the buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5150 will be rot-13 encoded. to decode just press &lt;f3&gt; again. Njoy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5151
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5152 </pre></tip> </html> <Tip category="KVim"> <html><center>Make vim the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5153 editor for files with unregistered extensions in Windows</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5154 HREF="http://vim.sf.net/tip_view.php?tip_id=185">http://vim.sf.net/tip_view.php?tip_id=185</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5155
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5156 Normally in Windows, if you try to "launch" a file whose extension is not
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5157 registered with the system, the OS will prompt you for what editor you would
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5158 like to use to open the file. A much more appealing solution, in my mind,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5159 is to make vim the default editor for any unregistered extension.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5160
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5161 To set vim up as the default editor for unregistered extensions, follow
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5162 these steps: 1. Copy the following into a file named unregistered.reg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5163 -------------begin unregistered.reg----------------- REGEDIT4
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5164 [HKEY_CLASSES_ROOT\Unknown\shell\Open\Command] @="d:\\program
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5165 files\\vim\\vim60\\gvim.exe \"%1\"" -------------end
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5166 unregistered.reg-----------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5167
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5168 2. Import unregistered into your registry. This can be done in vim by
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5169 executing the following :!regedit "unregistered.reg"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5170
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5171 Disclaimer: This has been tested only on NT4.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5172
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5173 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5174 <html><center>Making search powerful</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5175 HREF="http://vim.sf.net/tip_view.php?tip_id=186">http://vim.sf.net/tip_view.php?tip_id=186</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5176
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5177 My tip is just a bunch of mappings that can be used while searching.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5178
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5179 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5180 <html><center>Making search powerful</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5181 HREF="http://vim.sf.net/tip_view.php?tip_id=187">http://vim.sf.net/tip_view.php?tip_id=187</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5182
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5183 (Sorry, I think I accidentally added an incomplete tip)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5184
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5185 My tip is just a bunch of mappings that can be used while searching.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5186 What it does?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5187 o. Extend your current search. (kinda emacs search where you can search
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5188 each occurences
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5189 one by one and go back to the cursor position.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5190 o. Scroll/position during mapping. o. Other miscellaneous stuffs ;) read on
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5191
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5192 How to use?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5193 o. copy and paste the mappings into a file o. open vim (like vim .profile)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5194 o. :so &lt;saved-file&gt; o. start using the mappings
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5195
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5196 Note:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5197 In case these mappings dont work run like, 'vim -u NONE -U NONE -c
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5198 "so the-saved-file.vim"'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5199
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5200 Some of my mappings override the default vim bindings. (like Ctrl-A,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5201 Ctrl-Q). I selected those because, I feel by taking those I can do all
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5202 the search stuff with my left hand.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5203
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5204 One thing I did not like with this is, I usually miss the "search hit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5205 bottom" message. I could have handled that by complicating the current
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5206 mappings, but I preferred to make it simple
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5207
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5208 Mappings Used / =&gt; regular forward search start ? =&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5209 regular backward search start Rest of the mappings are used during search
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5210 Ctrl-A =&gt; search again forward (In normal mode, search forward with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5211 the word under cursor) Ctrl-Q =&gt; search again backward (in normal mode,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5212 search backward with the word under cursor) Ctrl-X =&gt; restore cursor (use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5213 at any point of time/during-any-operation mentioned during searching) Ctrl-F
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5214 =&gt; search with the word under cursor Ctrl-G =&gt; incrementally add the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5215 letters following the search pattern (in current line) Ctrl-T Ctrl-T =&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5216 search for the exact Ctrl-T Ctrl-Y =&gt; search partial (just strips \&lt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5217 and \&gt;) Ctrl-E =&gt; scroll up during searching Ctrl-Y =&gt; scroll down
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5218 during searching Ctrl-Z Ctrl-Z =&gt; position the cursor to mid of screen
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5219 (like zz in normal) Ctrl-Z Ctrl-A =&gt; position the cursor to top of screen
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5220 (like zt in normal) Ctrl-Z Ctrl-X =&gt; position the cursor to bottom of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5221 screen (like zb in normal)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5222
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5223 Misc: Ctrl-K during search save the current matching line Ctrl-K in normal
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5224 mode pastes the saved line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5225
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5226 C mappings Ctrl-V Ctrl-G search for the global variable of the search
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5227 pattern/word under cursor Ctrl-V Ctrl-H search for the local variable of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5228 the search pattern/word under cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5229
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5230 " --- cut n paste from here to end of document --- se nocp incsearch " core
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5231 mappings noremap / mg/ noremap ? mg? ounmap / ounmap ? noremap &lt;C-A&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5232 mg"gyiw/&lt;C-R&gt;g cnoremap &lt;C-A&gt; &lt;CR&gt;/&lt;Up&gt; cnoremap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5233 &lt;C-X&gt; &lt;CR&gt;`g cnoremap &lt;C-Q&gt; &lt;CR&gt;?&lt;Up&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5234
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5235 " extending current search mappings cnoremap &lt;C-F&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5236 &lt;CR&gt;yiw&lt;BS&gt;/&lt;C-R&gt;" cnoremap &lt;C-G&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5237 &lt;CR&gt;y/&lt;Up&gt;/e+1&lt;CR&gt;&lt;BS&gt;/&lt;C-R&gt;=escape(@",'.*\/?')&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5238
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5239 " miscellaneous: copy current line during search and later paste in NORMAL
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5240 mode cnoremap &lt;C-K&gt; &lt;CR&gt;"hyy?&lt;Up&gt;&lt;CR&gt;/&lt;Up&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5241 noremap &lt;C-K&gt; "hp
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5242
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5243 " exact/partial search mappings cnoremap &lt;C-T&gt;&lt;C-T&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5244 &lt;Home&gt;\&lt;&lt;C-End&gt;\&gt; cnoremap &lt;C-T&gt;&lt;C-Y&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5245 &lt;Home&gt;&lt;Del&gt;&lt;Del&gt;&lt;End&gt;&lt;Del&gt;&lt;Del&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5246
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5247 " C global/local variable search mappings noremap &lt;C-V&gt;&lt;C-G&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5248 mgyiw&lt;CR&gt;gg/\&lt;&lt;C-R&gt;"\&gt; noremap &lt;C-V&gt;&lt;C-H&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5249 mgyiw?^{&lt;CR&gt;/\&lt;&lt;C-R&gt;"\&gt; cnoremap &lt;C-V&gt;&lt;C-G&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5250 &lt;CR&gt;yiwgg/\&lt;&lt;C-R&gt;"\&gt; cnoremap &lt;C-V&gt;&lt;C-H&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5251 &lt;CR&gt;yiw?^{&lt;CR&gt;/\&lt;&lt;C-R&gt;"\&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5252
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5253 " positioning/scrolling during search mappings cnoremap &lt;C-E&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5254 &lt;CR&gt;mt&lt;C-E&gt;`t&lt;BS&gt;/&lt;Up&gt; cnoremap &lt;C-Y&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5255 &lt;CR&gt;&lt;C-Y&gt;&lt;BS&gt;/&lt;Up&gt; cnoremap &lt;C-Z&gt;&lt;C-A&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5256 &lt;CR&gt;zt&lt;BS&gt;/&lt;Up&gt; cnoremap &lt;C-Z&gt;&lt;C-X&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5257 &lt;CR&gt;zb&lt;BS&gt;/&lt;Up&gt; cnoremap &lt;C-Z&gt;&lt;C-Z&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5258 &lt;CR&gt;zz&lt;BS&gt;/&lt;Up&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5259
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5260 " VISUAL mappings vnoremap / ymg/&lt;C-R&gt;=escape(@",'.*\/?')&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5261 vnoremap ? ymg?&lt;C-R&gt;=escape(@",'.*\/?')&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5262
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5263 </pre></tip> </html> <Tip category="KVim"> <html><center>Searching
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5264 for more than one word at the same time.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5265 HREF="http://vim.sf.net/tip_view.php?tip_id=188">http://vim.sf.net/tip_view.php?tip_id=188</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5266
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5267 Did you know that with VIM u can search for more than one word with a single
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5268 command. say you want to search all occurances of "bill" or "ted", or "harry"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5269 in a text. in normal mode do the following. /\(bill\)\|\(ted\)\|\(harry\)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5270 &lt;Enter&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5271
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5272 this will match all instances of either "bill", or "ted", or "harry" in your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5273 text. the key is the \(\) and \| operators. \(\) group characters in a word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5274 and \| is for ORing.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5275
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5276 this is so cool u can even use it for replacing text. to replace all
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5277 instances of "bill" or "ted" or "harry" with "greg" do the following
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5278 :%s/\(bill\)\|\(ted\)\|\(harry\)/greg/g &lt;enter&gt; (note :- if u have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5279 set the option "gdefault" u don't need the "g" at the end of the above command)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5280
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5281 I don't know of any other editor which can do this, with so much ease.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5282 Rock on VIM Njoy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5283
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5284 </pre></tip> </html> <Tip category="KVim"> <html><center>Make
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5285 Ctrl-Backspace delete previous word (like GTK inputs)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5286 HREF="http://vim.sf.net/tip_view.php?tip_id=189">http://vim.sf.net/tip_view.php?tip_id=189</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5287
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5288 Stuff this into your ~/.gvimrc and then you'll be able to type
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5289 Control-Backspace to delete the previous word. I had gotten so used to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5290 C-BS working a certain way in all my editors with a ceezy input area (like
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5291 mozilla/galeon, gabber, etc...), that I wanted the same behaviour when I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5292 used gvim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5293
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5294 " map control-backspace to delete the previous word :imap &lt;C-BS&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5295 &lt;Esc&gt;vBc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5296
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5297 Simple, I know, but reasonably useful.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5298
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5299 --Robert
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5300
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5301 </pre></tip> </html> <Tip category="KVim"> <html><center>XP &gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5302 I-Explorer &gt; HTML Editor &lt; REG files</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5303 HREF="http://vim.sf.net/tip_view.php?tip_id=190">http://vim.sf.net/tip_view.php?tip_id=190</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5304
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5305 The issue is permitting other programs, besides NOTEPAD, be the HTML editor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5306 under Internet Explorer. (Adding "Edit" as a New Action in the publicly
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5307 exposed Files Types for HTM/L does NOT do the job.)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5308
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5309 Given below are two REG files for vim. Just cut 'em up where indicated.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5310 They have been tested under Windows XP.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5311
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5312 -------------------------------------------------------CUT HERE---------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5313 Windows Registry Editor Version 5.00
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5314
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5315 ; GOAL: Set gvim as HTML editor in Internet Explorer 6.0 ; Vim version :
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5316 6.0 ; Windows version: XP ; EASY USAGE: name this file iex-vim60.reg and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5317 double click on it ; Hard Usage: IMPORT this file using REGEDIT.EXE found
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5318 in c:\WINDOWS ; Last modified date : Dec 16, 2001
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5319
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5320 ; gvim is expected in "C:\Program Files\Vim\vim60\gvim.exe" ; Be sure to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5321 also reset Explorer&gt;Tools&gt;Internet Options&gt;Programs
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5322
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5323 ; Microsoft documentation ; <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5324 HREF="http://msdn.microsoft.com/workshop/browser/configuration/clientreg/clientregistrylayout.asp">http://msdn.microsoft.com/workshop/browser/configuration/clientreg/clientregistrylayout.asp</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5325
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5326 ; Add Vim in the list of supported HTML editors
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5327 [HKEY_CLASSES_ROOT\.htm\OpenWithList\Vim]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5328
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5329 [HKEY_CLASSES_ROOT\.htm\OpenWithList\Vim\shell]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5330
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5331 [HKEY_CLASSES_ROOT\.htm\OpenWithList\Vim\shell\edit]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5332
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5333 [HKEY_CLASSES_ROOT\.htm\OpenWithList\Vim\shell\edit\command] @="\"C:\\Program
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5334 Files\\Vim\\vim60\\gvim.exe\" \"%1\""
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5335
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5336 ; Do NOT add to .html, registry for .htm type suffices
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5337 ;[HKEY_CLASSES_ROOT\.html\OpenWithList\Vim]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5338
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5339 ;[HKEY_CLASSES_ROOT\.html\OpenWithList\Vim\shell]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5340
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5341 ;[HKEY_CLASSES_ROOT\.html\OpenWithList\Vim\shell\edit]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5342
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5343 ;[HKEY_CLASSES_ROOT\.html\OpenWithList\Vim\shell\edit\command]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5344 ;@="\"C:\\Program Files\\Vim\\vim60\\gvim.exe\" \"%1\""
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5345
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5346 ; OPTIONAL: Within Internet Explorer "View Source" with gvim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5347 ; but prefer to use Edit button (got to add this) on Toolbar
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5348 ;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5349
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5350 ;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5351 Editor\Editor Name] ;@="C:\\Program Files\\Vim\\vim60\\gvim.exe"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5352
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5353 ; ============================================= EOF
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5354
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5355 -------------------------------------------------------CUT HERE---------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5356 Windows Registry Editor Version 5.00
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5357
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5358 ; GOAL: UNINSTALL gvim as HTML editor in Internet Explorer 6.0 ; Vim version :
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5359 6.0 ; Windows version: XP ; EASY USAGE: name this file iex-vim60-uninstall.reg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5360 and double click on it ; Hard Usage: IMPORT this file using REGEDIT.EXE
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5361 found in c:\WINDOWS ; Last modified date : Dec 16, 2001
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5362
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5363 ; gvim is expected in "C:\Program Files\Vim\vim60\gvim.exe" ; Be sure to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5364 also reset Explorer&gt;Tools&gt;Internet Options&gt;Programs
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5365
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5366 ; Microsoft documentation ; <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5367 HREF="http://msdn.microsoft.com/workshop/browser/configuration/clientreg/clientregistrylayout.asp">http://msdn.microsoft.com/workshop/browser/configuration/clientreg/clientregistrylayout.asp</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5368
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5369 [-HKEY_CLASSES_ROOT\.htm\OpenWithList\Vim]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5370
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5371 [-HKEY_CLASSES_ROOT\.html\OpenWithList\Vim]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5372
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5373 [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5374
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5375 ; ============================================= EOF
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5376 -------------------------------------------------------CUT HERE---------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5377
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5378 Happy Vimming...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5379
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5380 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5381 <html><center>Transposing</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5382 HREF="http://vim.sf.net/tip_view.php?tip_id=191">http://vim.sf.net/tip_view.php?tip_id=191</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5383
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5384 You can easily move lines with these maps using &lt;C-Up&gt; and &lt;C-Down&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5385 (only in GUI version :( ) (Works in normal, insert, and visual mode, but
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5386 you can't add a count to them) " Transposing lines nmap &lt;C-Down&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5387 :&lt;C-u&gt;move .+1&lt;CR&gt; nmap &lt;C-Up&gt; :&lt;C-u&gt;move .-2&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5388
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5389 imap &lt;C-Down&gt; &lt;C-o&gt;:&lt;C-u&gt;move .+1&lt;CR&gt; imap &lt;C-Up&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5390 &lt;C-o&gt;:&lt;C-u&gt;move .-2&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5391
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5392 vmap &lt;C-Down&gt; :move '&gt;+1&lt;CR&gt;gv vmap &lt;C-Up&gt; :move
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5393 '&lt;-2&lt;CR&gt;gv
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5394
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5395 " Transpose chars (like Ctrl-T in emacs, shell...) imap &lt;C-F&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5396 &lt;Esc&gt;Xpa
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5397
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5398 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5399 <html><center>Latex Help for VIM</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5400 HREF="http://vim.sf.net/tip_view.php?tip_id=192">http://vim.sf.net/tip_view.php?tip_id=192</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5401
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5402 LaTeX Help for aucTeX `translated' as vim help file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5403
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5404 Installing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5405
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5406 :help add-local-help
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5407
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5408 </pre></tip> </html> <Tip category="KVim"> <html><center>Insert
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5409 the current filename at cursor postion.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5410 HREF="http://vim.sf.net/tip_view.php?tip_id=193">http://vim.sf.net/tip_view.php?tip_id=193</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5411
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5412 I found this one good for when I was starting to learn Java, it simply inserts
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5413 the current filename, at the cursor position, when you are in insert mode.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5414 Honestly, its a mish-mash of some other tips I found here, but I thought it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5415 might be useful.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5416
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5417 imap \fn &lt;C-R&gt;=expand("%:t:r")&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5418
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5419 Enjoy!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5420
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5421 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5422 <html><center>Inserting text in multiple lines</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5423 HREF="http://vim.sf.net/tip_view.php?tip_id=194">http://vim.sf.net/tip_view.php?tip_id=194</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5424
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5425 Do you know the I key in visual-block mode?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5426
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5427 Suppose you have let a=2 let b=3 let c=4
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5428
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5429 You want to make these variables script-wise. Then you move to over a, hit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5430 &lt;C-v&gt;, press jj and now press I. You will be in insert mode before a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5431 Now enter s:&lt;Esc&gt;, and when you press &lt;Esc&gt;, b and c will have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5432 the s: prefix too. See |v_b_I|
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5433
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5434 Happy vimming! Gergely Kontra
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5435
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5436 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5437 <html><center>Switching between files</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5438 HREF="http://vim.sf.net/tip_view.php?tip_id=195">http://vim.sf.net/tip_view.php?tip_id=195</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5439
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5440 When you edit multiple files, you often need to change windows. You can set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5441 up vim in windows and gvim to switch between windows with the commonly used
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5442 Ctrl-Tab and Ctrl-Shift-Tab The mappings nmap &lt;C-Tab&gt; &lt;C-w&gt;w
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5443 nmap &lt;C-S-Tab&gt;&lt;C-w&gt;W (They wrap around) See also |Ctrl-w|
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5444
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5445 </pre></tip> </html> <Tip category="KVim"> <html><center>FileName
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5446 Completion in Shell Scripts</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5447 HREF="http://vim.sf.net/tip_view.php?tip_id=196">http://vim.sf.net/tip_view.php?tip_id=196</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5448
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5449 In shell scripts, you often define environment variables for diff directory
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5450 names. i.e. JAVA_HOME=/opt/java/jdk1.4 PATH=/usr/local/bin:/bin....
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5451
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5452 Normally typing Ctrl-X Ctrl-F is used to complete FileName under cursor.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5453 But this does not work if used on lines given above. This is because vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5454 treats "=" sign as a valid filename character. Since the actual possibility
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5455 of "=" being in any filename is very less, this char can be removed from
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5456 the list of valid filename char.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5457
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5458 set isfname-==
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5459
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5460 putting the above line in .vimrc will remove "=" from the list of valid
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5461 filename chars. thus u can easyly complete filenames using &lt;Ctrl-X&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5462 &lt;Ctrl-F&gt; Njoy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5463
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5464 </pre></tip> </html> <Tip category="KVim"> <html><center>Open
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5465 file in already running vim from elsewhere</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5466 HREF="http://vim.sf.net/tip_view.php?tip_id=197">http://vim.sf.net/tip_view.php?tip_id=197</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5467
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5468 If you want edit new file, and you want do it in alrady running vim,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5469 instead of launching another instance, you may use --remote argument:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5470
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5471 gvim first_file gvim --remote +split first_file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5472
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5473 :he --remote It requires X windows (but works in terminal version of vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5474 there too) or MS windows and built-in client-server mechanism. If there are
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5475 several instances of vim already running, you may choose to which you talk
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5476 using --servername :help --servername
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5477
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5478 </pre></tip> </html> <Tip category="KVim"> <html><center>Pasting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5479 code with syntax coloring in emails</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5480 HREF="http://vim.sf.net/tip_view.php?tip_id=198">http://vim.sf.net/tip_view.php?tip_id=198</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5481
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5482 When sending code snippets or diffs to your colleagues either for code review
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5483 or for something else as email, how nice and clear it will be if you can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5484 paste it with the Vim syntax highlighting? I am sure they will be impressed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5485 and feel much easier to read the code. It is also very easy and fast (once
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5486 you practice it) to do this.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5487
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5488 This probably works only on windows and requires you to use Internet Explorer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5489 and an email client that understand RTF content coming from clipboard, such
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5490 as Outlook or Outlook Express. At least that would make the process faster. I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5491 haven't tried on any other combination though. This is what you need to do:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5492
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5493 - Open the file containing the code/code snippet/diff etc. in gvim. If you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5494 use dark background for GVim (like me), then I would suggest you to change
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5495 your color scheme temporarily to something else that has a white background
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5496 or just use the "-U NONE" as below:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5497
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5498 gvim -U NONE &lt;file&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5499
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5500 - Convert the file into HTML by using the following command at the colon
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5501 prompt as below:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5502
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5503 :runtime syntax/2html.vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5504
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5505 - The above step will open a new window with the HTML content in it. You might
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5506 want to just save it with the suggested name or write into a temporary file as:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5507
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5508 :w! c:/tmp/t.html
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5509
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5510 - Open the IE browser window and open the above temp file "c:/tmp/t.html".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5511 - Now you select all (press ^A) and copy it (^C). - You are ready to paste
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5512 it with syntax coloring in any application that accepts RTF content from
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5513 clipboard, including Outlook or Outlook Express mail composing window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5514
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5515 </pre></tip> </html> <Tip category="KVim"> <html><center>maximize
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5516 window and return to previous split structure</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5517 HREF="http://vim.sf.net/tip_view.php?tip_id=199">http://vim.sf.net/tip_view.php?tip_id=199</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5518
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5519 Say you have layed out a complex window split structure, and want to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5520 temporarily open 1 window with max dimensions, but don't want to lose your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5521 split structure. The following function and mappings let you toggle between
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5522 the split windows and on window maximized. The mappings prevent the default
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5523 behavior of calling :only and losing your finely tuned splits.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5524
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5525 Put this bit in your vimrc file, change mappings if you don't want to override
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5526 the defaults:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5527
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5528 nnoremap &lt;C-W&gt;O :call MaximizeToggle ()&lt;CR&gt; nnoremap &lt;C-W&gt;o
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5529 :call MaximizeToggle ()&lt;CR&gt; nnoremap &lt;C-W&gt;&lt;C-O&gt; :call
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5530 MaximizeToggle ()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5531
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5532 function! MaximizeToggle()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5533 if exists("s:maximize_session")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5534 source s:maximize_session call delete(s:maximize_session)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5535 unlet s:maximize_session let &hidden=s:maximize_hidden_save
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5536 unlet s:maximize_hidden_save
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5537 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5538 let s:maximize_hidden_save = &hidden let s:maximize_session =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5539 tempname() set hidden mksession! s:maximize_session only
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5540 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5541 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5542
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5543 </pre></tip> </html> <Tip category="KVim"> <html><center>Bouncing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5544 Parentheses (during insertion)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5545 HREF="http://vim.sf.net/tip_view.php?tip_id=200">http://vim.sf.net/tip_view.php?tip_id=200</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5546
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5547 When one is inserting parentheses some folks like to see the cursor bounce
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5548 off the matching parenthesis. To do that, put the following map into your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5549 &lt;.vimrc&gt; file:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5550
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5551 inoremap ) )&lt;c-o&gt;%&lt;c-o&gt;:sleep
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5552 500m&lt;CR&gt;&lt;c-o&gt;%&lt;c-o&gt;a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5553
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5554 Adjust the time delay (its 500 milliseconds above) to suit your needs.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5555
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5556 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5557 <html><center>The meaning of life</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5558 HREF="http://vim.sf.net/tip_view.php?tip_id=201">http://vim.sf.net/tip_view.php?tip_id=201</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5559
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5560 Use this tip if you need to discover the meaning of life, the universe
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5561 and everything.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5562
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5563 Simply do: :h 42
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5564
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5565 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5566 <html><center>debugging window autocommands</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5567 HREF="http://vim.sf.net/tip_view.php?tip_id=202">http://vim.sf.net/tip_view.php?tip_id=202</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5568
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5569 Don't know how people debug autocommands, but I just found out that you can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5570 debug (at least) those that result due to window close by just doing a debug
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5571 quit, i.e.,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5572
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5573 :debug quit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5574
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5575 Vim will let you step into the autocommands. Try it to believe.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5576
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5577 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5578 <html><center>Make make more helpful</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5579 HREF="http://vim.sf.net/tip_view.php?tip_id=203">http://vim.sf.net/tip_view.php?tip_id=203</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5580
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5581 I find this a very useful command to use. Add the below 4 lines to your vimrc.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5582 Then instead of "make" use "Make".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5583
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5584 " Command Make will call make and then cwindow which " opens a 3 line error
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5585 window if any errors are found. " if no errors, it closes any open cwindow.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5586 :command -nargs=* Make make &lt;args&gt; | cwindow 3
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5587
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5588 </pre></tip> </html> <Tip category="KVim"> <html><center>Some
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5589 mappings for using cscope with vim.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5590 HREF="http://vim.sf.net/tip_view.php?tip_id=204">http://vim.sf.net/tip_view.php?tip_id=204</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5591
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5592 These mappings can make using cscope a fun. You can copy the word under the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5593 cursor in one window, and search for it from other window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5594
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5595 " Copy and paste the word under cursor map &lt;silent&gt; &lt;C-Space&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5596 :let@m=expand("&lt;cword&gt;")&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5597
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5598 " Use the C-Space word as the search criterion map &lt;C-F6&gt; :cscope
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5599 find s &lt;C-R&gt;=@m&lt;CR&gt;&lt;CR&gt; map &lt;C-F5&gt; :cscope find
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5600 c &lt;C-R&gt;=@m&lt;CR&gt;&lt;CR&gt; map &lt;C-F7&gt; :cscope find g
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5601 &lt;C-R&gt;=@m&lt;CR&gt;&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5602
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5603 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5604 <html><center>Computing a sum of numbers in vim</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5605 HREF="http://vim.sf.net/tip_view.php?tip_id=205">http://vim.sf.net/tip_view.php?tip_id=205</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5606
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5607 "Sometimes you need to sum a some numbers in vim. There *are* some plugins
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5608 "that can do the job. But what if the numbers are not in a columns or are on
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5609 "the same line or are sacttered all across the file? You might also need to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5610 "sum all the numbers in file that look like '1234$', or '54565 Eu' ignoring
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5611 others. " "There is a very simple trick, using (my favourite) command ":s "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5612 "First you define following function
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5613
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5614 :let g:S=0 "In global variable S we later find the result
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5615
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5616 :function! Sum(number) "The function is defined with a '!',
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5617 "so it does not complain during debugging
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5618 "when you are redefining the function
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5619 :let g:S=g:S+a:number "we accumulate the result in global variable
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5620 S :return a:number "function returns the argument, so after a :s
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5621 "command the text remains the same
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5622 :endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5623
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5624 "you can do issue those few commands from a command line, "or create a small
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5625 file and put it into your plugin directory, "or write those few commands
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5626 into a file end issue a command :so %
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5627
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5628 "how to use this little function: "let's suppose you have a simple
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5629 column of numbers like " "10 "20 "30 " "you issue command like: :let S=0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5630 :%s/[0-9]\+/\=Sum(submatch(0))/ "the command finds the first number on the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5631 line and adds it to the S " "the result is displayed :echo $S
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5632
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5633 "!!!! don't forget to do :let g:S=0 "before use.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5634
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5635 "you can also use \zs and \ze atoms in a regular expression to "delimit the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5636 number, so submatch(0) returns only a number and "the text remains unchanged
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5637 after 'substitute'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5638
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5639 "for starter on the wonderfull world of regular expressions see: :help
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5640 usr_27.txt
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5641
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5642 "for the definition of the search pattern see :help :s :help pattern
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5643
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5644 "for replacement strings begining with \= and special function submatch(0)see
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5645 :help sub-replace-special
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5646
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5647 "for the *ultimate* guide through the world of regular expressions see book:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5648 "Mastering Regular Expressions "Powerful Techniques for Perl and Other Tools
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5649 "by Jeffrey E.F. Friedl "from O'REILLY
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5650
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5651 "the book does not write about vim, yet here you can learn that ":s command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5652 is the most powerfull command you can find in a text editor. "(with the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5653 possible exception of :global command)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5654
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5655 </pre></tip> </html> <Tip category="KVim"> <html><center>Highlight
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5656 doubled word errors in text</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5657 HREF="http://vim.sf.net/tip_view.php?tip_id=206">http://vim.sf.net/tip_view.php?tip_id=206</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5658
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5659 An error I sometimes make while working on a LaTeX file is the repetition of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5660 a word as in "the the". Most often, such doubled words come about through
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5661 a careless edit. Doubled words are hard to spot when the first word of the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5662 doubled pair is the last word on one line, and the second word of the pair
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5663 is the the first word on the next line. There is an example of such an error
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5664 in the last sentence. Vim's syntax mechanism can be used to highlight doubled
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5665 words as an error.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5666
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5667 To obtain this highlighting for TeX and LaTeX files, place the following
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5668 two lines:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5669
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5670 syn match texDoubleWord "\c\&lt;\(\a\+\)\_s\+\1\&gt;" hi def link
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5671 texDoubleWord Error
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5672
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5673 in a file called tex.vim in the directory that shows up last in your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5674 runtimepath (:set runtimepath? to check). This will often be either
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5675 ~/.vim/after/syntax/tex.vim or $VIM/vimfiles/after/syntax/tex.vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5676
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5677 The same effect can be obtained for files of a different filetype, say html,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5678 by putting the same lines in a file called html.vim in the same location.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5679
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5680 For more on the runtimepath, :he runtimepath. For more on syntax highlighting,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5681 :he syntax
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5682
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5683 </pre></tip> </html> <Tip category="KVim"> <html><center>editing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5684 databases with Vim/Perl/DBI</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5685 HREF="http://vim.sf.net/tip_view.php?tip_id=207">http://vim.sf.net/tip_view.php?tip_id=207</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5686
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5687 Perl's Data-Base-Independent (DBI) module provides programming language
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5688 level access to a lot of databases.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5689
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5690 Vim hosts an embedded Perl interpreter. So it is only a matter of some key
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5691 strokes to interactively issue DB commands from within Vim or to search,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5692 edit, and replace database contents including retrieval and storage. Of course
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5693 "create table" scripts can be worked upon in Vim as well as storing recurring
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5694 patterns in Vim functions or Perl modules.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5695
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5696 Prerequisites: Vim needs to be compiled with Perl support enabled. See the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5697 |if_perl.txt| manual page! The CPAN module DBI as well as an appropriate
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5698 database driver has to be installed with Perl in order to execute these
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5699 Vim commands:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5700
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5701 " connect to perl's dbi module: :perl use dbi;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5702
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5703 " connect to the database: :perl $dbh = dbi-&gt;connect(
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5704 "DBI:mysql:$DBNAME:$HOST",$USER,$PASSWORD,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5705 { raiseerror =&gt; 1});
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5706
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5707 " perform a simple query: :perl $result = $dbh-&gt;selectall_arrayref("show
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5708 tables;");
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5709
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5710 " insert the list of tables into the current buffer's top: :perl
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5711 $curbuf-&gt;Append(0, map($_-&gt;[0], @{$result}));
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5712
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5713 In MySql the command "show tables;" results in a list of table names. Inserted
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5714 into a Vim buffer this results in one line per table.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5715
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5716 You can find more on my web page <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5717 HREF="http://members.chello.at/intelliware/dbEdit">http://members.chello.at/intelliware/dbEdit</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5718
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5719 </pre></tip> </html> <Tip category="KVim"> <html><center>Alter
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5720 the display of buffers in the buffers menu</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5721 HREF="http://vim.sf.net/tip_view.php?tip_id=208">http://vim.sf.net/tip_view.php?tip_id=208</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5722
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5723 If you use the buffers menu, here's where you can change how the buffernames
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5724 are displayed:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5725
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5726 menu.vim, function s:BMMunge
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5727
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5728 OLD: let name2 = name2 . ' (' . a:bnum . ')'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5729
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5730 displays:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5731
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5732 .vimrc (1) menu.vim (2)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5733
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5734 NEW: let name2 = '&' . a:bnum . '. ' . name2
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5735
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5736 displays
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5737
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5738 1. .vimrc 2. menu.vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5739 (with the 1 and the 2 underlined)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5740
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5741 which is more useful, because you can (almost) always pick the buffer you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5742 want with one keystroke, the buffernumber, until you get to buffer 10 anyway.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5743
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5744 Roger
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5745
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5746 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5747 <html><center>backtracking your movements in a file</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5748 HREF="http://vim.sf.net/tip_view.php?tip_id=209">http://vim.sf.net/tip_view.php?tip_id=209</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5749
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5750 If you are jumping from one line to another a lot. You may find the "Ctrl-o"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5751 command handy. Usually u can set markers in a buffer to keep track of your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5752 movements. but Ctrl-o makes it even easier. it takes you back sequentially
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5753 to all your previous cursor locations in a buffer. just press ctrl-o in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5754 normal mode and u will go to your last cursor position.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5755
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5756 Njoy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5757
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5758 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5759 <html><center>compiling the actual file with gcc</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5760 HREF="http://vim.sf.net/tip_view.php?tip_id=210">http://vim.sf.net/tip_view.php?tip_id=210</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5761
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5762 if you use set makeprg=gcc\ -o\ %&lt;\ % in your .vimrc, and your actual
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5763 file is file.c, then :make will compile file.c with the output file. (gcc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5764 file.c -o file).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5765
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5766 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5767 <html><center>Rotate color themes</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5768 HREF="http://vim.sf.net/tip_view.php?tip_id=211">http://vim.sf.net/tip_view.php?tip_id=211</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5769
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5770 This tip is for those who like to change their vim color themes pretty often.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5771 I like different themes just for a change in my work environment. To achieve
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5772 this just add the following to your .vimrc or _vimrc file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5773
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5774 let themeindex=0 function! RotateColorTheme()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5775 let y = -1 while y == -1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5776 let colorstring =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5777 "#blue.vim#elflord.vim#evening.vim#koehler.vim#murphy.vim#pablo.vim#ron.vim#"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5778 let x = match(colorstring,"#",g:themeindex) let y =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5779 match(colorstring,"#",x+1) let g:themeindex = x+1 ":echo x
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5780 y g:themeindex if y == -1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5781 let g:themeindex = 0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5782 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5783 let themestring = strpart(colorstring,x+1,y-x-1)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5784 echo("Setting Theme to-&gt; ".themestring) return
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5785 ":so $VIMRUNTIME/colors/".themestring
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5786 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5787 endwhile
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5788 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5789
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5790 Change the value of colorstring above by changing the line let colorstring =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5791 "#blue.vim#elflord.vim#evening.vim#koehler.vim#murphy.vim#pablo.vim#ron.vim#"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5792 You can add your favorite color themes in this string so that you can rotate
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5793 between them. Just make sure that any string that you add is in between the #
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5794 as shown above. Just follow the format above and things will work.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5795
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5796 Then assign a key to roate the theme. map &lt;F8&gt; :execute
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5797 RotateColorTheme()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5798
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5799 Dunno if there are better ways to do the same. I just did a "help eval"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5800 and wrote the above.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5801
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5802 </pre></tip> </html> <Tip category="KVim"> <html><center>Setting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5803 file attributes without reloading a buffer</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5804 HREF="http://vim.sf.net/tip_view.php?tip_id=212">http://vim.sf.net/tip_view.php?tip_id=212</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5805
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5806 While creating scripts and others executable files with Vim it is needed to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5807 set UNIX executable bit on the file. You can do this from inside Vim with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5808 :!chmod a+x %. The % represents current buffer's filename. The problem is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5809 that Vim will notice attribute changes and prompt you to reload a file. If
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5810 you do this, your undo history for the file will be lost.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5811
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5812 The following function facilitate changing executable attributes without
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5813 reloading a buffer. Thanks to Bram for the algorithm for this function.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5814
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5815 fun! SetExecutableBit()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5816 let fname = expand("%:p") :checktime exec "au FileChangedShell
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5817 " . fname . " :echo" :silent !chmod a+x % :checktime exec
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5818 "au! FileChangedShell " . fname
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5819 endfun
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5820
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5821 " Create an EX command that will call the function. command -nargs=0 Xbit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5822 call SetExecutableBit()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5823
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5824 Now you can type :Xbit to make the file executable!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5825
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5826 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5827 <html><center>delet all lines containt TXT</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5828 HREF="http://vim.sf.net/tip_view.php?tip_id=213">http://vim.sf.net/tip_view.php?tip_id=213</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5829
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5830 I needed this one when I was editing an ldif file:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5831
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5832 I needed to delete all lines containing "profile":
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5833
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5834 :g/profile/d
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5835
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5836 very handydandy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5837
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5838 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5839 <html><center>Current buffer based menus</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5840 HREF="http://vim.sf.net/tip_view.php?tip_id=214">http://vim.sf.net/tip_view.php?tip_id=214</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5841
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5842 If you have different menus for different filetypes, and you want to have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5843 only the menu relevant to current buffer displayed, you can use this approach:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5844
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5845 in .vimrc: au BufEnter * if exists('b:BuffEnter')|exec b:BuffEnter|endif au
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5846 BufLeave * if exists('b:BuffEnter')|exec b:BuffLeave|endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5847
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5848 In appropriate ftplugin/?.vim, there are assigned commands to create or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5849 destroy the menus - here typed in directly, may be of course call to a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5850 menu-generating function or whatever.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5851
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5852 let b:BuffEnter='amenu C.added ...' let b:BuffLeave='unmenu! C|unmenu C'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5853
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5854 </pre></tip> </html> <Tip category="KVim"> <html><center>Edit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5855 configuration files for a filetype</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5856 HREF="http://vim.sf.net/tip_view.php?tip_id=215">http://vim.sf.net/tip_view.php?tip_id=215</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5857
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5858 When you open a file, vim may load several scripts to customize itself for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5859 editing the file type the file is associated with (for example a file "test.c"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5860 is associated with the filetype "c"). Such configurations include the setting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5861 of syntax highlighting colors (:help syntax) and support for indentation
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5862 (:help filetype-indent-on). When you start to override these files for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5863 yourself, it can sometimes be confusing, which file sets a specific option.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5864 The following function can be used, to edit the configuration files which
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5865 are associated with a specific filename. It open a buffer for all files which
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5866 get loaded. If I invoke it with ':call Edit_ft_conf("test.c")', for example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5867 I end up with the following buffers / windows:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5868 1 a "[No File]" line 1 2 a "test.c"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5869 line 1 3 a= "/usr/local/share/vim/vim60/syntax/c.vim"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5870 line 1 4 a "~/.vim/after/syntax/c.vim" line 1 5 #a=
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5871 "/usr/local/share/vim/vim60/indent/c.vim" line 1 6 %a=
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5872 "/usr/local/share/vim/vim60/ftplugin/c.vim" line 1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5873
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5874 Here comes the function:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5875
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5876 " Edit filetype configuration files " Usage: ':call Edit_ft_conf("file")'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5877 " Purpose: open all scripts which get loaded implicitly by opening "file" "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5878 (syntax highlighting, indentation, filetype plugins, ..) " The order of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5879 windows reflects the order of script loading (but "file" is " the topmost
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5880 window) fun! Edit_ft_conf(name)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5881 " we may not do this with a loaded file, since this won't trigger the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5882 " configuration file loading as desired. " try calling with 'call
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5883 Edit_ft_conf("nonexistingfile.&lt;EXT&gt;")' if this " gives you troubles
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5884 if bufexists(a:name) && bufloaded(a:name)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5885 echo "!Attention: buffer for " . a:name . " is loaded, unload first."
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5886 return
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5887 endif " split-open the file with verbose set, grab the output into a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5888 register " (without clobbering) let safereg = @u redir @u " redirect
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5889 command output to register @u exec "silent 2verbose split " . a:name
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5890 " verbose level 2 suffices to catch all scripts which get opened
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5891 redir END " Parse register @u, looking for smth like:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5892 'sourcing"/usr/local/share/vim/vim60/syntax/c.vim"' let pos = 0 let
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5893 regexp = 'sourcing "[^"]\+"' while match(@u,regexp,pos) &gt;= 0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5894 let file = matchstr(@u,regexp,pos) let pos = matchend (@u,regexp,pos)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5895 let file = strpart(file,10,strlen(file)-11) exec "silent below split
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5896 " . file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5897 endwhile " restore the register let @u = safereg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5898 endfun
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5899
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5900 </pre></tip> </html> <Tip category="KVim"> <html><center>calculate
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5901 equations from within vim</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5902 HREF="http://vim.sf.net/tip_view.php?tip_id=216">http://vim.sf.net/tip_view.php?tip_id=216</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5903
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5904 The following map and function calculates equations using the program 'bc'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5905 (found on most linux systems, available for most systems). Visually select the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5906 equation you want to calculate, then hit ;bc - if the selection ends with an
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5907 '=' sign, the answer will be appended after the equal, otherwise, the answer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5908 is echoed as a message. The code to put in a vimrc and source is at the end.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5909
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5910 Equations can span multiple lines, and the full bc syntax is probably
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5911 supported. Additionally, sin (), cos (), etc, are transformed into the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5912 names used by bc (s () c (), etc).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5913
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5914 Here are some example lines:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5915
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5916 2 * sqrt (2) =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5917
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5918 3 * (2 - 1) + 4.0 ^ 6 =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5919
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5920 4 / 3 =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5921
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5922 3 +
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5923 4 -
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5924 2 * (1 / (3 + 2)) =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5925
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5926 define rad (x) {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5927 return (x / 180) * 4 * atan (1)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5928 } cos (rad (45)) =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5929
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5930 Select each of these in turn (continguous non-blank lines, and hit ;bc for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5931 each), and this is what you get: 2 * sqrt (2) = 2.82842712474619009760
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5932
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5933 3 * (2 - 1) + 4.0 ^ 6 = 4099.000000
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5934
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5935 4 / 3 = 1.33333333333333333333
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5936
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5937 3 +
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5938 4 -
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5939 2 * (1 / (3 + 2)) = 6.60000000000000000000
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5940
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5941 define rad (x) {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5942 return (x / 180) * 4 * atan (1)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5943 } cos (rad (45)) = .70710678118654752440
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5944
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5945 Fun, no? Here is the code you need to put in your vimrc file:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5946
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5947 vnoremap ;bc "ey:call CalcBC()&lt;CR&gt; function! CalcBC()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5948 let has_equal = 0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5949
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5950 " remove newlines and trailing spaces let @e = substitute (@e, "\n",
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5951 "", "g") let @e = substitute (@e, '\s*$', "", "g")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5952
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5953 " if we end with an equal, strip, and remember for output if @e =~ "=$"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5954 let @e = substitute (@e, '=$', "", "") let has_equal = 1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5955 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5956
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5957 " sub common func names for bc equivalent let @e = substitute (@e,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5958 '\csin\s*(', "s (", "") let @e = substitute (@e, '\ccos\s*(', "c
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5959 (", "") let @e = substitute (@e, '\catan\s*(', "a (", "") let @e =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5960 substitute (@e, "\cln\s*(", "l (", "")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5961
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5962 " escape chars for shell let @e = escape (@e, '*()')
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5963
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5964 " run bc, strip newline let answer = substitute (system ("echo "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5965 . @e . " \| bc -l"), "\n", "", "")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5966
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5967 " append answer or echo if has_equal == 1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5968 normal `&gt; exec "normal a" . answer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5969 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5970 echo "answer = " . answer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5971 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5972 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5973
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5974 </pre></tip> </html> <Tip category="KVim"> <html><center>Translate
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5975 &#nnn; in html source to readable ascii</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5976 HREF="http://vim.sf.net/tip_view.php?tip_id=217">http://vim.sf.net/tip_view.php?tip_id=217</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5977
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5978 I found a website *cough*Tivoli.com*cough* that likes to obfuscate some of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5979 its help file web pages using &#nnn; instead of normal ascii. If you load
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5980 the source with Vim (in Opera you can just designate Vim as your source
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5981 viewing program), you can :so the following code to make it readable.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5982
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5983 let n = 32 while n &lt; 127
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5984 if n == 38
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5985 silent! exec '%s/&#38;/\&amp;/g'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5986 elseif n == 47
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5987 silent! exec '%s/&#47;/\//g'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5988 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5989 silent! exec '%s/&#' . n . ';/' . nr2char(n) . '/g'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5990 endif let n = n + 1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5991 endwhile
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5992
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5993 Disclaimer: I hacked this together in about 10 minutes (or possibly longer :).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5994 It worked suitably for the website I wrote it for (or possibly "against" :).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5995 Your Milage May Vary.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5996
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5997 See :help eval, :help silent, :help exec, :help :s
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5998
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5999 </pre></tip> </html> <Tip category="KVim"> <html><center>Check
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6000 for comments, independent of the filetype</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6001 HREF="http://vim.sf.net/tip_view.php?tip_id=218">http://vim.sf.net/tip_view.php?tip_id=218</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6002
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6003 For some scripts it might be useful to detect, whether a specific position
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6004 in a buffer is inside of a comment or not. Syntax highlighting can save us
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6005 the work for parsing the comments ourselves.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6006
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6007 The command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6008 :echo synIDattr(synIDtrans(synID(line("."), col("."), 0)), "name")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6009 echoes the group used for *highlighting* the character at the current
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6010 cursor position, see ':help synIDtrans()'. It will usually be "Comment"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6011 if the cursor is inside of a comment, so
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6012 synIDattr(synIDtrans(synID(line("."), col("."), 0)), "name") == "Comment"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6013 detects, independent of the filetype (which have their own group 'names'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6014 for comments), if the cursor is inside a comment or not. The expression
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6015 synIDattr(synIDtrans(synID(line("."), col("."), 0)), "name") =~
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6016 'Comment\|Constant\|PreProc'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6017 will detect additionally, if the cursor is inside of a string or some
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6018 preprocessor statement.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6019
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6020 </pre></tip> </html> <Tip category="KVim"> <html><center>make
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6021 from command line, open vim on errors</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6022 HREF="http://vim.sf.net/tip_view.php?tip_id=219">http://vim.sf.net/tip_view.php?tip_id=219</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6023
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6024 A simple alias (*csh) or shell function (bash) will let you run make from your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6025 shell, then automatically open vim or gvim on the errors (if there were any):
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6026
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6027 csh or tcsh:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6028
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6029 alias Make 'make \!* |& tee make.errors || gvim -q make.errors -c :copen'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6030
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6031 bash:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6032
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6033 Make () { command make "$@" |& tee make.errors || gvim -q make.errors -c
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6034 :copen ; }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6035
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6036 If you use vanilla sh or ksh or even cmd.exe, you can probably do the same -
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6037 add a not if you have ideas.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6038
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6039 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6040 <html><center>Match every word except 'foo'</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6041 HREF="http://vim.sf.net/tip_view.php?tip_id=220">http://vim.sf.net/tip_view.php?tip_id=220</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6042
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6043 This is a regular expression that matches all words except 'foo'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6044 \v&lt;(foo&gt;)@!\k+&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6045
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6046 \v Very magic &lt; Start-of-word (Foo&gt;) The
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6047 atom 'Foo' followed by end-of-word @! Match (with zero length)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6048 when the previous atom doesn't match. \k+ Match one or more
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6049 Keywords &gt; Match end-of-word.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6050
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6051 This is a kool example of using \@! in the middle of a regexp. The non-magic
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6052 version is: \&lt;\(foo\&gt;\)\@!\k\+\&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6053
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6054 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6055 <html><center>indenting "throws" in java</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6056 HREF="http://vim.sf.net/tip_view.php?tip_id=221">http://vim.sf.net/tip_view.php?tip_id=221</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6057
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6058 I want to indent java files like this:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6059
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6060 int x(int y, int z)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6061 throws Exception
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6062 {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6063 [...] return something;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6064 }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6065
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6066 By default vim will properly indent "throws" line, but following "{" will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6067 not be deindented back to the method declaration.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6068
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6069 The following indentexpr does the trick: let
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6070 &indentexpr='getline(v:lnum)=~"^\\s*{" && getline(v:lnum-1)=~"^\\s*throws\\s"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6071 ? cindent(v:lnum)-&sw : cindent(v:lnum)'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6072
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6073 It just checks that the current line starts with "{" and the previous line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6074 starts with "throws" and if that is the case, it subtracts one shiftwidth
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6075 from the number returned by cindent.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6076
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6077 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6078 <html><center>Building vim with color on HP-UX</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6079 HREF="http://vim.sf.net/tip_view.php?tip_id=222">http://vim.sf.net/tip_view.php?tip_id=222</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6080
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6081 Following the normal steps of running "./configure" and "make" to build vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6082 on an HP-UX 10.20 will result in vim being linked with the termlib library.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6083 This library does not support certain termcap capability codes, such as the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6084 "Co" code used to query the number of colors supported by the terminal.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6085 Consequently, vim will not display colors when used with a color terminal
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6086 such as a color xterm.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6087
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6088 One solution to this is to run the configure script with the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6089 "--with-tlib=curses" option, like this:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6090
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6091 ./configure --with-tlib=curses
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6092
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6093 This will cause vim to be linked with the HP-UX curses library, which does
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6094 support the color termcap capability codes.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6095
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6096 Note that the xterm that comes standard with HP-UX 10.20 does not display color
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6097 character attributes. To see colors when running vim in a terminal window,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6098 you will also need to install a color terminal emulator such as a recent xterm.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6099
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6100 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6101 <html><center>Reverse Selected Text</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6102 HREF="http://vim.sf.net/tip_view.php?tip_id=223">http://vim.sf.net/tip_view.php?tip_id=223</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6103
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6104 Suppose you want to reverse some text - I don't know why you would want to -
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6105 maybe you're dyslexic. Anyway, I had a need, so this mapping will reverse
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6106 visually selected text. Put the mapping in your vimrc or otherwise source
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6107 it, then visually select the word or words, and hit ;rv - really only works
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6108 with selections on one line:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6109
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6110 vnoremap ;rv c&lt;C-O&gt;:set revins&lt;cr&gt;&lt;C-R&gt;"&lt;esc&gt;:set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6111 norevins&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6112
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6113 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6114 <html><center>Shifting blocks visually</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6115 HREF="http://vim.sf.net/tip_view.php?tip_id=224">http://vim.sf.net/tip_view.php?tip_id=224</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6116
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6117 I use the &lt; and &gt; commands on blocks a lot, and it has always annoyed me
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6118 that if you want to shift more than one 'shiftwidth', you have count how many
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6119 'shiftwidth's you want to enter the '[count]&gt;', or restore the selection
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6120 with "gv". So I've cooked up two mappings that come in very handy:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6121
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6122 :vnoremap &lt; &lt;gv :vnoremap &gt; &gt;gv
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6123
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6124 These mappings will reselect the block after shifting, so you'll just have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6125 to select a block, press &lt; or &gt; as many times as you like, and press
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6126 &lt;ESC&gt; when you're done to unselect the block.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6127
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6128 I know it's not rocket science, but it sure has helped me a lot.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6129
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6130 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6131 <html><center>vim can interact with xdvi</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6132 HREF="http://vim.sf.net/tip_view.php?tip_id=225">http://vim.sf.net/tip_view.php?tip_id=225</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6133
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6134 vim can interact with the tricks that the latest xdvi does:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6135
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6136 * If one clicks at some place in xdvi, vim automatically jumps to the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6137 corresponding line in the LaTeX source file ("reverse search")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6138 * Also, from inside vim, one can jump to the corresponding line in xdvi
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6139 which becomes highlighted ("forward search").
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6140
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6141 Here is how to do it:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6142
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6143 * Reverse search:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6144 We start a vim server by: vim --servername xdvi We start xdvi(k) on
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6145 file.dvi by:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6146 xdvik -editor "vim --servername xdvi --remote +%l %f" file.dvi
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6147 At the desired location in xdvi, we press: &lt;ctrl&gt;&lt;left_mouse&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6148 Then, vim will jump to the corresponding line in the source file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6149
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6150 * Forward search:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6151 Inside vim, we type, for example, _g which is the following mapping:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6152 (the following should be a single line)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6153
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6154 map _g :execute "!xdvik -name xdvi -sourceposition "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6155 . line(".") . expand("%") . " " . expand("%:r") . ".dvi"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6156 &lt;cr&gt;&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6157
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6158 [the command to go to the point of xdvi that corresponds to line, eg, 77
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6159 of the source file is (no space after 77)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6160 xdvik -name xdvi -sourceposition 77file.tex file.dvi ]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6161
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6162 For the above to work one needs: 1) A recent version of xdvi or xdvik
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6163 (&gt;22.39 I think) 2) The package srcltx.sty and \usepackage{srcltx}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6164 (which should be
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6165 commented out when one finishes and is ready for printing etc).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6166 3) Our version of vim should have been compiled with +clientserver
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6167 (however, my vim doesn't have it and still works, so try it before
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6168 Bram finds out what is happening and fixes it)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6169
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6170 </pre></tip> </html> <Tip category="KVim"> <html><center>Edit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6171 file under cursor after a horizontal split</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6172 HREF="http://vim.sf.net/tip_view.php?tip_id=226">http://vim.sf.net/tip_view.php?tip_id=226</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6173
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6174 I use the command 'gf' quite often. But with this command the current buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6175 is hidden. To avoid that I use the following mapping :
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6176
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6177 map gw &lt;Esc&gt;:sp %&lt;CR&gt; gf
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6178
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6179 With this mapping the file under the cursor is opened after a horizontal split.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6180
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6181 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6182 <html><center>Power of :g</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6183 HREF="http://vim.sf.net/tip_view.php?tip_id=227">http://vim.sf.net/tip_view.php?tip_id=227</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6184
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6185 :g is something very old and which is very powerful. I just wanted to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6186 illustrate the use of it with some examples. Hope, it will be useful for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6187 someone.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6188
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6189 Brief explanation for ":g" ------------------------- Syntax is:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6190 :[range]:g/&lt;pattern&gt;/[cmd]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6191 You can think the working as, for the range (default whole file), execute
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6192 the colon command(ex) "cmd" for the lines matching &lt;pattern&gt;. Also,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6193 for all lines that matched the pattern, "." is set to that particular line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6194 (for certain commands if line is not specified "." (current line) is assumed).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6195
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6196 Some examples ------------- Display context (5 lines) for all occurences of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6197 a pattern
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6198 :g/&lt;pattern&gt;/z#.5 :g/&lt;pattern&gt;/z#.5|echo "==========" &lt;&lt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6199 same as first, but with some beautification &gt;&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6200 Delete all lines matching a pattern
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6201 :g/&lt;pattern&gt;/d
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6202 Delete all blank lines (just an example for above)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6203 :g/^\s*$/d
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6204 Double space the file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6205 :g/^/pu =\"\n\" :g/^/pu _ &lt;&lt; the above one also works &gt;&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6206 Copy all lines matching a pattern to end of file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6207 :g/&lt;pattern&gt;/t$
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6208 Yank all lines matching a pattern to register 'a'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6209 0"ay0:g/&lt;pattern&gt;/y A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6210 Increment the number items from current line to end-of-document by one
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6211 :.,$g/^\d/exe "normal! \&lt;c-a&gt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6212 Comment (C) lines containing "DEBUG" statements
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6213 g/^\s*DEBUG/exe "norm! I/* \&lt;Esc&gt;A */\&lt;Esc&gt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6214 A Reverse lookup for records (eg: An address book, with Name on start-of-line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6215 and fields after a space)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6216 :g/&lt;patern&gt;?^\w?p "if only name is interested
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6217 :g/&lt;patern&gt;/ka|?^\w?p|'ap "if name and the lookup-line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6218 is interested :g/&lt;patern&gt;/?^\w?|+,/^[^ ]/-1p "if entire record
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6219 is interested
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6220 Reverse a file (just to show the power of 'g')
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6221 :g/^/m0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6222
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6223 Foot note 1: use :v to negate the search pattern Foot note 2: Some explanation
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6224 of commonly used commands with :g
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6225 :2,8co15 =&gt; Copy lines 2 through 8 after line 15 :4,15t$ =&gt; Copy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6226 linesa 4 through 15 towards end of document (t == co)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6227 :-t$ =&gt; Copy previous line to end of document
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6228 :m0 =&gt; Move current line to the top of the document
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6229 :.,+3m$-1 =&gt; Move current line through cur-line+3 to the last but one line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6230 of the document
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6231 Foot note 3: Commands used with :g are ex commands, so a help search should
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6232 be,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6233 :help :&lt;help-topic&gt; eg. :help :k
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6234
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6235 </pre></tip> </html> <Tip category="KVim"> <html><center>Deleting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6236 nested reply threads in emails</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6237 HREF="http://vim.sf.net/tip_view.php?tip_id=228">http://vim.sf.net/tip_view.php?tip_id=228</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6238
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6239 I find the following setting useful when replying to email threads that have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6240 lots of lines like the following: &gt; blah &gt; &gt; blah &gt; &gt; &gt; blah
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6241
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6242 autocmd FileType mail map &lt;F8&gt; :%g/^&gt; &gt;/d&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6243
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6244 When replying to a mail and you want to remove everything except what the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6245 person you are directly replying to wrote just press F8. From the example
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6246 above, you would just be left with &gt; blah
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6247
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6248 What it does is simply match any line starting with &gt; &gt; and deletes it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6249 It's not perfect as sigs and other debris may remain but it takes a lot
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6250 of the grunt work out of replying to mails. The autocmd only maps F8 when
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6251 using mails, this is handy if you use F8 for other things as I do.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6252
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6253 :help autocmd :help map :help :g
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6254
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6255 </pre></tip> </html> <Tip category="KVim"> <html><center>First
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6256 thing to try before asking help</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6257 HREF="http://vim.sf.net/tip_view.php?tip_id=229">http://vim.sf.net/tip_view.php?tip_id=229</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6258
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6259 I've seen several questions asked in the reflector which is available in the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6260 help files. Yeah, I know the help is huge. But, you can try this command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6261 to show a list of related topics you are trying:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6262 :he &lt;topic&gt;&lt;c-d&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6263 It is "some topic" followed by the key sequence Ctrl-D. For eg:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6264 :he xterm&lt;c-d&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6265 will show all the help topics matching xterm. Then you can do
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6266 completion/copy-n-paste the topic you are searching. Of course you can cycle
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6267 through all the topics through repeated &lt;TABS&gt;, but if the number of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6268 hits are huge, it is cumbersome.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6269
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6270 Enjoy vimming beginners!!! -Arun
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6271
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6272 </pre></tip> </html> <Tip category="KVim"> <html><center>copy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6273 current file to another location from within vim</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6274 HREF="http://vim.sf.net/tip_view.php?tip_id=230">http://vim.sf.net/tip_view.php?tip_id=230</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6275
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6276 I work on jsp pages in my source tree but I have to copy the jsp files over
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6277 to the tomcat directory in order to view my changes.The following mapping
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6278 will copy the file being edited to another location.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6279
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6280 command Cpage silent !cp '%:p' "c:/Progra~1/Tomcat/webapps/console/pages/%"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6281
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6282 Explanation:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6283
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6284 % refers to the current buffer %:p refers to the path to the file silent
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6285 suppresses the command prompt window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6286
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6287 Usage:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6288
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6289 :Cpage
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6290
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6291 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6292 <html><center>Localized color schemes</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6293 HREF="http://vim.sf.net/tip_view.php?tip_id=231">http://vim.sf.net/tip_view.php?tip_id=231</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6294
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6295 i frequently like to edit multiple files in the same vim session. however,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6296 if i come into vim from another window i frequently hit 'i' and start typing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6297 in whatever buffer is currently being used -- this is often the wrong one
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6298 (requires &lt;esc&gt;, undo, go the other buffer and . to redo).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6299
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6300 one way to work around this for me is to use a different color scheme
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6301 depending on what file i'm working on:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6302
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6303 au BufEnter * if (exists("b:colors_name")) | let b:current_colors=colors_name
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6304 | execute "colorscheme " . b:colors_name | endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6305
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6306 au BufLeave * if (exists("b:current_colors")) | execute "colorscheme "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6307 . b:current_colors | endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6308
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6309 if you define b:colors_name with a particular color scheme name, then the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6310 above autocommands will switch to that colorscheme when you enter that window
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6311 and will return to the original color upon departure.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6312
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6313 inside ftplugin/java.vim, for example, i might have b:colors_name set to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6314 'morning', causing all java files to have a distinguishing color scheme.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6315
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6316 </pre></tip> </html> <Tip category="KVim"> <html><center>Search
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6317 JDK help for keyword at cursor</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6318 HREF="http://vim.sf.net/tip_view.php?tip_id=232">http://vim.sf.net/tip_view.php?tip_id=232</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6319
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6320 If you are using the Win32 version of Vim you can use this tip to search
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6321 the Jdk help for the keyword under the cursor.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6322 You need the winhlp32 version of the Jdk docs from this URL - <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6323 HREF="http://www.confluent.fr/javadoc/indexe.html.">http://www.confluent.fr/javadoc/indexe.html.</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6324 It is a 16mb D/L and approx 85mb unzipped!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6325
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6326 I added a command to the popup menu :amenu PopUp.JavaHelp :!start winhlp32
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6327 -k &lt;cword&gt; F:\jdk\winhelp\JDK13.HLP &lt;CR
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6328
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6329 And also made a keymapping map J :!start winhlp32 -k &lt;cword&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6330 F:\jdk\winhelp\JDK13.HLP &lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6331
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6332 Trivial yes, but I find it quite useful.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6333
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6334 </pre></tip> </html> <Tip category="KVim"> <html><center>Some
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6335 tips for using Vim to write Lisp code</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6336 HREF="http://vim.sf.net/tip_view.php?tip_id=233">http://vim.sf.net/tip_view.php?tip_id=233</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6337
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6338 For some tips on how to use Vim for writing Lisp code, see <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6339 HREF="http://www.lisp-p.org/i000/15-vim.">http://www.lisp-p.org/i000/15-vim.</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6340
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6341 </pre></tip> </html> <Tip category="KVim"> <html><center>Vi(M)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6342 Command Line tips & tricks</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6343 HREF="http://vim.sf.net/tip_view.php?tip_id=234">http://vim.sf.net/tip_view.php?tip_id=234</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6344
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6345 Hi VIMMERs
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6346
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6347 These tips save me wearing out my delicate little fingers with unnecessary
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6348 keystrokes. They assume Unix, but I also use them on a Windows Unix Shell
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6349 (MKS) as well
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6350
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6351 # When I know the file i want to edit is the most recent file in a directory
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6352
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6353 alias -x vew='vi `l\s -t * | head -1 `'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6354
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6355 #When I know the file I want to edit contains a unique keyword #this is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6356 actually in a little shell script call ed vg where the keyword is passed as
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6357 parameter $1 #/bin/sh #name vg vi.exe $(grep -isl $1 *) &
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6358
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6359 # some variations alias -x vp='vi `l\s -t *.@(pl|cgi)| head -1 `'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6360
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6361 #execute the most recent script (I call this from within VIM with a mapped
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6362 button) alias -x xew='`l\s -t *.pl | head -1 `'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6363
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6364 Cheers zzapper
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6365
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6366 </pre></tip> </html> <Tip category="KVim"> <html><center>Toggle
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6367 highlight word under cursor, to find cursor.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6368 HREF="http://vim.sf.net/tip_view.php?tip_id=235">http://vim.sf.net/tip_view.php?tip_id=235</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6369
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6370 When the screen has scrolled such as during a search, it may be difficult to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6371 find the cursor. :help %# explains the pattern one can use to highlight the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6372 word around the cursor, which gives a bigger target to look for on the screen.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6373 I have this in my .vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6374
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6375 function VIMRCWhere()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6376 if !exists("s:highlightcursor")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6377 match Todo /\k*\%#\k*/ let s:highlightcursor=1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6378 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6379 match None unlet s:highlightcursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6380 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6381 endfunction map &lt;C-K&gt; :call VIMRCWhere()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6382
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6383 This means that in "normal" mode ctrl-k will toggle the highlight. Todo is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6384 a hightlight group whch is particularly easy to see. For further information
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6385 see ":help s:", ":help match", ":help exists()" and ":help funtion".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6386
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6387 </pre></tip> </html> <Tip category="KVim"> <html><center>Menu
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6388 for inserting special characters</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6389 HREF="http://vim.sf.net/tip_view.php?tip_id=236">http://vim.sf.net/tip_view.php?tip_id=236</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6390
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6391 First, thanks for the script printascii.vim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6392
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6393 When looking at the ascii table, I found some characters I'd like to have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6394 inserted when editing. Add the following lines in your _gvimrc and you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6395 can select them via menu. (change the names of the menu if you don't have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6396 German installed or don't like my titles). I also made some abbreviations
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6397 to get separation lines in documentation or code files, e.g. abb dotlin
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6398 ……………………………………………………………………………………………………………………………………………………………………………………………^M
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6399 abb cdotlin
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6400 /*…………………………………………………………………………………………………………………………………………………………………………………*/^M
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6401 abb fdotlin
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6402 •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••^M
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6403 abb cfdotlin
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6404 /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/^M abb
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6405 dlin =======================================================================^M
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6406 abb cdlin
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6407 /*===================================================================*/^M abb
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6408 lin -----------------------------------------------------------------------^M
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6409 abb clin
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6410 /*-------------------------------------------------------------------*/^M abb
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6411 ulin _______________________________________________________________________^M
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6412 abb culin
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6413 /*___________________________________________________________________*/^M abb
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6414 Ulin ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯^M
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6415 abb cUlin
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6416 /*¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*/^M
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6417
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6418 (you have to substitute ^M with CTRL_V CTRL_M or delete it)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6419
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6420 20imenu Editieren.Sonderzeichen.open\ angle\ «
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6421 &lt;C-R&gt;=nr2char(171)&lt;CR&gt; 20nmenu Editieren.Sonderzeichen.open\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6422 angle\ « a&lt;C-R&gt;=nr2char(171)&lt;CR&gt;&lt;ESC&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6423 20imenu Editieren.Sonderzeichen.close\ angle\ »
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6424 &lt;C-R&gt;=nr2char(187)&lt;CR&gt; 20nmenu Editieren.Sonderzeichen.close\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6425 angle\ » a&lt;C-R&gt;=nr2char(187)&lt;CR&gt;&lt;ESC&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6426 20imenu Editieren.Sonderzeichen.start\ mark\ „
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6427 &lt;C-R&gt;=nr2char(132)&lt;CR&gt; 20nmenu Editieren.Sonderzeichen.start\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6428 mark\ „ a&lt;C-R&gt;=nr2char(132)&lt;CR&gt;&lt;ESC&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6429 20imenu Editieren.Sonderzeichen.end\ mark\ \ ”
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6430 &lt;C-R&gt;=nr2char(148)&lt;CR&gt; 20nmenu Editieren.Sonderzeichen.end\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6431 mark\ \ ” a&lt;C-R&gt;=nr2char(148)&lt;CR&gt;&lt;ESC&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6432 20imenu Editieren.Sonderzeichen.fat\ dot\ \ •
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6433 &lt;C-R&gt;=nr2char(149)&lt;CR&gt; 20nmenu Editieren.Sonderzeichen.fat\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6434 dot\ \ • a&lt;C-R&gt;=nr2char(149)&lt;CR&gt;&lt;ESC&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6435 20imenu Editieren.Sonderzeichen.etc\ \ \ …
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6436 &lt;C-R&gt;=nr2char(133)&lt;CR&gt; 20nmenu Editieren.Sonderzeichen.etc\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6437 \ \ … a&lt;C-R&gt;=nr2char(133)&lt;CR&gt;&lt;ESC&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6438 20imenu Editieren.Sonderzeichen.!underscore\ \ ¯
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6439 &lt;C-R&gt;=nr2char(175)&lt;CR&gt; 20nmenu Editieren.Sonderzeichen.!underscore\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6440 \ ¯ a&lt;C-R&gt;=nr2char(175)&lt;CR&gt;&lt;ESC&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6441 20imenu Editieren.Sonderzeichen.copyright\ \ ©
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6442 &lt;C-R&gt;=nr2char(169)&lt;CR&gt; 20nmenu Editieren.Sonderzeichen.copyright\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6443 \ © a&lt;C-R&gt;=nr2char(169)&lt;CR&gt;&lt;ESC&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6444 20imenu Editieren.Sonderzeichen.paragraph\ \ §
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6445 &lt;C-R&gt;=nr2char(167)&lt;CR&gt; 20nmenu Editieren.Sonderzeichen.paragraph\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6446 \ § a&lt;C-R&gt;=nr2char(167)&lt;CR&gt;&lt;ESC&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6447 20imenu Editieren.Sonderzeichen.noitamalcxe\ ¡
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6448 &lt;C-R&gt;=nr2char(161)&lt;CR&gt; 20nmenu Editieren.Sonderzeichen.noitamalcxe\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6449 ¡ a&lt;C-R&gt;=nr2char(161)&lt;CR&gt;&lt;ESC&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6450
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6451 </pre></tip> </html> <Tip category="KVim"> <html><center>If
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6452 you prefer vertical splits</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6453 HREF="http://vim.sf.net/tip_view.php?tip_id=237">http://vim.sf.net/tip_view.php?tip_id=237</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6454
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6455 This is just in case there's somebody else who likes to work in a maximized
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6456 vim window on a high resolution desktop. If you follow good coding practice
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6457 and make sure your programs use only 80 characters in each row, have you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6458 noticed how much space lies unused on the right?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6459
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6460 I find that the following settings keep me from ever seeing another horizontal
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6461 split, unless I specifically ask for it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6462
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6463 cabbrev split vsplit cabbrev hsplit split cabbrev sta vertical sta cabbrev
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6464 help vertical help cabbrev new vnew cabbrev right botright
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6465
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6466 ; A more heavyweight solution for ^W^] function! ToggleSplit (dir)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6467 let currFname = bufname ("%") let old = winnr ()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6468
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6469 " Window navigation to ensure the correct window is 'last'. if (a:dir ==
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6470 "u")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6471 wincmd k let back="j"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6472 elseif (a:dir == "d")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6473 wincmd j let back="k"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6474 elseif (a:dir == "l")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6475 wincmd h let back="l"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6476 elseif (a:dir == "r")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6477 wincmd l let back="h"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6478 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6479
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6480 if (winnr () == old)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6481 echo "Ouch" return
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6482 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6483
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6484 exec "wincmd " . back
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6485
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6486 quit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6487
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6488 if (back == "j" || back == "k")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6489 let orientation = "vsplit"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6490 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6491 let orientation = "split"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6492 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6493
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6494 if (back == "j" || back == "l")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6495 let dir = "below"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6496 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6497 let dir = "above"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6498 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6499
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6500 exec dir . " " . orientation " " . currFname
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6501 endfunction noremap ^W^] ^W^]:silent call ToggleSplit ("d")&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6502
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6503 ; Optional. set splitright ; In which case the above mapping becomes: noremap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6504 ^W^] :set splitbelow&lt;CR&gt;^W^]:silent call ToggleSplit ("u")&lt;CR&gt;:set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6505 nosplitbelow&lt;CR&gt; ; Or you could just set splitbelow ; :-)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6506
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6507 ; Very elegant and almost perfect, but it screws up if you want to run a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6508 command with ranges :-) ;noremap : :vertical&lt;Space&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6509
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6510 ; EOF
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6511
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6512 </pre></tip> </html> <Tip category="KVim"> <html><center>Very
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6513 basic session persistence</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6514 HREF="http://vim.sf.net/tip_view.php?tip_id=238">http://vim.sf.net/tip_view.php?tip_id=238</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6515
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6516 I use the following code in my plugins dir to ease session persistance. If
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6517 I want my session to persist I use :mks! and then whenever I open the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6518 Session.vim file, my session is restored. If I am working from a restored
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6519 session and I close VIM, the session is saved automatically. Drawback is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6520 that it makes editing the Session.vim file a bit cumbersome ;)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6521
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6522 au BufRead Session.vim so % au VimLeave * call SaveCurrentSession()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6523
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6524 function! SaveCurrentSession()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6525 if v:this_session != ""
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6526 exe "mksession! " . v:this_session
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6527 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6528 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6529
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6530 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6531 <html><center>map shift-up and shift-down</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6532 HREF="http://vim.sf.net/tip_view.php?tip_id=239">http://vim.sf.net/tip_view.php?tip_id=239</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6533
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6534 You can make Vim scroll the text using the shifted up/down arrows, sort
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6535 of like your browser (except with shifted keys :), by mapping Shift-Up to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6536 Ctrl-Y and Shift-Down to Ctrl-E.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6537
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6538 map &lt;s-Down&gt; &lt;C-E&gt; map &lt;s-Up&gt; &lt;C-Y&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6539
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6540 Shift-Down will then scroll down (like moving a scroll-bar down, or like
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6541 moving a cursor at the bottom of a window down), and Shift-Up will then
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6542 scroll up (like moving a scroll-bar up, etc).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6543
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6544 If you'd rather think about the text moving down/up instead of the cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6545 moving up/down, you can of course swap the mappings.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6546
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6547 If you normally use j and k for cursor movement, and rarely use the arrow
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6548 keys, you can map the arrow keys directly, in which case I'd probably map
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6549 the shifted arrow keys back to cursor movement:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6550
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6551 map &lt;down&gt; &lt;c-e&gt; map &lt;up&gt; &lt;c-y&gt; map &lt;s-down&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6552 j map &lt;s-up&gt; k
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6553
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6554 See :help ctrl-e, :help ctrl-y, and :help key-mapping.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6555
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6556 See also :help i_ctrl-o and :help map-modes for how to set up these mappings
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6557 for use in other modes (like insert mode :).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6558
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6559 (Vim by default maps s-Down and s-Up to Ctrl-F and Ctrl-B, for both normal and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6560 visual mode. Keep this in mind if you change some of the above mappings to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6561 "nmap", 'cause you'll probably also want to look in to "vmap".)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6562
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6563 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6564 <html><center>Hideall for Vim</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6565 HREF="http://vim.sf.net/tip_view.php?tip_id=240">http://vim.sf.net/tip_view.php?tip_id=240</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6566
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6567 Xemacs has a hide all function which can make all the function in your C file a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6568 fold and close them. And here is something small to achieve similiar under Vim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6569
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6570 func! HideAll()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6571 syn region myFold start="{" end="}" transparent fold syn sync fromstart
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6572 set foldnestmax=1 set foldmethod=syntax
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6573 endfunc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6574
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6575 amenu Whatever.Hide\ all :call HideAll()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6576
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6577 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6578 <html><center>"Hide" Folding Markers</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6579 HREF="http://vim.sf.net/tip_view.php?tip_id=241">http://vim.sf.net/tip_view.php?tip_id=241</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6580
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6581 I wanted to start using folding without having to get used to seeing the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6582 (default) markers, a.k.a {{{ and }}}. So, here are 2 autocmd's that will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6583 make them fade to black....bg=black fg=black
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6584
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6585 au BufRead,BufNewfile * syn match fmrkr '"*{{{\|"*}}}' |
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6586 \ syn cluster vimCommentGroup contains=fmrkr |
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6587 \ hi fmrkr term=NONE guibg=black guifg=black \
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6588 ctermbg=black ctermfg=black
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6589
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6590 au BufRead,BufNewfile * syn match fmrkr '"*{{{\|"*}}}'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6591 \ containedin=vimLineComment contained |
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6592 \ hi fmrkr term=NONE guibg=black guifg=black \
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6593 ctermbg=black ctermfg=black
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6594
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6595 They both accomplish the same thing, but with different methods, so simply pick
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6596 one and see those annoying (at least to me) markers fade away. I just tried
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6597 it out with vim files, but you can easily modify it for any other filetypes.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6598
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6599 Thanks to Colin's lead with ':help c-syntax' for the 1st au. Thanks to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6600 Benji's lead with ':help containedin' for the 2nd au. Understanding most
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6601 of the syntax.txt document file would also be helpful.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6602
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6603 To figure out what highlighting group the Marker is in, I would suggest
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6604 using Chip's vimtip#99.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6605
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6606 Happy Vimming!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6607
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6608 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6609 <html><center>The power of "\_" in reg-ex</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6610 HREF="http://vim.sf.net/tip_view.php?tip_id=242">http://vim.sf.net/tip_view.php?tip_id=242</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6611
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6612 One of the most uncelebrated feature of vim 6.0 is the ability to span a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6613 search across multiple lines.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6614
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6615 \_^ maps a begining of line anywhere in search pattern. \_$ ---"----- end
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6616 ----------------------"-------------------------. \_s ---"------ space
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6617 ------------"------------------------- .
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6618
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6619 e.g /{\_s will map all white spaces and new-line chars after a "{"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6620
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6621 The \_ can be appended to other objects as well. such as \_U, \_L, \_. (this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6622 one's risky) .
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6623
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6624 See :help pattern for more details. Njoy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6625
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6626 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6627 <html><center>Develop vim modules on Win</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6628 HREF="http://vim.sf.net/tip_view.php?tip_id=243">http://vim.sf.net/tip_view.php?tip_id=243</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6629
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6630 We're trying to develop txt2pdf.vim <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6631 HREF="http://vim.sourceforge.net/scripts/script.php?script_id=283 on
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6632 Win.">http://vim.sourceforge.net/scripts/script.php?script_id=283
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6633 on Win.</A><BR> It's a very simple module to save the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6634 current file and convert it to PDF using our txt2pdf tool <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6635 HREF="http://www.sanface.com/txt2pdf.html">http://www.sanface.com/txt2pdf.html</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6636 On our Windows 2000 we've developed it. It works good. Today we've tested
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6637 the module on Linux. Surprise: it doesn't work. Default Win Vim configure
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6638 save on Win text in Win way: EOL \r\n. A Vim module made in this way can't
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6639 work on Linux (probably on every Unix OS). If you want to make a Vim module
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6640 on Win and you want it can work also on Unix (we hope the same rula can work
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6641 also on different OS) you've to save the Vim module with Unix EOL (\n).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6642
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6643 Please send us (sanface@sanface.com) your notes about other OS (e.g. OpenVMS).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6644
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6645 </pre></tip> </html> <Tip category="KVim"> <html><center>Ask
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6646 vim where an option was set.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6647 HREF="http://vim.sf.net/tip_view.php?tip_id=244">http://vim.sf.net/tip_view.php?tip_id=244</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6648
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6649 When things go wrong, it is sometimes hard to figure out why.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6650 For example,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6651 an option might be set in the system vimrc file, in a personal vimrc file,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6652 in a plugin (global or local), or interactively. Vim will tell you where
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6653 the current value was set if you ask:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6654
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6655 :verbose set history?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6656
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6657 will tell you the current value of the 'history' option, and where it was set.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6658
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6659 </pre></tip> </html> <Tip category="KVim"> <html><center>Working
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6660 with Unicode (platform-independent)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6661 HREF="http://vim.sf.net/tip_view.php?tip_id=245">http://vim.sf.net/tip_view.php?tip_id=245</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6662
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6663 Here are the main options you will want to set if you want to work with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6664 Unicode files in (g)vim (see at bottom what help tags to look for)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6665
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6666 if has("multi_byte")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6667 set encoding=utf-8 " how vim shall represent
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6668 characters internally setglobal fileencoding=utf-8 " empty is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6669 also OK (defaults to same as 'encoding'). Or you may want to set one
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6670 of the ucs encodings (which
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6671 " may use less disk
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6672 space if you use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6673 only "alphabetic"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6674 scripts such as
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6675 Latin, Greek,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6676 Cyrillic, Hebrew
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6677 or Arabic, and "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6678 not "ideographic"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6679 scripts like
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6680 Chinese, Japanese
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6681 or Korean. With
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6682 the ucs encodings
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6683 it is usually better
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6684 set bomb " to also set 'bomb'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6685 on ('byte-order-mark" option, irrelevant for utf-8 but not for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6686 ucs) set termencoding=iso-8859-15 " or whatever is appropriate
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6687 to your locale (iso-8859-15 is Latin1 + Euro currency sign) set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6688 fileencodings=ucs-bom,iso-8859-15,iso-8859-3,utf-8
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6689 " or whatever is appropriate to the kinds of files you want to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6690 edit " 'fileencodings' defines the heuristic to set 'fillencoding'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6691 (local to buffer) when reading an existing file. The first one that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6692 matches will be used. " ucs-bom is "ucs with byte-order-mark";
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6693 it must not come after ucs-8 if you want it to be used
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6694 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6695 echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6696 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6697
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6698 In "replace" mode, one utf character (one or more data bytes) replaces one
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6699 utf character (which need not use the same number of bytes) In "normal" mode,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6700 ga shows the character under the cursor as text, decimal, octal and hex; g8
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6701 shows which byte(s) is/are used to represent it In "insert" or "replace" mode,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6702 - any character defined on your keyboard can be entered the usual way (even
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6703 with dead keys if you have them, e.g. âêîôû äëïöü) - any character which
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6704 has a "digraph" (there are a huge lot of them, see :dig after setting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6705 enc=utf-8) can be entered with a Ctrl-K prefix - any utf character at
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6706 all can be entered with a Ctrl-V prefix, either &lt;Ctrl-V&gt; u aaaa
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6707 or &lt;Ctrl-V&gt; U bbbbbbbb, with 0 &lt;= aaaa &lt;= FFFF, or 0 &lt;=
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6708 bbbbbbbb &lt;= 7FFFFFFF
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6709
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6710 Unicode can be used to create html "body text", at least for Netscape 6 and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6711 probably for IE; but on my machine it doesn't display properly as "title text"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6712 (i.e., between &lt;title&gt;&lt;/title&gt; tags in the &lt;head&gt; part).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6713
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6714 Gvim will display it properly if you have the fonts for it, provided that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6715 you set 'guifont' to some fixed-width font which has the glyphs you want
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6716 to use (Courier New is OK for French, German, Greek, Russian and more,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6717 but I'm not sure about Hebrew or Arabic; its glyphs are of a more "fixed"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6718 width than those of, e.g. Lucida Console: the latter can be annoying if you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6719 need bold Cyrillic writing).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6720
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6721 see:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6722
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6723 :h utf8 :h 'enc' :h 'fenc' :h 'fencs' :h 'tenc' :h 'bomb' :h 'guifont'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6724 :h ga :h g8 :h i_Ctrl-V_digit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6725
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6726 Happy Vimming ! Tony.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6727
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6728 </pre></tip> </html> <Tip category="KVim"> <html><center>Working
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6729 with Unicode (the same, rewritten for legibility)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6730 HREF="http://vim.sf.net/tip_view.php?tip_id=246">http://vim.sf.net/tip_view.php?tip_id=246</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6731
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6732 1. Where to look for help ------------------------- :h utf8 :h encoding-values
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6733 :h 'enc' :h 'fenc' :h 'fencs' :h 'tenc' :h 'bomb' :h 'guifont' :h ga :h g8
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6734 :h :dig :h i_Ctrl-V_digit :h has()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6735
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6736 2. What to do (These are *examples*. Modify them to suit your work
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6737 environment.) ------------- if has("multi_byte")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6738 set encoding=utf-8 setglobal fileencoding=utf-8
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6739 set bomb set termencoding=iso-8859-15 set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6740 fileencodings=ucs-bom,iso-8859-15,iso-8859-3,utf-8
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6741 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6742 echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6743 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6744
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6745 3. What the above does ---------------------- * has("multi_byte") checks if
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6746 you have the right options compiled-in. If you haven't got what it takes,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6747 it's no use trying to use Unicode.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6748
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6749 * 'encoding' sets how vim shall represent characters internally. Utf-8 is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6750 necessary for most flavors of Unicode.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6751
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6752 * 'fileencoding' sets the encoding for a particular file (local to buffer);
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6753 :setglobal sets the default value. An empty value can also be used: it defaults
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6754 to same as 'encoding'. Or you may want to set one of the ucs encodings, It
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6755 might make the same disk file bigger or smaller depending on your particular
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6756 mix of characters. Also, IIUC, utf-8 is always big-endian (high bit first)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6757 while ucs can be big-endian or little-endian, so if you use it, you will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6758 probably need to set 'bomb" (see below).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6759
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6760 * 'bomb' (boolean): if set, vim will put a "byte order mark" at the start
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6761 of ucs files. This option is irrelevant for most non-ucs files (utf-8,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6762 iso-8859, etc.)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6763
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6764 * 'termencoding' defines how your keyboard encodes what you type. The value
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6765 you put there will depend on your locale: iso-8859-15 is Latin1 + Euro currency
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6766 sign, but you may want something else for, say, an Eastern European keyboard.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6767
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6768 * 'fileencodings' defines the heuristic to set 'fileencoding' (local to buffer)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6769 when reading an existing file. The first one that matches will be used (and,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6770 IIUC, if there is no match, Vim falls back on Latin1). Ucs-bom is "ucs with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6771 byte-order-mark"; it must not come after utf-8 if you want it to be used.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6772
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6773 4. Additional remarks --------------------- * In "replace" mode, one utf
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6774 character (one or more data bytes) replaces one utf character (which need
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6775 not use the same number of bytes)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6776
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6777 * In "normal" mode, ga shows the character under the cursor as text, decimal,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6778 octal and hex; g8 shows which byte(s) is/are used to represent it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6779
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6780 * In "insert" or "replace" mode,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6781 - any character defined on your keyboard can be entered the usual way
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6782 (even with dead keys if you have them, e.g. French circumflex, German
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6783 umlaut, etc.); - any character which has a "digraph" (there are a huge lot
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6784 of them, see :dig after setting enc=utf-8) can be entered with a Ctrl-K
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6785 prefix; - any utf character at all can be entered with a Ctrl-V prefix,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6786 either &lt;Ctrl-V&gt; u aaaa or &lt;Ctrl-V&gt; U bbbbbbbb, with 0 &lt;=
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6787 aaaa &lt;= FFFF, or 0 &lt;= bbbbbbbb &lt;= 7FFFFFFF.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6788
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6789 * Unicode can be used to create html "body text", at least for Netscape 6 and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6790 probably for IE; but on my machine it doesn't display properly as "title text"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6791 (i.e., between &lt;title&gt;&lt;/title&gt; tags in the &lt;head&gt; part).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6792
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6793 * Gvim will display it properly if you have the fonts for it, provided
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6794 that you set 'guifont' to some fixed-width font which has the glyphs you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6795 want to use (Courier New is OK for French, German, Greek, Russian and more,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6796 but I'm not sure about Hebrew or Arabic; its glyphs are of a more "fixed"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6797 width than those of, e.g. Lucida Console: the latter can be awkward if you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6798 need bold Cyrillic writing).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6799
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6800 Happy Vimming ! Tony.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6801
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6802 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6803 <html><center>Preexisting code indentation</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6804 HREF="http://vim.sf.net/tip_view.php?tip_id=247">http://vim.sf.net/tip_view.php?tip_id=247</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6805
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6806 Using tabs as elementary unit in your code indentation has two advantages:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6807 first, you may modify 'tabstop' and immediately all the indentations depths
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6808 are modified according to it; second, your file will be smaller.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6809
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6810 But how can we change some already-written code in order to convert spaces
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6811 to tabs. Very simple! Suppose your old code has an indentation unit of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6812 2 spaces :ret! 2 :x will replace every 2-spaces to one tab, independently
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6813 from your current tabstop value, and will save the modified file. Then,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6814 if you open again the file with tabstop=2, the file will look as before but
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6815 it will be smaller. If you open the file with tabstop=4, the code vill have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6816 a more indented look, and so on...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6817
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6818 Cheers!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6819
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6820 </pre></tip> </html> <Tip category="KVim"> <html><center>Auto-save
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6821 the current buffer periodically.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6822 HREF="http://vim.sf.net/tip_view.php?tip_id=248">http://vim.sf.net/tip_view.php?tip_id=248</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6823
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6824 I have no idea if this was implemented in vim 5.3 or not, but you can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6825 definitely do the following kludge in 6.x by using CursorHold and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6826 localtime:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6827
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6828 - When you start reading a file, set a buffer variable to the current
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6829 time:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6830
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6831 au BufRead,BufNewFile * let b:start_time=localtime()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6832
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6833 - Set a CursorHold event to check to see if enough time has elapsed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6834 since the last save and save if not:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6835
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6836 au CursorHold * call UpdateFile()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6837
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6838 - Define a function to save the file if needed:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6839
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6840 " only write if needed and update the start time after the save
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6841 function! UpdateFile()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6842 if ((localtime() - b:start_time) &gt;= 60)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6843 update let b:start_time=localtime()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6844 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6845 echo "Only " . (localtime() - b:start_time) . " seconds have elapsed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6846 so far."
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6847 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6848 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6849
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6850 - Reset the start time explicitly after each save.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6851
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6852 au BufWritePre * let b:start_time=localtime()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6853
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6854 Obviously, you should get rid of the else portion once you're certain
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6855 that this does indeed do what you wanted.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6856
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6857 The thing to note is that the CursorHold will only fire after
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6858 'updatetime' milliseconds of inactivity have elapsed. So, if you type
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6859 rapidly for one and a half minutes non-stop, it won't actually save
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6860 anything until you STOP activity long enough. This may be what you want
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6861 anyway because it won't interrupt your activity with a forced save.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6862
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6863 The actual save-delay can be changed from '60' to another number (in seconds)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6864 or a variable or anything like that. This entire functionality can be easily
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6865 wrapped inside a nice script which enables/disables this on a per-buffer basis
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6866 (maybe with maps etc.). If desired, I can provide that also.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6867
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6868 </pre></tip> </html> <Tip category="KVim"> <html><center>Quickly
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6869 insert #if 0 - #endif around block of code</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6870 HREF="http://vim.sf.net/tip_view.php?tip_id=249">http://vim.sf.net/tip_view.php?tip_id=249</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6871
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6872 One of my favorite macros that I use in vim (and vi) inserts a #if 0 #endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6873 sandwich around a block of code. I always map this to the 2 key sequence ;'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6874 which is the semi-colon followed by the single quote. Look at your keyboard,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6875 you will notice these keys are adjacent to one another. I like this mapping
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6876 because it's very fast, my fingers easily roll from one key to the next,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6877 obviously YMMV.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6878
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6879 To use this mapping, go to the line of code that you want the '#if 0' to be
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6880 on, type ma to mark this line with the marker a, then move to the line that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6881 should be last line just above the '#endif' and press ;'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6882
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6883 " insert #if 0 - #endif around block of code map ;' mz'aO&lt;Esc&gt;i#if
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6884 0&lt;Esc&gt;'zo&lt;Esc&gt;i#endif&lt;Esc&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6885
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6886 -- David Thompson dat1965@yahoo.com
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6887
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6888 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6889 <html><center>One big window</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6890 HREF="http://vim.sf.net/tip_view.php?tip_id=250">http://vim.sf.net/tip_view.php?tip_id=250</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6891
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6892 If you like to see your files in fullscreen, and you have to edit more files,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6893 you can do the following. * Use only one window * Open further files with :e *
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6894 type :nm &lt;A-Up&gt; :bp!&lt;CR&gt; * type :nm &lt;A-Down&gt; :bn!&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6895 * type :nm &lt;C-F4&gt; :bd!&lt;CR&gt; You can of course change the keys.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6896 Now to switch between windows, you can press Alt-Up, and Alt-Down (Just in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6897 the GUI, if you use console, don't use Alt key) Another idea is to map them
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6898 to Ctrl-Tab, and Ctrl-Shift-Tab To close the current file you can press Ctrl-F4
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6899
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6900 </pre></tip> </html> <Tip category="KVim"> <html><center>align
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6901 #endif with corresponding #if/#ifdef</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6902 HREF="http://vim.sf.net/tip_view.php?tip_id=251">http://vim.sf.net/tip_view.php?tip_id=251</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6903
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6904 If you try to impose any sort of alignment on your preprocessor directives,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6905 rather than just starting them on column 0, this mapping will align the #endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6906 'correctly' when you type '#en', start a new line, and bring you back to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6907 the correct alignment to edit code.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6908
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6909 inoremap &lt;buffer&gt; #en
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6910 X&lt;BS&gt;&lt;Esc&gt;?#if&lt;CR&gt;"zy0^Og0"zpDa#endif&lt;CR&gt;X&lt;BS&gt;&lt;Esc&gt;?#end?-1&lt;CR&gt;^"zy0^O0"zpDa
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6911
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6912 I am reasonably sure this is insensitive to vim options...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6913
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6914 </pre></tip> </html> <Tip category="KVim"> <html><center>python
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6915 script to align statements</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6916 HREF="http://vim.sf.net/tip_view.php?tip_id=252">http://vim.sf.net/tip_view.php?tip_id=252</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6917
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6918 i know there's some awk scripts out there that do the same thing, and if i
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6919 were a real trooper i would have written this in vims internal language but...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6920
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6921 i wrote a python script to align statements.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6922
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6923 i put this in my .vimrc: map L :!lineUp.py&lt;cr&gt; " of course lineUp.py
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6924 is somewhere in my path
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6925
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6926 and i have this python file somewhere in my path: <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6927 HREF="http://ophinity.com/res/dotFiles/lineUp.py">http://ophinity.com/res/dotFiles/lineUp.py</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6928
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6929 so now i can just pipe the offending lines thru my code: :5, 10 !lineUp.py
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6930 or using the mapping above, visually select the lines and press 'L'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6931
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6932 </pre></tip> </html> <Tip category="KVim"> <html><center>The
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6933 power of | (v75|r- actually...)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6934 HREF="http://vim.sf.net/tip_view.php?tip_id=253">http://vim.sf.net/tip_view.php?tip_id=253</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6935
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6936 '|' as you may well be aware is the goto column motion, and that "75|"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6937 will place your cursor on column 75 of the current line.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6938
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6939 That in itself is pretty handy at times, but some true power arises when
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6940 used in conjuction with visual mode and replace. Or you could just say a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6941 sneaky trick :)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6942
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6943 v75|r- will repace from the cursor to the end of line with '-' *breakdown*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6944 v to turn on visual mode 75 for the count | *bar* to goto column r to enter
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6945 repace - to specify the char to replace.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6946
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6947 A handy and quick way to make a noticable section of your code (or whatever).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6948
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6949 A handy way to use this (formated to just drop into DrChip's CStubs): "//
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6950 -[Feral]---------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6951 "// &lt;cursor&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6952 elseif wrd == "//"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6953 exe "norm! a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6954 -[AuthorId]\&lt;esc&gt;$lv75|r-$a\&lt;cr&gt;\&lt;esc&gt;$a "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6955
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6956 "// -[Feral:146/02@08:31]--------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6957 "// &lt;cursor&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6958 elseif wrd == "///"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6959 exe "norm! s
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6960 -[AuthorId:\&lt;C-R&gt;=strftime('%j/%y@%H:%M')\&lt;CR&gt;]\&lt;esc&gt;$lv75|r-$a\&lt;cr&gt;\&lt;esc&gt;$a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6961 "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6962
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6963 "/* -[Feral:146/02@08:31]--------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6964 " * &lt;cursor&gt; " *
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6965 -------------------------------------------------------------------- */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6966 elseif wrd == "/*"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6967 exe "norm! a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6968 -[AuthorId:\&lt;C-R&gt;=strftime('%j/%y@%H:%M')\&lt;CR&gt;]\&lt;esc&gt;$lv75|r-$a\&lt;cr&gt;\&lt;cr&gt;\&lt;esc&gt;2lv72|r-$a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6969 */\&lt;esc&gt;k$a "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6970
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6971 Have to love VIM!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6972
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6973 </pre></tip> </html> <Tip category="KVim"> <html><center>Using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6974 \%[] to easily match parts of a word.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6975 HREF="http://vim.sf.net/tip_view.php?tip_id=254">http://vim.sf.net/tip_view.php?tip_id=254</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6976
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6977 This code fragment is suitable to drop into DrChip's CStubs.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6978 After much searching I was unable to find a tip nor script
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6979 number to referance, I believe where I found Dr. Chip's CStubs originally : <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6980 HREF="http://users.erols.com/astronaut/vim/vimscript/drcstubs.vim">http://users.erols.com/astronaut/vim/vimscript/drcstubs.vim</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6981 Thank you Dr. Chip! (=
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6982
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6983 If you have ever wanted to match parts of a word you may have considered
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6984 something like: if wrd == "re" || wrd == "ret" || wrd == "retu" || wrd ==
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6985 "retur"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6986 "do something
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6987
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6988 Althought the above works well enough it is a pain to maintain and add new
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6989 words (not to mention its just a touch messy ;) )
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6990
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6991 A more elegant (and easier to use I believe) method would be to use \%[]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6992 as part of a pattern.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6993
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6994 For instance, "\\&lt;re\\%[tur]\\&gt;" will match "re", "ret", "retu" or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6995 "retur"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6996
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6997 *breakdown* \\&lt; = start of word re = first letters of word we want to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6998 require to match \\%[tur] = optionally match chars bewteen the braces,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6999 i.e. 't', 'tu' or 'tur' \\&gt; = end of word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7000
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7001 So, we can use this as a pattern for match like so (In DrChip's CStubs)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7002
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7003 elseif match(wrd, "\\&lt;re\\%[tur]\\&gt;") &gt; -1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7004 exe "norm! bdWireturn\&lt;Esc&gt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7005
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7006 Which, I think, is a little better than the longer alternative: " vs elseif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7007 wrd == "re" || wrd == "ret" || wrd == "retu" || wrd == "retur"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7008 exe "norm! bdWireturn\&lt;Esc&gt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7009
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7010 Just another one of those VIM things that made me smile :)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7011
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7012 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7013 <html><center>arbitrary tags for file names</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7014 HREF="http://vim.sf.net/tip_view.php?tip_id=255">http://vim.sf.net/tip_view.php?tip_id=255</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7015
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7016 This definitely work on linux and there is probably some windows equivalent.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7017 I've started working with tomcat and many many .jsp files. I find this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7018 trick to be very helpful.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7019
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7020 find -name '*.jsp' -printf '%f\t%P\t1\n' |sort &gt; jsp.tags
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7021
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7022 This will create a file called jsp.tags with tag entries for each .jsp file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7023 Within Vim I use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7024
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7025 :set tags+=jsp.tags
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7026
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7027 Now I can to simple :tag file.jsp to quickly switch b/w the many, many
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7028 .jsp files.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7029
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7030 One important note. The utility sort will use the value of LC_COLLATE to sort
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7031 according to your locale. This will give Vim issues. So try "LC_COLLATE=C
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7032 sort" instead of plain "sort"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7033
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7034 </pre></tip> </html> <Tip category="KVim"> <html><center>Opening
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7035 current Vim file in your Windows browser</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7036 HREF="http://vim.sf.net/tip_view.php?tip_id=256">http://vim.sf.net/tip_view.php?tip_id=256</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7037
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7038 Hi Vimmers
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7039
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7040 open current file in browser
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7041
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7042 map ,f :update&lt;CR&gt;:silent !start c:\progra~1\intern~1\iexplore.exe
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7043 file://%:p&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7044
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7045 open http link under cursor in your browser
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7046
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7047 map ,i :update&lt;CR&gt;: !start c:\progra~1\intern~1\iexplore.exe
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7048 &lt;cWORD&gt;&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7049
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7050 Note use of cWORD (not cword) meaning OUTER Word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7051
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7052 Works for me in XP & 98 (Original came from a posting by Ralf Arens)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7053
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7054 zzapper
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7055
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7056 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7057 <html><center>fast page up/down.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7058 HREF="http://vim.sf.net/tip_view.php?tip_id=257">http://vim.sf.net/tip_view.php?tip_id=257</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7059
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7060 i discovered a cool way to move between pages of the same document in vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7061 6.1. press a number in -normal mode- and the page up/down. the document
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7062 will move with that number of pages up/down.if the number is greater that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7063 the nr of pages, document will move to begin/end of file. i didn't test it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7064 on other version.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7065
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7066 </pre></tip> </html> <Tip category="KVim"> <html><center>how
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7067 long is the current word?</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7068 HREF="http://vim.sf.net/tip_view.php?tip_id=258">http://vim.sf.net/tip_view.php?tip_id=258</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7069
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7070 ever wondered how long the current word is? this can be quite useful when
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7071 editing data files. simply add the following to your .vimrc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7072
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7073 nmap &lt;C-_&gt; :echo 'word' expand("&lt;cword&gt;") ' wordlen ='
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7074 strlen(expand("&lt;cword&gt;"))&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7075
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7076 and it will tell you the word under the cursor, and how long it is.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7077
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7078 and for things that arent words, this addition to your .vimrc works on
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7079 sections of a line that have been hightligted in visual mode
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7080
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7081 vmap &lt;C-_&gt; "-y:echo 'word' @- ' wordlen =' strlen(@-)&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7082
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7083 again you see the "word", and its length this may also work on vim 5.x,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7084 but i havent checked to make sure.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7085
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7086 </pre></tip> </html> <Tip category="KVim"> <html><center>removing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7087 the toolbar (icons) from gvim</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7088 HREF="http://vim.sf.net/tip_view.php?tip_id=259">http://vim.sf.net/tip_view.php?tip_id=259</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7089
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7090 Change good or bad usually encounters interia from people in excepting it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7091 gvim 6.0 is the first version that introduced the icons shortcut in shape
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7092 of a toolbar under the menu. when we upgraded to the new and improved vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7093 6.1 from vim 5.7 some of people in our company encountered some problems
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7094 with their syntax highlighting and some of them objected on the new toolbar
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7095 which displayed icons for some common tasks for people more used to GUI.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7096
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7097 I finally figured out how to remove this new feature since I also didn't
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7098 see much use for it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7099
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7100 Here is for all those who haven't figured it out yet
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7101
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7102 In your .gvimrc include the following two lines
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7103
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7104 unmenu ToolBar unmenu! ToolBar
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7105
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7106 Doing this from an open gvim does not remove them but grays them out but
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7107 doing from gvimrc does the job
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7108
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7109 I was also trying to remove the menus at the top and almost succeeded with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7110 a similar technique but somehow the Buffer menu item stays there no matter
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7111 what. IMHO it is a bug but it could very well be a feature ;)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7112
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7113 I tried this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7114
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7115 unmenu * unmenu! *
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7116
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7117 even added this line after the above two but didn't help unmenu Buffers
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7118
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7119 I hope this benefits you all as much as I have benefitted from all your tips
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7120
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7121 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7122 <html><center>gvim--&gt;mouse--&gt;popup menu</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7123 HREF="http://vim.sf.net/tip_view.php?tip_id=260">http://vim.sf.net/tip_view.php?tip_id=260</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7124
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7125 This tip is for those who prefer to do some of the common operations like
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7126 cut/copy/paste etc using mouse. All u have to do is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7127
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7128 :set mousemodel=popup
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7129
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7130 by this u get a popup menu on right click of your mouse and u can do all
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7131 the common operations like undo, cut, copy, paste, select etc using mouse.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7132
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7133 u can also customise your popup menu by editing $VIMRUNTIME/menu.vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7134
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7135 </pre></tip> </html> <Tip category="KVim"> <html><center>Close
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7136 windows from Gvim poup menu</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7137 HREF="http://vim.sf.net/tip_view.php?tip_id=261">http://vim.sf.net/tip_view.php?tip_id=261</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7138
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7139 To close windows from the popup menu add these lines to your .gvimrc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7140
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7141 :amenu PopUp.Close.\ Window :confirm close&lt;CR&gt; :amenu PopUp.Close.\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7142 Other :confirm only&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7143
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7144 You obviously need ':set mousemodel=popup' in your .gvimrc as well :=)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7145
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7146 </pre></tip> </html> <Tip category="KVim"> <html><center>Bored
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7147 of ur arrow shapped mouseptr?</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7148 HREF="http://vim.sf.net/tip_view.php?tip_id=262">http://vim.sf.net/tip_view.php?tip_id=262</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7149
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7150 here is how u can change the shape of ur mouseptr in gvim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7151
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7152 :set mouseshape=n:pencil
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7153
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7154 this will change the shape of the mouseptr to pencil in normal mode. u can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7155 choose different shapes for different modes. see :h mouseshape
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7156
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7157 Want more shapes?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7158
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7159 Then look for the file cursorfont.h in ur X11/ directory. This file contains
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7160 lots of cursor shape #define definitions, like . #define XC_heart 62 .
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7161 now :set mouseshape=n:62 will set the shape of the mouseptr to heart in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7162 normal mode.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7163
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7164 -ncr
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7165
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7166 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7167 <html><center>color active line</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7168 HREF="http://vim.sf.net/tip_view.php?tip_id=263">http://vim.sf.net/tip_view.php?tip_id=263</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7169
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7170 This tip shows how to color the active line, the line in which the cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7171 is, for better reading. You should try possibility 2 before 1, IMHO it is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7172 mostly usable.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7173
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7174 possibility 1:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7175 :au! CursorHold * let @/ = '\%' . line('.') . 'l.*' :set ut=500
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7176
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7177 explanation:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7178 After 500 ms of waiting for you to hit a key, vim sets the search
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7179 register to a pattern that matches the current line.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7180
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7181 problem:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7182 Register / holds the search pattern, so you cannot have color the active
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7183 line and search. Therefore another solution:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7184
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7185 possibility 2:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7186 :highlight CurrentLine guibg=darkgrey guifg=white (or whatever
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7187 colors you want) :au! Cursorhold * exe 'match CurrentLine /\%'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7188 . line('.') . 'l.*/' :set ut=100
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7189
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7190 explanation:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7191 This solution uses 'match' to highlight a string, it does not interface
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7192 with the current search pattern.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7193
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7194 addition:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7195 Turning the highlighning off:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7196 :au! Cursorhold :match none
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7197 The order of these commands are important. If :match none is executed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7198 first, the autocommand would almost immediately execute another match
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7199 command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7200
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7201 references to vim help:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7202 :help Cursorhold :help 'ut' :help /\%l :help "/ :help \%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7203
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7204 </pre></tip> </html> <Tip category="KVim"> <html><center>F5
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7205 Compile and Run, F8 Compile (ala Visual Studio)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7206 HREF="http://vim.sf.net/tip_view.php?tip_id=264">http://vim.sf.net/tip_view.php?tip_id=264</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7207
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7208 I love vim, it's my default editor on my Sun, Windows, Linux and *BSD boxen.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7209 That said, I hate having to flip windows to compile while doing the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7210 write-&gt;compile-&gt;debug loop.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7211
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7212 If you're used to Visual Studio and the ability it has to just hit F5 to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7213 compile and run the current file or F8 to compile or step through the code
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7214 you'll appreciate this...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7215
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7216 This is my Windows version of this scriplet/tiplet. For other platforms,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7217 you'll want to change the IF ELSE loops. You should actually never see
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7218 the "Unsuccessful" message from the compile/run loop unless the compiler
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7219 completely bombs out. This is from my _vimrc...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7220
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7221 map &lt;F5&gt; :call CompileRunGcc()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7222
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7223 map &lt;F8&gt; : call CompileGcc()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7224
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7225 func! CompileRunGcc()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7226 exec "w" "Save the file exec "!gcc % -o %&lt; && cr 10 && IF
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7227 EXIST %&lt;.exe (%&lt;) ELSE banner -c = Compile Unsuccessful
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7228 " exec "i" "jump back where we were
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7229
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7230
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7231 endfunc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7232
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7233 func! CompileGcc()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7234 exec "w" exec "!gcc % -o %&lt; && IF EXIST %&lt;.exe (cr 5 &&
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7235 banner -c # Success) ELSE banner -c # Compile Unsuccessful
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7236 " exec "i"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7237
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7238 endfunc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7239
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7240 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7241 <html><center>Fast help in full window</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7242 HREF="http://vim.sf.net/tip_view.php?tip_id=265">http://vim.sf.net/tip_view.php?tip_id=265</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7243
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7244 You can get fast access to help by writing small script
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7245
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7246 #!/bin/bash vim -c "help $1" -c only
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7247
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7248 now name it eg. vih and from cl
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7249
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7250 $ vih makeprg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7251
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7252 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7253 <html><center>use -S command line switch</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7254 HREF="http://vim.sf.net/tip_view.php?tip_id=266">http://vim.sf.net/tip_view.php?tip_id=266</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7255
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7256 The -S switch could be used to simplify common idiom: start Vim and source
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7257 a script file: gvim -c ":so foobar.vim" got translated into gvim -S foobar.vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7258
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7259 Yes, this tip is trivial but I still see the -c ":so x" way too often. Time
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7260 to update your mind!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7261
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7262 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7263 <html><center>selectively displaying abbreviations</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7264 HREF="http://vim.sf.net/tip_view.php?tip_id=267">http://vim.sf.net/tip_view.php?tip_id=267</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7265
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7266 Hi Vimmers, abbreviations have always been one of the most useful parts of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7267 vi(m), trouble is when you've got too many you forgot what you called them.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7268
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7269 You can of course list the whole lot with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7270
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7271 :ab&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7272
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7273 But did you know that you can type the first few letters of your abbreviations
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7274 and get a list of just thos abs eg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7275
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7276 :ab php&lt;cr&gt; gives me all my php abs & :ab perl&lt;cr&gt; gives me all
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7277 my perls
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7278
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7279 also try control-D instrad of &lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7280
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7281 zzapper
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7282
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7283 </pre></tip> </html> <Tip category="KVim"> <html><center>Get cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7284 position as byte percentage instead of line percentage</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7285 HREF="http://vim.sf.net/tip_view.php?tip_id=268">http://vim.sf.net/tip_view.php?tip_id=268</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7286
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7287 On line 300 of a thousand line file, Vim will show you that you're 30%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7288 through the file. But what if most of the lines have one character in them,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7289 and some of them have twenty thousand? Sometimes it comes in handy to know
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7290 your percentage through the file in terms of current-byte / total-bytes.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7291 I looked through the Vim docs and couldn't find a way to do this, so I wrote
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7292 a Vim function to show it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7293
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7294 Put this in your .vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7295
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7296 function! Percent()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7297 let byte = line2byte( line( "." ) ) + col( "." ) - 1 let size = (line2byte(
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7298 line( "$" ) + 1 ) - 1) " return byte . " " . size . " " . (byte * 100)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7299 / size return (byte * 100) / size
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7300 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7301
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7302 (Uncomment the first return to see intermediate values.)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7303
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7304 And put this somewhere in your "set statusline=...":
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7305
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7306 %{Percent()}%%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7307
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7308 See "help statusline", "help eval".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7309
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7310 </pre></tip> </html> <Tip category="KVim"> <html><center>Syntax highlighting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7311 is "out of sync", seems to correct itself with refresh ??</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7312 HREF="http://vim.sf.net/tip_view.php?tip_id=269">http://vim.sf.net/tip_view.php?tip_id=269</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7313
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7314 This one has come across the 'vim' users mailing list many times, and probably
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7315 comp.editors as well...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7316
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7317 Summary: see :help :syn-sync and search for 'sync' in your favorite syntax
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7318 file in $VIMRUNTIME/syntax
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7319
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7320 Long Version: The syntax highlight code utilizes a certain synchronization
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7321 method to efficiently figure out syntax highlighting, specifically if you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7322 aren't at the very beginning or end of a file. The specific setting is 'syntax
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7323 sync'. For various file types the method is set by default in this is setup
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7324 in the syntax file and one can vary the degree of trouble which VIM goes to to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7325 try and figure this out. As an example for C, from $VIMRUNTIME/syntax/c.vim:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7326
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7327 if exists("c_minlines")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7328 let b:c_minlines = c_minlines
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7329 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7330 if !exists("c_no_if0")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7331 let b:c_minlines = 50 " #if 0 constructs can be long
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7332 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7333 let b:c_minlines = 15 " mostly for () constructs
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7334 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7335 endif exec "syn sync ccomment cComment minlines=" . b:c_minlines
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7336
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7337 Where c_minlines is the minimum number of lines that VIM goes backward to try
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7338 to find the start of a comment for syntax highlighting. If that line which
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7339 starts a comment is outside of that range, highlighting will appear wrong.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7340
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7341 You can easily set up something like this in your .vimrc: let c_minlines=500
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7342 or even bigger, but realize that it is a performance trade-off and that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7343 syntax highlighting will slow things down.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7344
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7345 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7346 <html><center>Insert a single character</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7347 HREF="http://vim.sf.net/tip_view.php?tip_id=270">http://vim.sf.net/tip_view.php?tip_id=270</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7348
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7349 Using Insert mode to insert a single character feels clumsy (you need 3
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7350 keypresses for one character), so here's a slightly easier way:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7351
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7352 :nmap &lt;space&gt; i_&lt;esc&gt;r
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7353
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7354 Now, when in Normal mode, just press space followed by what it is you want
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7355 to insert.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7356
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7357 BUG: Repeating the insertion with . doesn't work.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7358
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7359 </pre></tip> </html> <Tip category="KVim"> <html><center>easy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7360 (un)commenting out of source code</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7361 HREF="http://vim.sf.net/tip_view.php?tip_id=271">http://vim.sf.net/tip_view.php?tip_id=271</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7362
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7363 Something that I do quite alot is comment out blocks of text, only to uncomment
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7364 that same block later. The following mappings have proven useful to me. They
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7365 can be applied using visually selected blocks, or with motion keys.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7366
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7367 " lhs comments map ,# :s/^/#/&lt;CR&gt; map ,/ :s/^/\/\//&lt;CR&gt; map ,&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7368 :s/^/&gt; /&lt;CR&gt; map ," :s/^/\"/&lt;CR&gt; map ,% :s/^/%/&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7369 map ,! :s/^/!/&lt;CR&gt; map ,; :s/^/;/&lt;CR&gt; map ,- :s/^/--/&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7370 map ,c :s/^\/\/\\|^--\\|^&gt; \\|^[#"%!;]//&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7371
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7372 " wrapping comments map ,* :s/^\(.*\)$/\/\* \1 \*\//&lt;CR&gt; map ,(
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7373 :s/^\(.*\)$/\(\* \1 \*\)/&lt;CR&gt; map ,&lt; :s/^\(.*\)$/&lt;!--
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7374 \1 --&gt;/&lt;CR&gt; map ,d :s/^\([/(]\*\\|&lt;!--\) \(.*\)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7375 \(\*[/)]\\|--&gt;\)$/\2/&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7376
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7377 The commands to comment a selection of text are as follows, begining with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7378 begining-of-line comments:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7379
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7380 ,# shell, perl, etc ,/ c++ ,&gt; email quote ," vim ,%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7381 latex, prolog ,! assembly?... add single ! ,; scheme ,-
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7382 don't remember this one... add -- ,c clears any of the previous
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7383 comments
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7384
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7385 Here are the wrapping comments, each line wrapped individually:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7386
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7387 ,* c ,( Standard ML ,&lt; html ,d clears any of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7388 the wrapping comments
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7389
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7390 </pre></tip> </html> <Tip category="KVim"> <html><center>automaticaly
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7391 formating pasted text (p=`])</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7392 HREF="http://vim.sf.net/tip_view.php?tip_id=272">http://vim.sf.net/tip_view.php?tip_id=272</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7393
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7394 In times past I used a nice editor that had the neat feature of automatically
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7395 setting pasted text to the proper indent level. Recently I've begun to miss
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7396 this so I went looking in the help and camp up with....
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7397
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7398 =`]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7399
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7400 which will format to the end of the pasted text... Perfect to call right
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7401 after you past something as the cursor ends up at the top of the pasted text,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7402 thus the mapping:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7403
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7404 :map &lt;c-p&gt; =`]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7405
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7406 " by the by the above may should be nmap and I am pretty sure c-p is unused,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7407 your mileage will vary no doubt.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7408
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7409 However I wanted the formatting to automatically be done so it was two simple
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7410 (once I figured out how!) nnoremap:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7411
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7412 " [Feral:185/02@14:27] map c-p to what p was (past with no formatting), map
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7413 p to p and = to end of pasted text. :nnoremap p p=`] :nnoremap &lt;c-p&gt; p
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7414
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7415 This simply (as the comment hints at) maps normal mode p to what p did (paste)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7416 then = to `] (last character in the previously changed text). While ctrl+p
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7417 just does what p did. (just in case you find you don't want a bit of text
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7418 auto formatted.).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7419
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7420 reference: :h :nnoremap :h p :h = :h `]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7421
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7422 Whatever the name of this idea is, tis something I find handy :)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7423
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7424 Happy VIMing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7425
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7426 </pre></tip> </html> <Tip category="KVim"> <html><center>Fast
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7427 fixing of email quotations (too long lines)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7428 HREF="http://vim.sf.net/tip_view.php?tip_id=273">http://vim.sf.net/tip_view.php?tip_id=273</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7429
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7430 When using VIM as your editor of choice, even for email processing - as I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7431 do - it is often unpleasing how some MUA's quote the email body produced by
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7432 mailers such as Outlook. The lines often span across multiple visual lines
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7433 and its difficult to reply on certain parts of it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7434
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7435 With VIM, you can quickly fix those quotations to maintain a proper 75 char
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7436 break. For example, when using Mutt, put this line in your .muttrc, or use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7437 a custom .vimrc_mail for it:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7438
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7439 set editor="vim -c 'set fo=tcrq' -c 'set tw=76'"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7440
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7441 For other MUA's this has to be fitted. However, now, when your quoted email
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7442 is displayed, you can use this VIM sequence to fix it:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7443
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7444 1. move cursor to first line of broken paragraph 2. press 'V' and move to the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7445 last line of the paragraph you want to fix 3. press 'g' and then 'q'. The
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7446 marked text will wrap around to your specified textwidth (76 in our case)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7447 and the quotations will be preserved across the lines
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7448
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7449 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7450 <html><center>Some useful mappings for TeX</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7451 HREF="http://vim.sf.net/tip_view.php?tip_id=274">http://vim.sf.net/tip_view.php?tip_id=274</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7452
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7453 You know, TeX requires a lot of additional formatting code. I'm tired of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7454 opening and closing braces, brakets,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7455 \beginning and \ending etc. I particularly hate typing \begin and \end.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7456 To help myself and to save a few(not a few) keystrokes I naturaly came up to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7457 some solutions, which I wish to share with other TeXnicians and TeXperts whhich
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7458 use Vim. "===============================cut here=========================
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7459 "=============== you can put it in ~/.vim/after/ftplugin/tex.vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7460 =============== " " Note: i_&lt;C-L&gt; " This constructs a skeleton of a TeX
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7461 environment. " You write a line like this: " floatingfigure:ht&lt;C-L&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7462 " and after you press &lt;C-L&gt;, you get: " " \begin[ht]{floatingfigure}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7463 " " \end{floatingfigure} " -- INSERT -- " " where floatingfigure is the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7464 desired environment " ht are options " : is delimiter; in fact, you can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7465 use whatever delimiter you want " as long it is not in &iskeyword option.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7466 inoremap &lt;buffer&gt; &lt;C-L&gt; 
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7467 \:s/[^][:alnum:]&lt;bar&gt;]\+/,/eg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7468 \I\begin{ea}[A]%d%%P \:s/\[,/[/e \:s/,]/]/e
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7469 \:s/\[]//e \0f{y%o\endpO
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7470 inoremap &lt;buffer&gt; { {}i inoremap &lt;buffer&gt; [ []i inoremap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7471 &lt;buffer&gt; ^ ^{}i inoremap &lt;buffer&gt; _ _{}i inoremap &lt;buffer&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7472 \( \(\)hi inoremap &lt;buffer&gt; \[ \[\]hi
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7473
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7474 " Note: v_&lt;C-L&gt; " For this to work, you have to write on a blank
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7475 line the name of " the desired environment and options (see i_&lt;C-L&gt;)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7476 and visual select " (from top to bottom) this and following lines. " After
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7477 pressing &lt;C-L&gt; the selected lines will be surrounded " with begin/end
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7478 skeleton of the environment. vnoremap &lt;buffer&gt; &lt;C-L&gt; o
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7479 \:s/[^][:alnum:]&lt;bar&gt;]\+/,/eg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7480 \I\begin{ea}[A]%d%%P \:s/\[,/[/e \:s/,]/]/e
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7481 \:s/\[]//e \0f{y%gvoo\endp
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7482 " vnoremap &lt;buffer&gt; { di{}P " vnoremap &lt;buffer&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7483 [ di[]P vnoremap &lt;buffer&gt;  di^{}P vnoremap &lt;buffer&gt;  di_{}P
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7484 vnoremap &lt;buffer&gt; \( di\(\)hP vnoremap &lt;buffer&gt; \[ di\[\]hP
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7485
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7486 " This makes "two spaces after a comma" before every :write au BufWritePre
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7487 *.tex %s/,\(\S\)/, \1/ge
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7488
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7489 "==================== You can put this in your ~/.vimrc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7490 ======================== " If cursor is inside braces and not before comma,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7491 blank or opening brace, " exit the brace block and stay in insert mode. "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7492 If cursor is outside braces, it inserts a space or perform an abbreviation
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7493 " as normal. function! CleverSpace()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7494 let CharOnCursor = strpart( getline('.'), col('.')-2, 1) let
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7495 CharAfterCursor = strpart( getline('.'), col('.'), 1) if CharOnCursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7496 !~ ',\|\s\|(' && CharAfterCursor =~ ')\|]\|}'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7497 normal x
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7498 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7499 endfunction inoremap &lt;Space&gt; &lt;Space&gt;:call CleverSpace()&lt;LF&gt;a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7500
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7501 " I use the last function not only for LaTeX but also in C sources.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7502
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7503 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7504 <html><center>Some useful mappings for TeX</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7505 HREF="http://vim.sf.net/tip_view.php?tip_id=275">http://vim.sf.net/tip_view.php?tip_id=275</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7506
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7507 You know, TeX requires a lot of additional formatting code. I'm tired of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7508 opening and closing braces, brakets,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7509 \beginning and \ending etc. I particularly hate typing \begin and \end.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7510 To help myself and to save a few(not a few) keystrokes I naturaly came up to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7511 some solutions, which I wish to share with other TeXnicians and TeXperts whhich
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7512 use Vim. "===============================cut here=========================
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7513 "=============== you can put it in ~/.vim/after/ftplugin/tex.vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7514 =============== " " Note: i_&lt;C-L&gt; " This constructs a skeleton of a TeX
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7515 environment. " You write a line like this: " floatingfigure:ht&lt;C-L&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7516 " and after you press &lt;C-L&gt;, you get: " " \begin[ht]{floatingfigure}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7517 " " \end{floatingfigure} " -- INSERT -- " " where floatingfigure is the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7518 desired environment " ht are options " : is delimiter; in fact, you can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7519 use whatever delimiter you want " as long it is not in &iskeyword option.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7520 inoremap &lt;buffer&gt; &lt;C-L&gt; 
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7521 \:s/[^][:alnum:]&lt;bar&gt;]\+/,/eg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7522 \I\begin{ea}[A]%d%%P \:s/\[,/[/e \:s/,]/]/e
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7523 \:s/\[]//e \0f{y%o\endpO
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7524 inoremap &lt;buffer&gt; { {}i inoremap &lt;buffer&gt; [ []i inoremap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7525 &lt;buffer&gt; ^ ^{}i inoremap &lt;buffer&gt; _ _{}i inoremap &lt;buffer&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7526 \( \(\)hi inoremap &lt;buffer&gt; \[ \[\]hi
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7527
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7528 " Note: v_&lt;C-L&gt; " For this to work, you have to write on a blank
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7529 line the name of " the desired environment and options (see i_&lt;C-L&gt;)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7530 and visual select " (from top to bottom) this and following lines. " After
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7531 pressing &lt;C-L&gt; the selected lines will be surrounded " with begin/end
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7532 skeleton of the environment. vnoremap &lt;buffer&gt; &lt;C-L&gt; o
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7533 \:s/[^][:alnum:]&lt;bar&gt;]\+/,/eg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7534 \I\begin{ea}[A]%d%%P \:s/\[,/[/e \:s/,]/]/e
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7535 \:s/\[]//e \0f{y%gvoo\endp
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7536 " vnoremap &lt;buffer&gt; { di{}P " vnoremap &lt;buffer&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7537 [ di[]P vnoremap &lt;buffer&gt;  di^{}P vnoremap &lt;buffer&gt;  di_{}P
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7538 vnoremap &lt;buffer&gt; \( di\(\)hP vnoremap &lt;buffer&gt; \[ di\[\]hP
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7539
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7540 " This makes "two spaces after a comma" before every :write au BufWritePre
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7541 *.tex %s/,\(\S\)/, \1/ge
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7542
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7543 "==================== You can put this in your ~/.vimrc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7544 ======================== " If cursor is inside braces and not before comma,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7545 blank or opening brace, " exit the brace block and stay in insert mode. "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7546 If cursor is outside braces, it inserts a space or perform an abbreviation
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7547 " as normal. function! CleverSpace()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7548 let CharOnCursor = strpart( getline('.'), col('.')-2, 1) let
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7549 CharAfterCursor = strpart( getline('.'), col('.'), 1) if CharOnCursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7550 !~ ',\|\s\|(' && CharAfterCursor =~ ')\|]\|}'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7551 normal x
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7552 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7553 endfunction inoremap &lt;Space&gt; &lt;Space&gt;:call CleverSpace()&lt;LF&gt;a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7554
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7555 " I use the last function not only for LaTeX but also in C sources.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7556
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7557 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7558 <html><center>Function signature previewer</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7559 HREF="http://vim.sf.net/tip_view.php?tip_id=276">http://vim.sf.net/tip_view.php?tip_id=276</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7560
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7561 Have you ever tried to call a function which parameters you have forgotten?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7562 Especially those long named and with long parameter list GTK+ functions
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7563 like gtk_menu_item_image_from_stock_new(..........) !!! By accident I saw a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7564 function in Vim help. It's name was PreviewWord and it allowed one to jump
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7565 in the preview window to the tag for the word cursor is on. I _slightly_
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7566 modified this function not to need tags file, but to search included files
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7567 instead. I wrote another function, which uses the above said one, which
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7568 triggers PreviewWord when you open the parenthesis after a function name.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7569 Here it is: " Note: " This is literally stolen from Vim help. The only
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7570 changes are: " (1) if w != "" becomes if w =~ "\k" "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7571 (2) exe "silent! ptag " . w becomes exe "silent! psearch " . w " *
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7572 The first change prevents PreviewWord of searching while cursor is on some "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7573 non-keyword characters, e.g. braces, asterisks, etc. function! PreviewWord()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7574 if &previewwindow " don't do this in the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7575 preview window
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7576 return
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7577 endif let w = expand("&lt;cword&gt;") " get the word under
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7578 cursor if w =~ "\k" " if there is one
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7579 ":ptag" to it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7580
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7581 " Delete any existing highlight before showing another tag
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7582 silent! wincmd P " jump to preview
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7583 window if &previewwindow " if we really
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7584 get there...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7585 match none " delete existing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7586 highlight wincmd p " back to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7587 old window
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7588 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7589
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7590 " Try displaying a matching tag for the word under the cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7591 let v:errmsg = "" exe "silent! psearch " . w if v:errmsg =~
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7592 "tag not found"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7593 return
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7594 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7595
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7596 silent! wincmd P " jump to preview
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7597 window if &previewwindow " if we really get
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7598 there...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7599 if has("folding")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7600 silent! .foldopen " don't want
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7601 a closed fold
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7602 endif call search("$", "b") " to end of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7603 previous line let w = substitute(w, '\\', '\\\\',
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7604 "") call search('\&lt;\V' . w . '\&gt;') "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7605 position cursor on match " Add a match highlight to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7606 the word at this position hi previewWord term=bold
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7607 ctermbg=green guibg=green exe 'match previewWord "\%'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7608 . line(".") . 'l\%' . col(".") . 'c\k*"' wincmd p
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7609 " back to old window
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7610 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7611 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7612 endfunction au! CursorHold *.[ch] nested call PreviewWord()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7613
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7614 " Note: " When you open a parenthesis after a function name, and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7615 at the " line end, that function's definition is previewed through
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7616 PreviewWord(). " This is inspired from Delphi's CodeInsight technology.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7617 " Something similar (PreviewClassMembers) could be written for " the C++
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7618 users, for previewing the class members when you type " a dot after an
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7619 object name. " If somebody decides to write it, please, mail it to me.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7620 function! PreviewFunctionSignature()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7621 let CharOnCursor = strpart( getline('.'), col('.')-2, 1) if col(".") ==
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7622 col("$")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7623 call PreviewWord()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7624 endif return "("
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7625 endfunction inoremap &lt;buffer&gt; (
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7626 &lt;C-R&gt;=PreviewFunctionSignature()&lt;LF&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7627
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7628 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7629 <html><center>Function signature previewer</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7630 HREF="http://vim.sf.net/tip_view.php?tip_id=277">http://vim.sf.net/tip_view.php?tip_id=277</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7631
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7632 Have you ever tried to call a function which parameters you have forgotten?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7633 Especially those long named and with long parameter list GTK+ functions
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7634 like gtk_menu_item_image_from_stock_new(..........) !!! By accident I saw a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7635 function in Vim help. It's name was PreviewWord and it allowed one to jump
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7636 in the preview window to the tag for the word cursor is on. I _slightly_
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7637 modified this function not to need tags file, but to search included files
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7638 instead. I wrote another function, which uses the above said one, which
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7639 triggers PreviewWord when you open the parenthesis after a function name.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7640 Here it is: " Note: " This is literally stolen from Vim help. The only
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7641 changes are: " (1) if w != "" becomes if w =~ "\k" "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7642 (2) exe "silent! ptag " . w becomes exe "silent! psearch " . w " *
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7643 The first change prevents PreviewWord of searching while cursor is on some "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7644 non-keyword characters, e.g. braces, asterisks, etc. function! PreviewWord()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7645 if &previewwindow " don't do this in the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7646 preview window
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7647 return
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7648 endif let w = expand("&lt;cword&gt;") " get the word under
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7649 cursor if w =~ "\k" " if there is one
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7650 ":ptag" to it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7651
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7652 " Delete any existing highlight before showing another tag
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7653 silent! wincmd P " jump to preview
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7654 window if &previewwindow " if we really
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7655 get there...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7656 match none " delete existing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7657 highlight wincmd p " back to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7658 old window
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7659 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7660
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7661 " Try displaying a matching tag for the word under the cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7662 let v:errmsg = "" exe "silent! psearch " . w if v:errmsg =~
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7663 "tag not found"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7664 return
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7665 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7666
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7667 silent! wincmd P " jump to preview
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7668 window if &previewwindow " if we really get
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7669 there...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7670 if has("folding")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7671 silent! .foldopen " don't want
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7672 a closed fold
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7673 endif call search("$", "b") " to end of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7674 previous line let w = substitute(w, '\\', '\\\\',
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7675 "") call search('\&lt;\V' . w . '\&gt;') "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7676 position cursor on match " Add a match highlight to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7677 the word at this position hi previewWord term=bold
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7678 ctermbg=green guibg=green exe 'match previewWord "\%'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7679 . line(".") . 'l\%' . col(".") . 'c\k*"' wincmd p
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7680 " back to old window
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7681 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7682 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7683 endfunction au! CursorHold *.[ch] nested call PreviewWord()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7684
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7685 " Note: " When you open a parenthesis after a function name, and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7686 at the " line end, that function's definition is previewed through
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7687 PreviewWord(). " This is inspired from Delphi's CodeInsight technology.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7688 " Something similar (PreviewClassMembers) could be written for " the C++
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7689 users, for previewing the class members when you type " a dot after an
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7690 object name. " If somebody decides to write it, please, mail it to me.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7691 function! PreviewFunctionSignature()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7692 let CharOnCursor = strpart( getline('.'), col('.')-2, 1) if col(".") ==
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7693 col("$")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7694 call PreviewWord()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7695 endif return "("
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7696 endfunction inoremap &lt;buffer&gt; (
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7697 &lt;C-R&gt;=PreviewFunctionSignature()&lt;LF&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7698
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7699 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7700 <html><center>all the right moves</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7701 HREF="http://vim.sf.net/tip_view.php?tip_id=278">http://vim.sf.net/tip_view.php?tip_id=278</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7702
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7703 One of the principles of effective text editing is moving around very
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7704 efficiently. Following are some pointers which may help u do that.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7705
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7706 h move one character left j move one row down
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7707 k move one row up l move one char. right. w move
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7708 to begining of next word b move to begining of previous word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7709 e move to end of word W move to begining of next word after a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7710 whitespace B move to begining of pervious word before a whitespace
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7711 E move to end of word before a whitespace.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7712
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7713 (All the above movements can be preceeded by a numeric value . i.e '4j'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7714 will move 4 rows down )
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7715
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7716 ^ move to first non blank char of the line. g_ move to last non
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7717 blank char of the line. 0 moev to begining of line $ move
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7718 to end of line. gg move to first line. G move to last line.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7719 nG move to "n"th line. H top of screen.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7720 M middle of screen
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7721 L bottom of screen
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7722 Ctrl-D move half page down Ctrl-U move half page up. Ctrl-B page-up
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7723 Ctrl-F page down.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7724
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7725 Ctrl-o last cursor position. '[a-z,0-9,A-Z] jump to the marker. (u
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7726 can set a marker on line by :- m[a-zA-Z,0-9] and then jump back to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7727 it by '[a-z,A-Z0-9]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7728
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7729 n next matching search pattern N previous matching search pattern *
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7730 next word under cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7731 # previous word under cursor. g* next matching search pattern
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7732 under cursor. g# previous matching search pattern under cursor.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7733
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7734 </pre></tip> </html> <Tip category="KVim"> <html><center>On Windows, make GVim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7735 the default action for double-click with "unknown file types"</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7736 HREF="http://vim.sf.net/tip_view.php?tip_id=279">http://vim.sf.net/tip_view.php?tip_id=279</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7737
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7738 I find myself installing the following registry modification for all my
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7739 PC's now (even other people's PC's). It applies to Microsoft Windows
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7740 machines only. The following is also for Windows 9x... NT or XP or 2000
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7741 may require modifications (which I don't care to understand!).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7742
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7743 The problem: You double-click on a file that doesn't have a 'registered type'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7744 and that pesky "What program should I use?" dialog pops up. Even worse,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7745 depending on the installation, the GVim icon may not be listed, and one has
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7746 to browse to the executable... and then the type becomes forever bonded
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7747 to being editted with GVim (if that box is checked). The standard Vim 6.1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7748 installation does include a "right click to edit" menu item for all files,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7749 but a double-click is so much faster!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7750
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7751 The solution: What if unregistered types would just automatically open up
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7752 in GVim? Well, they can.. with a little registry trickery.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7753
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7754 How to Install it:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7755
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7756 Step 1. Create a text file called "vimalways.reg" and paste the below text
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7757 into it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7758
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7759 Step 2. Important NOTE: You will have to edit the pathname to correspond
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7760 to the pathname of your GVim.exe. The text below works fine for a GVim 6.1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7761 default installation.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7762
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7763 Step 3: Save the file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7764
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7765 Step 4: Right-click on the file and select "install". Then you are done!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7766
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7767 ------ vimalways.reg ------- cut here ------snip---snip--- REGEDIT4
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7768
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7769 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7770
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7771 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Open with &GVim] @="Open
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7772 with &GVim"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7773
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7774 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Open with &GVim\command]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7775 @="\"C:\\vim\\vim61\\gvim.exe\" \"%1\""
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7776
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7777 ----end of file---- cut here----- snip---snip----
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7778
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7779 Note 1. This can't be de-installed automatically, and if you want to remove
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7780 it, you'll have to edit the registry by hand (annoying, but easy).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7781
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7782 Note 2. Keep this file around, so when you upgrade your GVim, all you have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7783 to do is modify the pathname (to say, for example, vim62) and then install
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7784 it again.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7785
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7786 Ok, thanks for playing! And thanks to the author(s) of Vim and GVim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7787 If it weren't for them, I'd still be using elvis or stevie!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7788
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7789
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7790 </pre></tip> </html> <Tip category="KVim"> <html><center>Integration
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7791 with PyUnit testing framework</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7792 HREF="http://vim.sf.net/tip_view.php?tip_id=280">http://vim.sf.net/tip_view.php?tip_id=280</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7793
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7794 Vim has a wonderful ability to integrate with external tools, like compilers,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7795 make, ctags etc. That's one of the reasons we love it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7796
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7797 PyUnit can be seen as a "compiler" for the Python test code. To understand
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7798 it, Vim should be told about the language the PyUnit speaks. This could be
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7799 done with 'errorformat' option:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7800
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7801 setlocal efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7802
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7803 This magic spell enables Vim to parse unittest.TextRunner's output and to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7804 enter quick-fix mode. To run all your unit tests at once you'll need to setup
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7805 'makeprg' option and provide a runner. I'm using this setup:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7806
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7807 setlocal makeprg=./alltests.py
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7808
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7809 And contents of the alltests.py (for the sake of completeness):
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7810
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7811 #!/usr/bin/env python2
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7812
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7813 import unittest import sys sys.path.append('unittests')
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7814
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7815 modules_to_test = (
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7816 'fooTest', 'barTest', 'bazTest',
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7817 )
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7818
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7819 def suite():
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7820 alltests = unittest.TestSuite() for module in map(__import__,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7821 modules_to_test):
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7822 alltests.addTest(unittest.findTestCases(module))
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7823 return alltests
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7824
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7825 if __name__ == '__main__':
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7826 unittest.main(defaultTest='suite')
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7827
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7828 ============== end of the alltests.py file ========================
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7829
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7830 While talking about it, I'd also suggest to add a couple of mappings.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7831 In the end, my vim/files/ftplugin/python.vim looks like this:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7832
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7833 setlocal makeprg=./alltests.py\ -q setlocal efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7834 line\ %l%.%#,%Z%[%^\ ]%\\@=%m iabbr &lt;buffer&gt; sae self.assertEquals
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7835 iabbr &lt;buffer&gt; sar self.assertRaises
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7836
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7837 For details see :help quick-fix, :help
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7838 'efm' and :help 'makeprg'. See also: <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7839 HREF="http://c2.com/cgi/wiki?PythonUnit">http://c2.com/cgi/wiki?PythonUnit</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7840
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7841 Many thanks to Stefan Roemer who patiently spent quite some time to build
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7842 'efm' for me.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7843
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7844 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7845 <html><center>Stateful zz</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7846 HREF="http://vim.sf.net/tip_view.php?tip_id=281">http://vim.sf.net/tip_view.php?tip_id=281</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7847
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7848 Do you find yourself hitting 'zz' all the time in order to see some context of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7849 what you're currently working on? If so, then this tip might be for you. If
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7850 you add the following line in your vimrc, you can toggle zz mode by pressing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7851 &lt;Leader&gt;zz.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7852
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7853 " maintain a constant zz state, second call will toggle it back off map
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7854 &lt;Leader&gt;zz :let &scrolloff=999-&scrolloff&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7855
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7856 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7857 <html><center>Folding with Regular Expression</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7858 HREF="http://vim.sf.net/tip_view.php?tip_id=282">http://vim.sf.net/tip_view.php?tip_id=282</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7859
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7860 Well, I've tried to understand some of the folding scripts, but life's too
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7861 short. Instead, I added the following lines to my vimrc file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7862
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7863 set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7864 foldexpr=(getline(v:lnum)=~@/)?0:(getline(v:lnum-1)=~@/)\|\|(getline(v:lnum+1)=~@/)?1:2
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7865 map \z :set foldmethod=expr foldlevel=0 foldcolumn=2&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7866
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7867 The first line is an extension of foldexpr=(getline(v:lnum)=~@/)?0:1 The
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7868 second line (re)sets the foldmethod to expr(ession) plus.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7869
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7870 First search for /regexp/, then fold everything else with \z Use zr to reveal
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7871 more context (before/after) lines.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7872
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7873 You could add (getline(v:lnum-2)=~@/)\|\|(getline(v:lnum+2)=~@/)?2:3 but it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7874 will take longer as folded lines (the majority) evaluate the full expression.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7875
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7876 What could be easier?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7877
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7878 </pre></tip> </html> <Tip category="KVim"> <html><center>Turn
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7879 on syntax coloring in Mac OS X</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7880 HREF="http://vim.sf.net/tip_view.php?tip_id=283">http://vim.sf.net/tip_view.php?tip_id=283</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7881
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7882 This tip is actually for vim 6.1. To turn on syntax coloring in Mac OS X
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7883 enter the following commands, or place them in your $HOME/.vimrc file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7884
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7885 :set term=builtin_beos-ansi :syntax on
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7886
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7887 </pre></tip> </html> <Tip category="KVim"> <html><center>Mapping
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7888 to print syntax highlighted buffer in B&W</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7889 HREF="http://vim.sf.net/tip_view.php?tip_id=284">http://vim.sf.net/tip_view.php?tip_id=284</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7890
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7891 I use this mapping to print syntax highlighted C++ code in B&W This tip
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7892 needs vimscript #233 print_bw.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7893
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7894 The mapping is as follows map &lt;C-p&gt; :color
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7895 print_bw&lt;CR&gt;:hardcopy&lt;CR&gt;:color sean&lt;CR&gt;:syn on&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7896
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7897 Change ":color sean" to whatever is your chosen color scheme. Need to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7898 change line 7 of print_bw from "syntax reset" to "syntax off" &lt;C-p&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7899 on a syntax highlighted buffer turns off syntax highlighting , sets the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7900 colors to B&W, prints the buffer, resets the color scheme and turns on syntax
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7901 highlighting again.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7902
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7903 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7904 <html><center>Don't use the escape key!</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7905 HREF="http://vim.sf.net/tip_view.php?tip_id=285">http://vim.sf.net/tip_view.php?tip_id=285</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7906
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7907 Vim (any vi really) is a dream for touch typists... Until you want to switch
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7908 from insert mode to normal mode. Then you've got to reach way up to whack
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7909 the escape key.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7910
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7911 Or at least that's what I was doing until I realized that (drum roll please)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7912
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7913 Esc is exactly equivalent to control-[ (that's the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7914 control key plus the left square bracket key)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7915
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7916 That little bit of knowledge, plus mapping my caps lock to another control
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7917 key, was what turned my fascination with Vim into true love. You never have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7918 to lose track of the home row again!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7919
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7920 For Xfree86 users - you can make the capslock key another control key by adding
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7921
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7922 Option "XkbOptions" "ctrl:nocaps"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7923
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7924 to the InputDevice section of your XF86Config file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7925
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7926 For Windows NT/2000 users - use the following .reg file to do the same thing:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7927
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7928 REGEDIT4
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7929
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7930 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7931 "Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7932
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7933 </pre></tip> </html> <Tip category="KVim"> <html><center>Recover
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7934 after doing something... ugly.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7935 HREF="http://vim.sf.net/tip_view.php?tip_id=286">http://vim.sf.net/tip_view.php?tip_id=286</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7936
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7937 I was once editing a file and wanted to test something. The test was meant
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7938 to add a line at the end of the file, from outside vim. All was fine, but
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7939 instead of &gt;&gt;, I wrote &gt;. You can imagine what happened... :)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7940
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7941 If you happen to do something like that, the solution is:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7942
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7943 :recover
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7944
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7945 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7946 <html><center>Cool trick to change numbers</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7947 HREF="http://vim.sf.net/tip_view.php?tip_id=287">http://vim.sf.net/tip_view.php?tip_id=287</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7948
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7949 In the gvim if you want to decrement any number just put ur curcor on that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7950 number in Esc mode and pres &lt;CTRL&gt; X
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7951
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7952 </pre></tip> </html> <Tip category="KVim"> <html><center>A keymapping
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7953 to generate Java setters and getters automatically</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7954 HREF="http://vim.sf.net/tip_view.php?tip_id=288">http://vim.sf.net/tip_view.php?tip_id=288</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7955
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7956 This mapping makes it much simpler to write new java classes by simplifying
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7957 some of the dull repetative coding (ie setters and getters).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7958
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7959 To use, first write a basic class with the following format:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7960
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7961 public class MyClass {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7962
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7963 private &lt;type&gt; &lt;varname&gt; = &lt;initvalue&gt;; private
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7964 &lt;type&gt; &lt;varname&gt; = initvalue&gt;;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7965
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7966 // getters
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7967
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7968 // setters
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7969
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7970 }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7971
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7972 Note the getters/setters comment -- they are important as they are used to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7973 place the getters and setters.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7974
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7975 The mapping is:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7976
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7977 map jgs mawv/ &lt;Enter&gt;"ty/
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7978 &lt;Enter&gt;wvwh"ny/getters&lt;Enter&gt;$a&lt;Enter&gt;&lt;Enter&gt;public
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7979 &lt;Esc&gt;"tpa&lt;Esc&gt;"npbiget&lt;Esc&gt;l~ea()&lt;Enter&gt;{&lt;Enter&gt;&lt;Tab&gt;return
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7980 &lt;Esc&gt;"npa;&lt;Enter&gt;}&lt;Esc&gt;=&lt;Enter&gt;&lt;Esc&gt;/setters&lt;Enter&gt;$a&lt;Enter&gt;&lt;Enter&gt;public
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7981 void &lt;Esc&gt;"npbiset&lt;Esc&gt;l~ea(&lt;Esc&gt;"tpa
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7982 &lt;Esc&gt;"npa)&lt;Enter&gt;{&lt;Enter&gt;&lt;Tab&gt;this.&lt;Esc&gt;"npa=&lt;Esc&gt;"npa;&lt;Enter&gt;}&lt;Esc&gt;=&lt;Enter&gt;`ak
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7983
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7984 (the above should be one long line with no spaces between the end of the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7985 lines above).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7986
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7987 To use this to generate a class go to the variable that should have a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7988 setter/getter and place the curser at the beginning of the 'private':
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7989
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7990 private &lt;type&gt; &lt;variable&gt; = &lt;initvalue&gt;' ^
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7991
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7992 Then type:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7993
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7994 jgs
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7995
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7996 this will create the first getter/setter and then move up to the next
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7997 variable. You can just keep typing jgs until all the getters/setters have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7998 been generated.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7999
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8000 This should mapping isn't perfect and someone could probably make it a little
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8001 cleaner. It could also relatively easily be adapted to C++. Please feel free
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8002 to send me any feedback/enhancements as I am trying to compile a list of these.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8003
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8004 </pre></tip> </html> <Tip category="KVim"> <html><center>Alternative
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8005 &lt;escape&gt; that allows you to do a "quick and dirty
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8006 insert" and get out into normal mode</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8007 HREF="http://vim.sf.net/tip_view.php?tip_id=289">http://vim.sf.net/tip_view.php?tip_id=289</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8008
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8009 This is an alternative key combo for the escape key from the one mentioned
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8010 by David A. Rogers in vimtip #285.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8011
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8012 I do a lot of editting in Vim, and I've always found myself in situations where
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8013 I had to "do a quick insert" - basically (from normal mode), change into insert
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8014 mode, type in one quick word, then &lt;esc&gt; out, then navigate elsewhere.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8015
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8016 As has been rightly observed by a lot of people, the &lt;esc&gt; key can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8017 sometimes be a little bit out of the way. But that's no problem for ViM, is it?
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8018
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8019 At first, I thought of editting the ViM source code itself, in order to come
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8020 up with a command that could do things like say "let me jump into insert
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8021 mode, type a few quick words, then escape out into normal mode when i press
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8022 something like double &lt;space&gt;".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8023
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8024 It was only later when reading through the section in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8025 Jesse Goerz's "Beginner's Guide to ViM" on remapping (<A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8026 HREF="http://newbiedoc.sourceforge.net/tutorials/vim/mapping-vim.html)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8027 that I got inspired to retake a look at using remapping as an alternative
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8028 instead.">http://newbiedoc.sourceforge.net/tutorials/vim/mapping-vim.html)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8029 that I got inspired to retake a look at using remapping as an alternative
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8030 instead.</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8031
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8032 This is what I came up with.. Use whatever is comfortable for you - single
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8033 or double &lt;Shift-space&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8034
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8035 :map! &lt;S-space&gt; &lt;esc&gt; :map! &lt;S-space&gt;&lt;S-space&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8036 &lt;esc&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8037
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8038 With this quick combo ("Shift", + &lt;space&gt;), one can easily (and might
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8039 I add, intuitively) "do a quick insert" and exit quickly out into normal
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8040 mode. I guess I always thought the &lt;space&gt; would be a good way to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8041 do this sort of thing, since it is after all, so intuitive in the typing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8042 process. So why not make it such that it can "escape" you out into normal
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8043 mode as well? Just type 'i', to go into insert mode, type in your stuff,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8044 and once you're done, hit Shift-space!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8045
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8046 </pre></tip> </html> <Tip category="KVim"> <html><center>Text
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8047 Processing With Integrated Spell Checking</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8048 HREF="http://vim.sf.net/tip_view.php?tip_id=290">http://vim.sf.net/tip_view.php?tip_id=290</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8049
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8050 I have written an HTML document to help others use Vim as a basic text
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8051 processing application. It discusses how to integrate spell checking,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8052 dictionary, and thesaurus applications. It also talks about wrapping lines,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8053 indentation, justification, and the vim settings that effect the behavior
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8054 of these operations. The document can be found at:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8055 <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8056 HREF="http://www.highley-recommended.com/text-processing.html">http://www.highley-recommended.com/text-processing.html</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8057
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8058 Everything has been tested with UNIX, Linux, Windows, and Windows with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8059 Cygwin patforms.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8060
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8061 </pre></tip> </html> <Tip category="KVim"> <html><center>^P
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8062 & auto filling of variables and text</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8063 HREF="http://vim.sf.net/tip_view.php?tip_id=291">http://vim.sf.net/tip_view.php?tip_id=291</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8064
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8065 Do you know you can auto fill the variable and names as you type your code
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8066 ? This will help most of the programmers, who always try hard to remember the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8067 variable names and browse through all the files to find out the variable name.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8068 Use Ctrl+P and Ctrl+N to autofill the variables names etc. Just practice,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8069 you will feel the ease of using vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8070
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8071 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8072 <html><center>vim + cscope + cygwin</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8073 HREF="http://vim.sf.net/tip_view.php?tip_id=292">http://vim.sf.net/tip_view.php?tip_id=292</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8074
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8075 I've found that vim + cscope + cygwin does not work. The problem seems to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8076 be that in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8077
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8078 sprintf(cmd, "exec %s -dl -f %s", prog, csinfo[i].fname);
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8079
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8080 vim execs cscope with the "-dl" options, causing it to fail. It is probably
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8081 a cscope bug, but a simple workaround is top build vim without thad "d":
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8082
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8083 sprintf(cmd, "exec %s -l -f %s", prog, csinfo[i].fname);
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8084
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8085 seems to work for me!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8086
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8087 </pre></tip> </html> <Tip category="KVim"> <html><center>remember
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8088 where you had ended reading help</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8089 HREF="http://vim.sf.net/tip_view.php?tip_id=293">http://vim.sf.net/tip_view.php?tip_id=293</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8090
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8091 You could jump to the last place you had been while reading Vim help files
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8092 if you add this to your .vimrc file:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8093
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8094 au BufLeave * if &ft == "help" | mark H | endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8095
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8096 Then use 'H to go to the mark H.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8097
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8098 To work between Vim runs 'viminfo' option should be setup to save file marks.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8099 See :help 'viminfo' and :help file-marks for more information.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8100
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8101 </pre></tip> </html> <Tip category="KVim"> <html><center>Use
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8102 Ctrl-S to save current or new files.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8103 HREF="http://vim.sf.net/tip_view.php?tip_id=294">http://vim.sf.net/tip_view.php?tip_id=294</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8104
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8105 I wanted to have a single key stroke that would save existing files, or call
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8106 the file browser. Here's a key map for Ctrl-S to accomplish that (place in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8107 vimrc file):
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8108
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8109 if has("gui_running")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8110 " If the current buffer has never been saved, it will have no name,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8111 " call the file browser to save it, otherwise just save it. :map
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8112 &lt;silent&gt; &lt;C-S&gt; :if expand("%") == ""&lt;CR&gt;:browse confirm
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8113 w&lt;CR&gt;:else&lt;CR&gt;:confirm w&lt;CR&gt;:endif&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8114 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8115
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8116 Tom Kimpton
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8117
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8118 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8119 <html><center>Line/word/file/whatever completion</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8120 HREF="http://vim.sf.net/tip_view.php?tip_id=295">http://vim.sf.net/tip_view.php?tip_id=295</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8121
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8122 In addition to vimtip #291 you can use whole &lt;C-x&gt; completion mode. It
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8123 can complete whole lines (&lt;C-x&gt;l, then &lt;C-p&gt;, &lt;C-n&gt;),
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8124 filenames (&lt;C-f&gt;), keywords, words from custom dictionary and many,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8125 many others. During coding it usually saves a LOT of key strokes ;) This
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8126 mode has many other powerful features, for example when completing word (by
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8127 &lt;C-x&gt;&lt;C-p&gt; or just by &lt;C-p&gt;) you can continue completion
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8128 with another &lt;C-x&gt;&lt;C-p&gt;. For example, after writing such text:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8129
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8130 this is first line second line is here
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8131
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8132 Placing cursor at third line and pressing &lt;C-x&gt;l will double last
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8133 line - &lt;C-n&gt;, &lt;C-p&gt; in this moment can be used to manipulate
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8134 completed line. Or, instead of completing whole line you can press 'f' and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8135 then complete by &lt;C-p&gt; which will result in 'first' word. After that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8136 you can &lt;C-x&gt;&lt;C-p&gt; to get 'line' word (since this is next word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8137 after 'first'). Try yourself for other powerful combinations.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8138
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8139 </pre></tip> </html> <Tip category="KVim"> <html><center>Attach
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8140 the currently open file to email</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8141 HREF="http://vim.sf.net/tip_view.php?tip_id=296">http://vim.sf.net/tip_view.php?tip_id=296</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8142
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8143 This is very simple, but most people don't seem to take advantage of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8144 this. Often you have some file (source code or other text file) already open
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8145 in an existing vim session and you need to attach it with an email. It is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8146 very simple.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8147 - First copy the filename into clipboard. For this I put the following
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8148 mapping in vimrc and press &lt;F2&gt;:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8149 nnoremap &lt;F2&gt; :let @*=expand("%:p")&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8150 - Go to your email compose window and use your regular file attachment
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8151 menu (Insert-&gt;File in outlook) and press ^V (or whatever key to paste
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8152 clipboard) and press Enter.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8153
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8154 That is all there to it. If you are on windows and your email client doesn't
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8155 accept forward-slashes, then you might want to change the map to:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8156
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8157 nnoremap &lt;F2&gt; :let @*=substitute(expand("%:p"), "/", "\\",
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8158 "g")&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8159
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8160 HTH, Hari
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8161
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8162 </pre></tip> </html> <Tip category="KVim"> <html><center>Start
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8163 in insert mode without loosing your escape key</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8164 HREF="http://vim.sf.net/tip_view.php?tip_id=297">http://vim.sf.net/tip_view.php?tip_id=297</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8165
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8166 There are two parts to this, each is fairly simple.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8167
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8168 First, I want to start in insert mode. Well "set im!" in my vimrc did the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8169 job, but I lost the escape key. Second, I have found that often times,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8170 when I'm in command mode, I hit escape trying to get back into insert mode.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8171 I am always rewarded with a beep, telling me once again I made that mistake.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8172
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8173 So I mapped esc in command mode to set insert mode (":set im") and I mapped
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8174 esc in insert mode to unset insert mode (&lt;c-o&gt;:set im) Well then I
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8175 realized if you hit "i" in command mode, escape woulding work the first time.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8176 So here's the code to add to your vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8177
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8178 set im! " start in insert mode map &lt;esc&gt; :set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8179 im!&lt;cr&gt; " escape in command mode goes to insert mode map
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8180 i :set im!&lt;cr&gt; " i in command mode goes to insert mode
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8181 map! &lt;esc&gt; &lt;c-o&gt;:set im!&lt;cr&gt; " escape in insert mode goes
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8182 to command mode
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8183
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8184 see :help insert
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8185
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8186 </pre></tip> </html> <Tip category="KVim"> <html><center>Changing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8187 case with regular expressions</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8188 HREF="http://vim.sf.net/tip_view.php?tip_id=298">http://vim.sf.net/tip_view.php?tip_id=298</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8189
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8190 I stumbled across this factoid on a website about vi. I haven't been able to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8191 locate it in the Vim documentation, but it works in Vim, and it's very handy.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8192
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8193 There are times that you might like to go through a file and change the case
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8194 of characters that match some arbitrary criteria. If you understand regular
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8195 expressions well, you can actually do this fairly easily.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8196
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8197 It's as simple as placing \U or \L in front of any backreferences in your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8198 regular expressions. Vim will make the text in the backreference uppercase
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8199 or lowercase (respectively).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8200
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8201 (A "backreference" is a part of a regular expression that refers to a previous
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8202 part of a regular expression. The most common backrefernces are &, \1, \2,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8203 \3, ... , \9).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8204
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8205 Some examples that demonstrate the power of this technique:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8206
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8207 Lowercase the entire file - :%s/.*/\L&/g
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8208
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8209 (& is a handy backreference that refers to the complete text of the match.)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8210
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8211 Uppercase all words that are preceded by a &lt; (i.e. opening HTML tag names):
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8212 :%s/&lt;\(\w*\)/&lt;\U\1/g
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8213
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8214 Please add a note if you know where this is in the documentation. I have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8215 done Ctrl-D searches on upper, lower, \U, and \L with no luck.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8216
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8217 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8218 <html><center>Open file under cursor.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8219 HREF="http://vim.sf.net/tip_view.php?tip_id=299">http://vim.sf.net/tip_view.php?tip_id=299</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8220
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8221 A little thing that I did and found quite useful:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8222
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8223 function! OpenFileUnderCursor()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8224 let FileName = expand("&lt;cfile&gt;") let OldPath = getcwd() silent cd
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8225 %:p:h execute "silent sp +e " . FileName execute "silent cd " . OldPath
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8226 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8227
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8228 map! silent &lt;M-e&gt; :call OpenFileUnderCursor()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8229
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8230 Then use Alt+E on a filename to open it (relative to the directory the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8231 current file resides in).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8232
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8233 </pre></tip> </html> <Tip category="KVim"> <html><center>Making
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8234 a tags file for IDL (Interactive Data Language)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8235 HREF="http://vim.sf.net/tip_view.php?tip_id=300">http://vim.sf.net/tip_view.php?tip_id=300</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8236
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8237 I have recently began using the tags features of vim (:help tags) with my
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8238 fortran codes and come to appreciate their power. I also do a lot of coding
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8239 in IDL (Interactive Data Language), but found that ctags did not have native
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8240 support for IDL. If you take the time you can learn how to get ctags to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8241 support IDL, but I found, after a search of usenet, that someone else has
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8242 already done this and written a perl script called idltags. It is part
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8243 of an emacs package (is anyone still reading?) that you need to download,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8244 called idlwave, which is located at:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8245 <A HREF="http://idlwave.org/">http://idlwave.org/</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8246 and currently (I don't know if this will change) the direct download link is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8247 <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8248 HREF="http://idlwave.org/download/idlwave.tar.gz">http://idlwave.org/download/idlwave.tar.gz</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8249 In the usenet pages the maintainer, JD Smith, was suggesting that idlwave
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8250 had outgrown idltags and was not sure it was still needed, so I don't know
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8251 how long it will be available.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8252
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8253 </pre></tip> </html> <Tip category="KVim"> <html><center>Edit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8254 files in path, or related.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8255 HREF="http://vim.sf.net/tip_view.php?tip_id=301">http://vim.sf.net/tip_view.php?tip_id=301</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8256
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8257 You can write a little shell function that will let you easily edit any file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8258 that is in the path, or which's location can be retrieved with the whereis
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8259 tool. This is something similar to what I have in /etc/profile:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8260
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8261 function vvim() { vim `whereis $1|cut -d: -f2` } function ggvim() { gvim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8262 `whereis $1|cut -d: -f2` }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8263
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8264 Then just type, for example, "vvim ls", and you'll start vim with /bin/ls
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8265 and /usr/share/man/ls.1.gz loaded :) (it's not very useful to edit /bin/ls,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8266 but you get the ideea ;)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8267
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8268 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8269 <html><center>Use gvim in kmail</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8270 HREF="http://vim.sf.net/tip_view.php?tip_id=302">http://vim.sf.net/tip_view.php?tip_id=302</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8271
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8272 To automatically open gvim to edit in kmail, "-f" command line option must
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8273 be used . In kmail configuration go to the composer settings , and write
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8274 in the "use external editor" field the following command : "gvim -f %f"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8275 Without -f option gvim would work in background and editing would not have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8276 any effect on kmail.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8277
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8278 </pre></tip> </html> <Tip category="KVim"> <html><center>Statusline
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8279 Tab Level Function Ruler TVIM</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8280 HREF="http://vim.sf.net/tip_view.php?tip_id=303">http://vim.sf.net/tip_view.php?tip_id=303</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8281
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8282 I use this function to let me know if my cursor is on a TAB column. The t*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8283 on the ruler means I am not. But t3 means the cursor is on tablevel 3 ~vimrc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8284 ----------------------- My Ruler ------------------------ r4,c13,t3 ~vimrc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8285 ----------------------- My Ruler ------------------------ r4,c14,t* If you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8286 want to change a tab level you can drag or push the first character of a line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8287 to a desired tab level. (more on that later) This ruler replacement will let
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8288 you know where you are, whether you like to use space tabs (see vimtip #12 )
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8289 or regular tabs. My function is set to four space tabs stops and only goes
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8290 9 levels but can be easily modified.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8291
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8292 Actually I just wanted to learn how to use a function in my _vimrc and this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8293 was my first attempt. Add this to your _vimrc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8294
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8295 "--------------------cut------------------ set laststatus=2 "This makes sure
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8296 the ruler shows. See help laststatus set statusline=%f\ ---------\ My\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8297 Ruler\ ----------\ r%l,c%c,t%{ShowTab()} "See help statusline (I toggle
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8298 between 12 helpful rulers -- more on that later) fu ShowTab()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8299 let TabLev='*' let Col=(col(".")) if Col == 1 | let TabLev='0' |
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8300 en if Col == 5 | let TabLev='1' | en if Col == 9 | let TabLev='2' |
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8301 en if Col ==13 | let TabLev='3' | en if Col ==17 | let TabLev='4' |
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8302 en if Col ==21 | let TabLev='5' | en if Col ==25 | let TabLev='6' |
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8303 en if Col ==29 | let TabLev='7' | en if Col ==33 | let TabLev='8' |
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8304 en if Col ==37 | let TabLev='9' | en
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8305 return TabLev endf "The ruler (statusline) shows a t* unless you are on
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8306 col 1,5,9,13,... "-------------------cut-------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8307
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8308 This function ShowTab() gets called and updates the ruler with every cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8309 move but it does not slow things down as I type. Perhaps a speed typist
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8310 may complain :-) In case I write something else you may search on the key
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8311 word TVIM Best Wishes TVIM Tamed Vim paradocs@frontiernet.net
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8312
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8313 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8314 <html><center>fold braces and javadoc</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8315 HREF="http://vim.sf.net/tip_view.php?tip_id=304">http://vim.sf.net/tip_view.php?tip_id=304</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8316
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8317 If you'd like to have javadoc folded together with areas in braces try that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8318 &lt;pre&gt; set foldmethod=syntax set foldenable syn region foldBraces
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8319 start=/{/ end=/}/ transparent fold syn region foldJavadoc start=,/\*\*,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8320 end=,\*/, transparent fold keepend &lt;/pre&gt; and play a bit with:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8321 &lt;pre&gt; set foldlevel=0 set foldnestmax=10 &lt;/pre&gt; parameters
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8322
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8323 </pre></tip> </html> <Tip category="KVim"> <html><center>Best
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8324 of VIM Tips (VIM's best Features)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8325 HREF="http://vim.sf.net/tip_view.php?tip_id=305">http://vim.sf.net/tip_view.php?tip_id=305</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8326
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8327 Here's a necessarily cryptic list of "MY" Best Vim Tips
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8328 that I've gleaned from <A HREF="http://vim.sf.net/ &
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8329 comp.editors ">http://vim.sf.net/ & comp.editors </A><BR> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8330 HREF="http://groups.google.com/groups?safe=off&group=comp.editors">http://groups.google.com/groups?safe=off&group=comp.editors</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8331
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8332 updated version at <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8333 HREF="http://www.rayninfo.co.uk/vimtips.html">http://www.rayninfo.co.uk/vimtips.html</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8334 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8335 # Absolutely essential
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8336 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8337 vim.sf.net : Visit frequently comp.editors : "VIM" dominated
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8338 newsgroup * # g* g# : find word under cursor (forwards/backwards)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8339 % : match brackets {}[]() matchit.vim : % now matches
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8340 tags &lt;tr&gt;&lt;td&gt;&lt;script&gt; etc &lt;C-N&gt; &lt;C-P&gt; : word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8341 completion in insert mode &lt;C-X&gt;&lt;C-L&gt; : Line complete SUPER
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8342 USEFUL /&lt;C-R&gt;&lt;C-W&gt; : Pull &lt;cword&gt; onto search/command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8343 line :set ignorecase # you nearly always want this :syntax on : colour
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8344 syntax in Perl,HTML,PHP etc :h slash&lt;C-D&gt; : type control-D and get a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8345 list all help topics containing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8346 slash (plus use TAB for Help completion)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8347 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8348 # MAKE IT EASY TO UPDATE/RELOAD_vimrc :nmap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8349 ,s :source $VIM/_vimrc :nmap ,v :e $VIM/_vimrc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8350 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8351 #VISUAL MODE Mappings :vmap sb "zdi&lt;b&gt;&lt;C-R&gt;z&lt;/b&gt;&lt;ESC&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8352 : wrap &lt;b&gt;&lt;/b&gt; around VISUALLY selected
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8353 Text :vmap st "zdi&lt;?= &lt;C-R&gt;z ?&gt;&lt;ESC&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8354 : wrap &lt;?= ?&gt; around VISUALLY selected Text
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8355 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8356 # Exploring :Ex : file explorer note capital Ex \be
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8357 : builtin buffer explorer :ls : list of buffers(eg
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8358 following) :cd .. : move to parent directory
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8359 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8360 # Great guu : lowercase line gUU
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8361 : uppercase line gf : open file name under
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8362 cursor (SUPER) ga : display hex,ascii value of
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8363 character under cursor ggVGg? : rot13 whole file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8364 CTRL-A,CTRL-X : increment,decerement number under cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8365 win32 users must remap CNTRL-A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8366 CTRL-R=5*5 : insert 25 into text
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8367 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8368 # Makes all other tips superfluous :h 42 :h holy-grail :help!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8369 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8370 # Markers & moving about '. : jump to last modification
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8371 line (SUPER) `. : jump to exact spot in last modification
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8372 line &lt;C-O&gt; : retrace your movements in file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8373 (old) &lt;C-I&gt; : retrace your movements in file (new)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8374 :ju(mps) :help jump-motions :history : list of all your commands
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8375 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8376 # Abbreviations & maps :map &lt;f7&gt; :'a,'bw! c:/aaa/x :map &lt;f8&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8377 :r c:/aaa/x :map &lt;f9&gt; :w&lt;CR&gt;:!c:/php/php.exe %&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8378 :map &lt;f11&gt; :.w! c:/aaa/xr&lt;CR&gt; :map &lt;f12&gt; :r
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8379 c:/aaa/xr&lt;CR&gt; :ab php : list of abbreviations beginning
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8380 php :map , : list of maps beginning , # For use in Maps
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8381 &lt;CR&gt; : carriage Return for maps &lt;ESC&gt; :
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8382 Escape &lt;LEADER&gt; : normally \ &lt;BAR&gt; : | pipe
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8383 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8384 # List your Registers :reg : display contents
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8385 of all registers "1p.... : retrieve numeric buffers
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8386 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8387 # Useful trick "ayy@a : execute "Vim command" in a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8388 text file yy@" : same thing using unnamed register
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8389 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8390 # Get output from other commands :r!ls.exe :
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8391 reads in output of ls !!date : same thing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8392 :%!sort -u : use an external program to filter content
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8393 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8394 # Multiple Files Management :wn : write file and move to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8395 next (SUPER) :bd : remove file from buffer list (SUPER)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8396 :sav php.html : Save current file as php.html and "move" to php.html
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8397 :sp fred.txt : open fred.txt into a split :e! : return to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8398 unmodified file :w c:/aaa/% : save file elsewhere :e # :
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8399 edit alternative file :e % :rew : rewwind to first file in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8400 ARGS :bn : next file :bp : next file :brew
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8401 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8402 # Recording (BEST TIP of ALL) qq # record to q your commands
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8403 q @q to execute @@ to Repeat # editing a register/recording "ap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8404 &lt;you can now see register contents, edit as required&gt; "add @a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8405 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8406 # _vimrc essentials :set incsearch : jumps to search word as you type (annoying
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8407 but excellent) :set wildignore=*.o,*.obj,*.bak,*.exe :set shiftwidth=3
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8408 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8409 # launching Win IE :nmap ,f :update&lt;CR&gt;:silent
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8410 !start c:\progra~1\intern~1\iexplore.exe
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8411 file://%:p&lt;CR&gt; :nmap ,i :update&lt;CR&gt;: !start
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8412 c:\progra~1\intern~1\iexplore.exe &lt;cWORD&gt;&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8413 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8414 # FTPing from VIM cmap ,r :Nread <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8415 HREF="ftp://209.51.134.122/public_html/index.html
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8416 ">ftp://209.51.134.122/public_html/index.html </A><BR> cmap ,w :Nwrite <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8417 HREF="ftp://209.51.134.122/public_html/index.html">ftp://209.51.134.122/public_html/index.html</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8418 gvim <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8419 HREF="ftp://209.51.134.122/public_html/index.html">ftp://209.51.134.122/public_html/index.html</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8420 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8421 # appending to registers (use CAPITAL) # yank
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8422 5 lines into "a" then add a further 5 "a5yy 10j "A5yy
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8423 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8424 [I : show lines matching word under cursor &lt;cword&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8425 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8426 #Conventional Shifting :'a,'b&gt;&gt; # visual shifting
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8427 (builtin-repeat) :vnoremap &lt; &lt;gv :vnoremap &gt; &gt;gv
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8428 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8429 # searching /^joe.*fred.*bill/ : normal /^[A-J]\+/ : search
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8430 for lines beginning A-J followed by at leat 1 A-J /forum\(\_.\)*pent
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8431 search over possible multiple lines /fred\_s*joe/i : any
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8432 whitespace including newline /fred\|joe : Search for FRED OR JOE
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8433 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8434 #substitution :%s/fred/joe/igc : general substitute command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8435 :%s/\r//g : Delete DOS returns ^M :'a,'bg/fred/s/dick/joe/gc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8436 : VERY USEFUL :s/\(.*\):\(.*\)/\2 : \1/ : reverse fields separated
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8437 by : :%s/^.\{-}pdf/new.pdf/ non greedy matching (ie to first pdf)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8438 :s/fred/&lt;c-r&gt;a/g substitute "fred" with contents of register "a"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8439 :%s/^\(.*\)\n\1/\1$/ delete duplicate lines # non-greedy matching
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8440 \{-} :%s/^.\{-}pdf/new.pdf/ :help /\{-} :s/fred/&lt;c-r&gt;a/g
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8441 substitute "fred" with contents of register "a" # multiple commands
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8442 :%s/\f\+\.gif\&gt;/\r&\r/g | v/\.gif$/d | %s/gif/jpg/ :%s/suck\|buck/loopy/gc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8443 : ORing :s/__date__/\=strftime("%c")/ : insert datestring
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8444 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8445 # global command :g/^\s*$/d :delete all blank lines :g!/^dd/d :
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8446 delete lines not containing string :v/^dd/d : delete lines not
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8447 containing string :g/fred/,/joe/d : not line based :v/./.,/./-1join : compress
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8448 empty lines :'a,'b g/^Error/ . w &gt;&gt; errors.txt :g/cmap\|form/p : ORing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8449 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8450 # Paste register * :redir @* : redirect commands to paste :redir
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8451 END "*yy : yank to paste "*p : insert paste buffer
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8452 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8453 # Formatting text gq&lt;CR&gt; gqap (a is motion p paragraph (visual mode))
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8454 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8455 # Operate command over multiple files :argdo
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8456 %s/foo/bar/ :bufdo %s/foo/bar/ :windo %s/foo/bar/
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8457 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8458 # Command line tricks gvim -h ls | gvim - : edit a PIPE!! #
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8459 vg.ksh (shell script) # vi all files in directory containing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8460 keyword $1 and jump to $1 gvim.exe -c "/$1" $(grep -isl "$1" *) &
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8461 ------------------------------------------------------------------------------
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8462
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8463 </pre></tip> </html> <Tip category="KVim"> <html><center>Open a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8464 web-browser with the URL in the current line</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8465 HREF="http://vim.sf.net/tip_view.php?tip_id=306">http://vim.sf.net/tip_view.php?tip_id=306</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8466
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8467 function! Browser ()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8468 let line = getline (".") let line = matchstr (line, "http[^ ]*") exec
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8469 "!netscape ".line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8470 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8471
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8472 map &lt;Leader&gt;w :call Browser ()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8473
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8474 </pre></tip> </html> <Tip category="KVim"> <html><center>annoying
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8475 "Hit any key to close this window..."</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8476 HREF="http://vim.sf.net/tip_view.php?tip_id=307">http://vim.sf.net/tip_view.php?tip_id=307</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8477
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8478 i use gvim and bash heavily under win98. i have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8479
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8480 let $HOME = substitute($HOME, '\\', '/', 'g') set shell=bash\ --rcfile\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8481 \"$HOME\"_bashrc\ -i
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8482
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8483 in my _vimrc, and something like
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8484
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8485 function br() { if [ $1 ]; then
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8486 explorer.exe ${1//\//\\}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8487 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8488 explorer.exe ${PWD//\//\\}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8489 fi
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8490 }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8491
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8492 in my _bashrc. when i finish editing one html file, i simply type :!br %
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8493
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8494 everything works fine now. but when :!br % executes, one console window will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8495 bump out and wait me to press some key to contiue. i consider this quiet
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8496 annoying. i want the console window to disappear automatically if no fault
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8497 has happened. does anyone know how to achieve this? thanks.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8498
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8499 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8500 <html><center>Move through wrapped lines.</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8501 HREF="http://vim.sf.net/tip_view.php?tip_id=308">http://vim.sf.net/tip_view.php?tip_id=308</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8502
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8503 If you don't like the fact that when you press Up and Down on a wrapped line,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8504 you get to the next phisical line instead of the next line on the screen,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8505 you can do something like this:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8506
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8507 imap &lt;silent&gt; &lt;Down&gt; &lt;C-o&gt;gj imap &lt;silent&gt; &lt;Up&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8508 &lt;C-o&gt;gk
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8509
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8510 nmap &lt;silent&gt; &lt;Down&gt; gj nmap &lt;silent&gt; &lt;Up&gt; gk
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8511
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8512 </pre></tip> </html> <Tip category="KVim"> <html><center>close
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8513 vim you left open remotely</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8514 HREF="http://vim.sf.net/tip_view.php?tip_id=309">http://vim.sf.net/tip_view.php?tip_id=309</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8515
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8516 Vim 6 has this cool client-server protocol. I use it all the time to edit
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8517 a file in an existing gvim, like so $ gvim --remote [filename]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8518
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8519 Today I left myself logged in at the console at work, and when I got home
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8520 I realized I had left vim running with files unsaved. I think I even left
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8521 it in insert mode. I wanted to edit these files at home. So I ssh'd to the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8522 machine and started playing with the --remote commands.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8523
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8524 :help was a bit cryptic
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8525 --remote-send {keys} Send {keys} to server and exit.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8526
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8527 After a lot of failed attempts, I finally succeeded in getting the remote
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8528 vim to save its buffers and quit.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8529
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8530 $ DISPLAY=:0 vim --servername GVIM --remote-send '&lt;ESC&gt;:wqa&lt;CR&gt;'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8531
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8532 A couple of notable things. Then environment variable DISPLAY has to be the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8533 display of the remote vim, and you have to be able to open that display. The
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8534 client-server stuff is done through X.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8535
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8536 The &lt;CR&gt; is important. This part eluded me for a long time. The {keys}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8537 are just like keys you would press if you were editing at the console,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8538 and you have to press enter, or vim won't do anything.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8539
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8540 Check your .swp files to make sure vim really closed the files it was
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8541 editing. Vim provides little feedback as to the success or failure of what
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8542 you're trying to do remotely. Nonetheless, it's clearly a useful feature to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8543 have available.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8544
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8545 </pre></tip> </html> <Tip category="KVim"> <html><center>showing ascii
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8546 value of the current character in decimal, hex, and octal</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8547 HREF="http://vim.sf.net/tip_view.php?tip_id=310">http://vim.sf.net/tip_view.php?tip_id=310</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8548
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8549 dont know if you guys know this or not, but i was trying to make the word
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8550 "hello" to upper case by trying "gaUw" (= which didnt work but it showed
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8551 the decimal, hex, and octal of the char under the cursor... ncie to know.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8552
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8553 </pre></tip> </html> <Tip category="KVim"> <html><center>Open
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8554 the folder containing the currently open file</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8555 HREF="http://vim.sf.net/tip_view.php?tip_id=311">http://vim.sf.net/tip_view.php?tip_id=311</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8556
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8557 Occasionally, on windows, I have files open in gvim, that the folder for that
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8558 file is not open. This key map opens the folder that contains the currently
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8559 open file. The expand() is so that we don't try to open the folder of an
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8560 anonymous buffer, we would get an explorer error dialog in that case.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8561
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8562 if has("gui_running")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8563 if has("win32")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8564 " Open the folder containing the currently open file. Double &lt;CR&gt; at
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8565 end " is so you don't have to hit return after command. Double quotes are
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8566 " not necessary in the 'explorer.exe %:p:h' section. :map &lt;silent&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8567 &lt;C-F5&gt; :if expand("%:p:h") != ""&lt;CR&gt;:!start explorer.exe
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8568 %:p:h&lt;CR&gt;:endif&lt;CR&gt;&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8569 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8570 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8571
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8572 Tom.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8573
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8574 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8575 <html><center>Copy, Cut, and Paste</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8576 HREF="http://vim.sf.net/tip_view.php?tip_id=312">http://vim.sf.net/tip_view.php?tip_id=312</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8577
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8578 PS: copy, cut, and paste are the words from (usually) gui editor.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8579
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8580 Ever try to cut (or copy) some lines and paste to another place? If you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8581 need to count the lines first, then try these to eliminate counting task.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8582
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8583 Cut and Paste:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8584
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8585 1. Place the cursor at the beginning of the block you want to CUT. 2. Mark
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8586 it with md 3. Go to the end of the block. 4. Cut it with d'd 5. Go to the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8587 new location that you want to PASTE those text. 6. Press P.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8588
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8589 Copy and Paste:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8590
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8591 1. Place the cursor at the beginning of the block you want to COPY. 2. Mark
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8592 it with my 3. Go to the end of the block. 4. Cut it with y'y 5. Go to the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8593 new location that you want to PASTE those text. 6. Press P.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8594
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8595 The name of the mark used is related to the operation (d:delete or y:yank).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8596 I found that those mark names requires minimal movement of my finger. ;)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8597
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8598 </pre></tip> </html> <Tip category="KVim"> <html><center>printing
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8599 using kprinter (unix + kde)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8600 HREF="http://vim.sf.net/tip_view.php?tip_id=313">http://vim.sf.net/tip_view.php?tip_id=313</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8601
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8602 just add set printexpr=system('kprinter'\ .\ '\ '\ .\ v:fname_in)\ .\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8603 delete(v:fname_in)\ +\ v:shell_error to your ~/.vimrc; further on all your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8604 printing will be piped through the nice and consistent print-dialog of kde.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8605
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8606 lg, tomte
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8607
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8608 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8609 <html><center>Insert and back...</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8610 HREF="http://vim.sf.net/tip_view.php?tip_id=314">http://vim.sf.net/tip_view.php?tip_id=314</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8611
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8612 this is related to vimtip #289 in terms of programmers (like I) too lazy to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8613 move their hands to reach the far far away &lt;esc&gt; key.... joking! :)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8614 actually the less your hands move around the faster you type, and the fester
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8615 you type the more time you have on your hands to think of "what" you type...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8616
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8617 here is a small snippet from my mappings file, ready to speed things up: //
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8618 the key overloading might be a somewhat confusing at first....
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8619
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8620 --cut--- imap &lt;S-Space&gt; &lt;esc&gt;l imap &lt;C-CR&gt; &lt;esc&gt;o
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8621 imap &lt;S-CR&gt; &lt;esc&gt;O
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8622
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8623 nmap &lt;S-Space&gt; i nmap &lt;space&gt;&lt;space&gt; i nnoremap &lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8624 o nmap &lt;S-CR&gt; O
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8625
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8626 ---uncut---
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8627
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8628 Good luck!!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8629
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8630 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8631 <html><center>"Smart &lt;home&gt;"</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8632 HREF="http://vim.sf.net/tip_view.php?tip_id=315">http://vim.sf.net/tip_view.php?tip_id=315</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8633
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8634 to make it faster to navigate through indented code here is a common way to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8635 "go home"...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8636
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8637 ---cut--- fun! s:SmartHome()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8638 if col('.') != match(getline('.'), '\S')+1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8639 norm ^
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8640 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8641 :call cursor(line('.'),2) norm h
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8642 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8643 endfun inoremap &lt;silent&gt;&lt;home&gt; &lt;C-O&gt;:call
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8644 &lt;SID&gt;SmartHome()&lt;CR&gt; nnoremap &lt;silent&gt;&lt;home&gt; :call
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8645 &lt;SID&gt;SmartHome()&lt;CR&gt; vnoremap &lt;silent&gt;&lt;home&gt; :call
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8646 &lt;SID&gt;SmartHome()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8647
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8648 ---uncut---
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8649
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8650 what this snippet does is make the &lt;home&gt; key behave as it does in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8651 such IDEs as PythonWin or MSVisualStudio, and that is first go to the first
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8652 non whitespace, and then to the first char on the line.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8653
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8654 </pre></tip> </html> <Tip category="KVim"> <html><center>Using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8655 /pattern/ search in a script</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8656 HREF="http://vim.sf.net/tip_view.php?tip_id=316">http://vim.sf.net/tip_view.php?tip_id=316</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8657
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8658 There are a number of ways you can search for a pattern in a script.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8659 The search function is the typical way to search for a pattern. But, it
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8660 has limited options. In particular, there are no options to control the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8661 position of the cursor after it matches the pattern.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8662
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8663 Instead you can use :normal command. The secret is to add a &lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8664 (^M) on the end of the command. For example, to search for "pattern"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8665 and move the cursor to the end of the matching pattern issue the command:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8666
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8667 :normal /pattern/e+1^M
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8668
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8669 where ^M is a real carriage return. It can be entered with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8670 &lt;c-v&gt;&lt;c-m&gt;.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8671
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8672 Another use is when you want to enter a bunch of normal commands together.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8673 For example, if you were looking to find a '{' to highlight and delete
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8674 a C block. The '{' may not be on the same line so you can't use the "f"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8675 normal command.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8676
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8677 :normal V/{/^M%d
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8678
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8679 A drawback to using the normal command is that if the pattern does not
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8680 match then it is difficult to detect. Also, you can get in trouble with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8681 the wrapscan setting.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8682
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8683 For more information about these commands look at
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8684
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8685 :help / :help normal :help search()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8686
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8687 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8688 <html><center>Mozilla Vim Keybindings</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8689 HREF="http://vim.sf.net/tip_view.php?tip_id=317">http://vim.sf.net/tip_view.php?tip_id=317</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8690
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8691 If you use VIM you like the h, j, k, and l movement keys. I found myself
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8692 annoyed at not having these movement keys available when browsing web pages.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8693 Moving to the arrow keys on a laptop is annoying to just scroll the page.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8694
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8695 Locate your mozilla/res/builtin directory (varies by platform). You could
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8696 search for htmlBindings.xml to find it. (ie. locate htmlBindings.xml.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8697
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8698 On Mac OS X it's inside the Mozilla application bundle.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8699 /Applications/Mozilla/Mozilla.app/Contents/MacOS/res/builtin.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8700
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8701 Create a new XML file called userHTMLBindings.xml, making it executable for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8702 all users and making sure the CRLF format is the same as htmlBindings.xml.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8703 i.e. on Mac OS X most files use \r but Vim writes \n instead. You can either
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8704 save the file with Vim as a Mac formatted file or use tr '\n' '\r' &lt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8705 input.xml &gt; output.xml to convert the file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8706
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8707 Place the following XML into the userHTMLBindings.xml file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8708
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8709 &lt;?xml version="1.0"?&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8710
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8711 &lt;bindings id="htmlBindings"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8712 xmlns="<A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8713 HREF="http://www.mozilla.org/xbl"">http://www.mozilla.org/xbl"</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8714 xmlns:xul="<A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8715 HREF="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;">http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8716
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8717 &lt;binding id="browserUser"&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8718 &lt;handlers&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8719 &lt;handler event="keypress" key="h" command="cmd_scrollLeft"/&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8720 &lt;handler event="keypress" key="j" command="cmd_scrollLineDown"/&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8721 &lt;handler event="keypress" key="k" command="cmd_scrollLineUp"/&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8722 &lt;handler event="keypress" key="l" command="cmd_scrollRight"/&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8723 &lt;/handlers&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8724 &lt;/binding&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8725 &lt;/bindings&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8726
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8727 There are many more bindings one could configure to get Vim like keybindings.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8728 You can read <A HREF="http://www.mozilla.org/unix/customizing.html#keys for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8729 more information.">http://www.mozilla.org/unix/customizing.html#keys for
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8730 more information.</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8731
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8732 PS. I love the keymaster/gatekeeper xul reference in the xul URL above.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8733 It's from the original GhostBusters movie. ;-)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8734
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8735
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8736
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8737 </pre></tip> </html> <Tip category="KVim"> <html><center>Extended
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8738 Bracket and Parenthesis + extras for perl</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8739 HREF="http://vim.sf.net/tip_view.php?tip_id=318">http://vim.sf.net/tip_view.php?tip_id=318</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8740
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8741 This is an extension of vimtip #153 I found this tip useful, but the jump
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8742 seemed out of place for me, I couldn't enter just one ' or ", and so I created
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8743 an improvement Basically, I set it up so that when you're in perl and have
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8744 a non keyword charcter, (except for @, $ and % for perl) and you type a {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8745 you get: {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8746 | &lt;- cursor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8747 } Where as, when I have a keyword I get: word{} With the cursor in the middle,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8748 for hashes in perl. I can jump out of any block, except the "" or '' blocks,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8749 by typing their closing charcter. So } jumps me out past the next } in
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8750 the file.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8751
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8752 Warning, this search may wrap around.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8753
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8754 Finally, I made it so that, using the alt key, &lt;Alt-'&gt; inserts a '
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8755 &lt;Alt-/&gt; inserts a " &lt;Alt-[&gt; inserts a [ &lt;Alt-]&gt; inserts a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8756 ] &lt;Alt--&gt; inserts a { &lt;Alt-=&gt; inserts a } &lt;Alt-,&gt; inserts
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8757 a &lt; &lt;Alt-.&gt; inserts a &gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8758
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8759 "######################################## " File -
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8760 matchMe.vim " Date - Wednesday, August 21, 2002
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8761 "########################################
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8762
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8763 " This code fixes my problem with " does the one format for perl and still
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8764 keeps hashes function! InsertBrackets()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8765 let fileType = &ft
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8766
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8767 if fileType == 'perl'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8768 let col = col('.') - 1 if !col || getline('.')[col - 1] !~
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8769 '\k' && getline('.')[col - 1] !~ '\$' && getline('.')[col - 1]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8770 !~ '@' && getline('.')[col - 1] !~ '%' && getline('.')[col -
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8771 1] !~ '#'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8772 return "{\&lt;cr&gt;\&lt;bs&gt;}\&lt;esc&gt;ko"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8773 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8774 return "{}\&lt;esc&gt;i\&lt;c-o&gt;:echo \&lt;cr&gt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8775 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8776 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8777 return "{\&lt;cr&gt;\&lt;bs&gt;}\&lt;esc&gt;ko"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8778 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8779 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8780
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8781 " This code jumps out of the brackets function! JumpNext(normChar)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8782 let ret =
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8783 "\&lt;space&gt;\&lt;esc&gt;ma\&lt;left&gt;/\\".a:normChar."\&lt;cr&gt;mb`ai\&lt;del&gt;\&lt;esc&gt;`bi\&lt;right&gt;"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8784 return ret
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8785 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8786
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8787 " mappings inoremap " ""&lt;esc&gt;i&lt;c-o&gt;:echo
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8788 &lt;cr&gt; inoremap ' ''&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8789 inoremap &lt; &lt;&gt;&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8790 inoremap ( ()&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt; inoremap [
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8791 []&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt; inoremap { &lt;c-r&gt;=InsertBrackets
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8792 ()&lt;cr&gt; inoremap &gt; &lt;c-r&gt;=JumpNext("&gt;")&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8793 inoremap ) &lt;c-r&gt;=JumpNext(")")&lt;cr&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8794 inoremap ] &lt;c-r&gt;=JumpNext("]")&lt;cr&gt; inoremap }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8795 &lt;c-r&gt;=JumpNext("}")&lt;cr&gt; inoremap &lt;m-[&gt; [ inoremap &lt;m-]&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8796 ] inoremap &lt;m-/&gt; " inoremap &lt;m--&gt; { inoremap &lt;m-=&gt; }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8797 inoremap &lt;m-,&gt; &lt; inoremap &lt;m-.&gt; &gt; inoremap &lt;m-'&gt; '
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8798
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8799 "######################################## " End Of File
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8800 "########################################
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8801
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8802 If you have any other suggestions, drop a note...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8803
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8804 </pre></tip> </html> <Tip category="KVim"> <html><center>text
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8805 formatting (lining up ='s,('s etc))</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8806 HREF="http://vim.sf.net/tip_view.php?tip_id=319">http://vim.sf.net/tip_view.php?tip_id=319</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8807
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8808 some time onw would like to reformat text like a=1; foo=2; longstring=1; c=2
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8809
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8810 to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8811
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8812 a =1; foo =2; longstring =1; c =2;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8813
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8814 Note I am not sure wether the code above is displayed properly in your browsers
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8815 what is basically shows is all the ='s are lined up in a single column
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8816 and this is how we achive it 0f=20i&lt;space&gt;&lt;esc&gt;020lvf=hx and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8817 this is what it does 0 goes to first column f=
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8818 finds next occurance of = on current line 20i&lt;space&gt;&lt;esc&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8819 inserts 20 spaces before = 0 goesback to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8820 first column 20l forward 20 column vf=hx
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8821 deletes everything up to the = sign
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8822
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8823 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8824 <html><center>Borland pageup/down behavier</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8825 HREF="http://vim.sf.net/tip_view.php?tip_id=320">http://vim.sf.net/tip_view.php?tip_id=320</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8826
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8827 borlandbehavier = the cursor keeps the same xy position during pageup/down
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8828
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8829 Im new to VIM scripting, im sure it can be done smarter? I read vimtip #105
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8830 and it gave me a clue of how BorlandPageUp/Down could be done.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8831
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8832 " i could'nt find any get_number_of_visible_lines function, so i made my own.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8833 function GetNumberOfVisibleLines()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8834 let cur_line = line(".") let cur_col = virtcol(".") normal H let
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8835 top_line = line(".") normal L let bot_line = line(".")
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8836
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8837 execute "normal " . cur_line . "G" execute "normal " . cur_col . "|"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8838 return bot_line - top_line
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8839 endfunc
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8840
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8841 " noremap &lt;PageUp&gt; 39&lt;C-U&gt;:set scroll=0&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8842 function! MyPageUp()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8843 let visible_lines = GetNumberOfVisibleLines() execute "normal "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8844 . visible_lines . "\&lt;C-U&gt;:set scroll=0\r"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8845 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8846
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8847 " noremap &lt;PageDown&gt; 39&lt;C-D&gt;:set scroll=0&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8848 function! MyPageDown()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8849 let visible_lines = GetNumberOfVisibleLines() execute "normal "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8850 . visible_lines . "\&lt;C-D&gt;:set scroll=0\r"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8851 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8852
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8853 " BorlandPascal pageup/down behavier! " todo: when hitting top/bottom of file,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8854 then restore Y to lastY noremap &lt;PageUp&gt; :call MyPageUp()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8855 noremap &lt;PageDown&gt; :call MyPageDown()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8856
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8857 </pre></tip> </html> <Tip category="KVim"> <html><center>Centura
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8858 swap with upper/lower line behavier</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8859 HREF="http://vim.sf.net/tip_view.php?tip_id=321">http://vim.sf.net/tip_view.php?tip_id=321</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8860
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8861 I was once forced to use a windows development suite called "Centura".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8862 The only good thing i remember was its swap current_line with upper/lower line.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8863
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8864 function! MySwapUp()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8865 let cur_col = virtcol(".") normal ddkkp execute "normal " . cur_col . "|"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8866 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8867
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8868 function! MySwapDown()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8869 let cur_col = virtcol(".") normal ddp execute "normal " . cur_col . "|"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8870 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8871
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8872 " swap lines and preserve cursorx " todo: in visual mode, perform swap with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8873 line before/after the selection noremap &lt;S-Up&gt; :call MySwapUp()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8874 noremap &lt;S-Down&gt; :call MySwapDown()&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8875
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8876 </pre></tip> </html> <Tip category="KVim"> <html><center>text
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8877 template with placeholders</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8878 HREF="http://vim.sf.net/tip_view.php?tip_id=322">http://vim.sf.net/tip_view.php?tip_id=322</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8879
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8880 Many scripts/ftplugin provide text or code templates. Sadly none of the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8881 marks the places where you are supposed to "fill in the form". My own code
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8882 templates for C/C++ insert a triple percent (%%%) where you are supposed to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8883 enter something. I mapped ;; to find the next %%% and change them. All the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8884 template mappings are insert-mode only, while the "skip to next placeholder"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8885 is both insert and normal mode enabled.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8886
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8887 A complete for-loop template for C++ looks like:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8888
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8889 :imap &lt;buffer&gt; ;fo &lt;C-O&gt;mzfor( %%%; %%%; %%%)&lt;CR&gt;{ //
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8890 %%%&lt;CR&gt;%%%&lt;CR&gt;}&lt;CR&gt;&lt;C-O&gt;'z;;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8891
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8892 The command to go to the next placeholder is this:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8893
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8894 :imap &lt;buffer&gt; ;; &lt;C-O&gt;/%%%&lt;CR&gt;&lt;C-O&gt;c3l :nmap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8895 &lt;buffer&gt; ;; /%%%&lt;CR&gt;c3l
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8896
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8897 Every time I need a for-loop ;fo produces this ( _ is the cursor position)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8898 : for( _; %%% ; %%%) { // %%%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8899 %%%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8900 }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8901
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8902 Now I enter starting value (i=0): for( i=0_; %%% ; %%%) { // %%%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8903 %%%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8904 }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8905
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8906 and go to the condition using ;; for( i=0; _ ; %%%) { // %%%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8907 %%%
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8908 }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8909
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8910 and so forth.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8911
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8912 The choice of %%% proved to be almost universal, it even works in MATLAB or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8913 LaTeX where % is the comment character.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8914
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8915 Even if you forget to replace one %%%, that's not a problem as the compiler
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8916 flags is as a syntax error (except MATLAB and LaTeX, of course).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8917
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8918 It made my life easier, maybe it works for you.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8919
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8920 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8921 <html><center>using folders with latex</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8922 HREF="http://vim.sf.net/tip_view.php?tip_id=323">http://vim.sf.net/tip_view.php?tip_id=323</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8923
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8924 set foldmarker=\\begin,\\end set foldmethod=marker
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8925
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8926 this is useful with big latex document
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8927
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8928 </pre></tip> </html> <Tip category="KVim"> <html><center>Search
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8929 and replace in files named NAME</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8930 HREF="http://vim.sf.net/tip_view.php?tip_id=324">http://vim.sf.net/tip_view.php?tip_id=324</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8931
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8932 I'm not sure if there is a simple way to do this from within Vim, but,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8933 I wrote this simple script that does it. It basically searches for files
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8934 named NAMED (whatever name pass) for a given string and replaces that with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8935 a given string: find_replace.sh NAMED "string_to_find" "string_to_replace"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8936
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8937 This is all done from the command line without opening Vim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8938
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8939 Of course one could do things like:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8940 :let n = 1 :while n &lt;= argc() " loop over all
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8941 files in arglist : exe "argument " . n : " start at
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8942 the last char in the file and wrap for the : " first
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8943 search to find match at start of file : normal G$ :
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8944 let flags = "w" : while search("foo", flags) &gt; 0 :
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8945 s/foo/bar/g : let flags = "W" : endwhile : update
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8946 " write the file if modified : let n = n + 1 :endwhile
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8947
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8948 As suggested in the Vim help files :-) but, I wanted to go and find only
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8949 these files... here is the script:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8950 1 #!/bin/sh 2 # Luis Mondesi &lt; lemsx1@hotmail.com &gt; 3 #
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8951 DESCRIPTION: 4 # it uses vim to replace a given string for 5 #
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8952 another in a number of files 6 # 7 # usage: 8 # find_replace.sh file
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8953 "string" "replace" 9 #
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8954 10 if [ $1 -a $2 -a $3 ]; then 11 for i in `find . -name "$1"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8955 -type f | xargs grep -l $2`; do 12 # how do search and replace
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8956 13 # the screen might flicker... vim opening and closing...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8957 14 vim -c ":%s/$2/$3/g" -c ":wq" $i 15 done 16 exit 0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8958 17 fi 18 # I should never reach here 19 echo -e "USAGE: find_replace.sh
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8959 file 'string' 'replace' \n\n" 20 exit 1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8960
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8961 </pre></tip> </html> <Tip category="KVim"> <html><center>Errorformat
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8962 for java/ant/junit/cygwin/bash</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8963 HREF="http://vim.sf.net/tip_view.php?tip_id=325">http://vim.sf.net/tip_view.php?tip_id=325</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8964
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8965 If you program in Java and use Jakarta ant for builds *and* if you have the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8966 bash shell, this tip will make your development experience a little smoother.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8967
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8968 This tip will result in a working compile/edit/debug system (in Win32 vim/gvim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8969 and in Cygwin vim) that takes you to the exact lines where the build fails,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8970 whether the failure is a compilation error or a junit test failure. If you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8971 use bash on a linux box, you shouldn't have to change very much to get
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8972 everything to work.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8973
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8974 There are 6 sections: 1. set up your build script 2. set up makeprg 3. set
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8975 up shell options 4. set up path formatting options 5. set up your errorformat
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8976 6. set up key mappings
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8977
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8978 Set up build script ------------------- Add the following script to your path
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8979 (I use /usr/local/bin/):
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8980
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8981 mymake: #!/bin/bash cd /work/ ant -emacs $* 2&gt;&1 | tr '\\' / | tr ^M '
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8982 ' | sed -u -n -f /usr/local/bin/testerrors.sed | tee /tmp/errors
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8983
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8984 Comment: sed -u is non-standard, use the code at: <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8985 HREF="http://mail.gnu.org/pipermail/bug-gnu-utils/2002-May/000192.html to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8986 get">http://mail.gnu.org/pipermail/bug-gnu-utils/2002-May/000192.html to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8987 get</A><BR> the -u option for sed (this avoids waiting for the build output
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8988 to get to the screen)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8989
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8990 testerrors.sed: # This assumes that all your junit test cases are in a com.*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8991 package /^Running com\./ {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8992 # duplicate the line s!\(.*\)!\1\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8993 \1!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8994 P
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8995
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8996 # turn the test package into a directory path for %D errorformat
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8997 s!.*\(com\..*\)\.[A-Za-z_][A-Za-z0-9_]*!\1! s!\.!/!g s!.*!Entering:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8998 /work/src/&!
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8999
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9000 # print the line and go on p n
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9001 }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9002
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9003 # just pass any unmatched lines through p
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9004
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9005 Set up makeprg -------------- Add the following lines to your vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9006 autocmd BufNewFile,BufRead /work/*.java set makeprg=mymake autocmd
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9007 BufNewFile,BufRead ?:/work/*.java set makeprg=mymake
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9008
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9009 Set up shell options -------------------- Add the following lines to your
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9010 vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9011 " in order to have bash as the shell for win32 vi.exe and gvim.exe,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9012 you have " to set these options, and also build vimrun.exe in the cygwin
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9013 environment " so that the system() call is executed via bash, not cmd.exe
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9014 -- the command " to build vimrun.exe is "make -f Make_cyg.mak vimrun.exe"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9015 set shell=bash.exe set shellcmdflag=-c set shellslash
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9016
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9017 Also to use this environment in Win32 gvim, you must recompile vimrun so
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9018 that gvim invokes the shell via bash, not via cmd.exe.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9019
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9020 Set up path formatting options ------------------------------ Add the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9021 following lines to your vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9022 " allows DOS file names from UNIX (Cygwin) vim set isfname+=\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9023
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9024 Set up your errorformat ----------------------- Add the following lines to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9025 your vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9026 " the "\%DEntering:\ %f," rule relies on a sed script which generates "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9027 "Entering: " messages for each test class run (the directory name is "
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9028 generated from the test class package and a hard-coded src root)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9029
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9030 " the "%\\C" at the start of the exception matching line tells to match
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9031 " case-exact (the exception mathching lines rely on the %D rule that sets
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9032 " up the correct directory from the package structure)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9033
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9034 " ant/junit/javac errorformat set errorformat=
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9035 \%-G%.%#build.xml:%.%#, \%-G%.%#warning:\ %.%#, \%-G%\\C%.%#EXPECTED%.%#,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9036 \%f:%l:\ %#%m, \C:%f:%l:\ %m, \%DEntering:\ %f\ %\\=, \%ECaused\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9037 by:%[%^:]%#:%\\=\ %\\=%m, \%ERoot\ cause:%[%^:]%#:%\\=\ %\\=%m,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9038 \%Ecom.%[%^:]%#:%\\=\ %\\=%m, \%Eorg.%[%^:]%#:%\\=\ %\\=%m,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9039 \%Ejava.%[%^:]%#:%\\=\ %\\=%m, \%Ejunit.%[%^:]%#:%\\=\ %\\=%m,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9040 \%-Z%\\C\ at\ com.mypkg.%.%#.test%[A-Z]%.%#(%f:%l)\ %\\=,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9041 \%-Z%\\C\ at\ com.mypkg.%.%#.setUp(%f:%l)\ %\\=, \%-Z%\\C\ at\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9042 com.mypkg.%.%#.tearDown(%f:%l)\ %\\=, \%-Z%^\ %#%$, \%-C%.%#, \%-G%.%#
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9043
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9044 NOTE: Make sure that the character before "at" is an actual Tab character
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9045 in the three long -Z lines above
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9046
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9047 Here is an annotated version:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9048 set errorformat=
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9049 " don't treat the build.xml diagnostic as an error
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9050 \%-G%.%#build.xml:%.%#,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9051
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9052 " don't treat warning lines as errors \%-G%.%#warning:\ %.%#,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9053
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9054 " don't treat lines containing "EXPECTED" as errors
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9055 \%-G%\\C%.%#EXPECTED%.%#,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9056
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9057 " look for this standard error format \%f:%l:\ %#%m,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9058
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9059 " look for this standard error format (with C: on front) \C:%f:%l:\ %m,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9060
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9061 " look for special sed-generated "Entering" lines while running tests
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9062 \%DEntering:\ %f\ %\\=,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9063
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9064 " look for exceptions that were thrown in the tests, use the exception
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9065 " description as the error message (don't know how to also include the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9066 " exception name in the error message) \%ECaused\ by:%[%^:]%#:%\\=\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9067 %\\=%m, \%ERoot\ cause:%[%^:]%#:%\\=\ %\\=%m, \%Ecom.%[%^:]%#:%\\=\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9068 %\\=%m, \%Eorg.%[%^:]%#:%\\=\ %\\=%m, \%Ejava.%[%^:]%#:%\\=\ %\\=%m,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9069 \%Ejunit.%[%^:]%#:%\\=\ %\\=%m,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9070
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9071 " using the "Entering" directory and the filename/line number provided
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9072 " in the exception trace, go to the test method where the exception
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9073 " was thrown \%-Z%\\C\ at\ com.mypkg.%.%#.test%[A-Z]%.%#(%f:%l)\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9074 %\\=, \%-Z%\\C\ at\ com.mypkg.%.%#.setUp(%f:%l)\ %\\=, \%-Z%\\C\ at\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9075 com.mypkg.%.%#.tearDown(%f:%l)\ %\\=,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9076
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9077 " empty lines terminate searching for further exception lines \%-Z%^\
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9078 %#%$,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9079
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9080 " any line can intervene between the start of an exception printout
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9081 " and the line where it ends (last in list so that it is matched if
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9082 " none of the other exception trace patterns match) \%-C%.%#,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9083
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9084 " all other lines are not errors \%-G%.%#
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9085
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9086 Set up key mappings ------------------- Add the following lines to your vimrc:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9087 nmap &lt;F10&gt; :clist&lt;CR&gt; nmap &lt;F11&gt; :cprev&lt;CR&gt; nmap
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9088 &lt;F12&gt; :cnext&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9089
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9090 This allows for quick error navigation.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9091
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9092 NOTES ----- Vim treats the "Entering: /work/src/..." messages in a weird way.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9093 If there are any actual errors, then these error lines are ignored by the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9094 :cnext and :cprev commands, but if there are no real errors, then :cnext and
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9095 :cprev roll through these "Entering:" messages as if they were errors, but
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9096 since they don't include any line numbers, the cursor position is never moved.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9097
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9098 I thought that this was strange, but even stranger, it is programmed directly
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9099 into the vim error handling code to function exactly this way. There were
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9100 no comments, and nobody responded on the vim mailing list, so I just decided
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9101 to live with it.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9102
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9103 The upshot of it all is that if you see an error like "Entering:", chances
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9104 are that your build succeeded and all the tests ran without a problem.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9105
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9106 Hope this helps...
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9107
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9108 Mail me with bugs at jdsumsion at earthlink.net.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9109
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9110 </pre></tip> </html> <Tip category="KVim"> <html><center>Help
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9111 for VIM Help (VIM QuickRef)</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9112 HREF="http://vim.sf.net/tip_view.php?tip_id=326">http://vim.sf.net/tip_view.php?tip_id=326</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9113
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9114 Type :help quickref or :h quic
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9115
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9116 And get a VIM Command Quick Reference Page brilliant for beginners &
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9117 oldtimers alike
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9118
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9119 type :h help to learn how to use help
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9120
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9121 Other Help Tips
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9122
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9123 # help for help :h visual&lt;C-D&gt;&lt;tab&gt; : obtain list of all
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9124 visual help topics
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9125 : Then use tab to step thru them
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9126 :h ctrl&lt;C-D&gt; : list help of all control keys :h :r
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9127 : help for :ex command :h CTRL-R : normal mode :h \r
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9128 : what's \r in a regexp :h i_CTRL-R : help for say &lt;C-R&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9129 in insert mode :h c_CTRL-R : help for say &lt;C-R&gt; in command
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9130 mode :h v_CTRL-V : visual mode :h tutor : VIM Tutor
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9131
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9132 These are also listed in my Best Of VIM Tips vimtip #305
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9133
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9134 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9135 <html><center>key mappings</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9136 HREF="http://vim.sf.net/tip_view.php?tip_id=327">http://vim.sf.net/tip_view.php?tip_id=327</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9137
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9138 I use my left thumb for the alt key and right for the space. Using this
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9139 combo, you can get some useful key maps for which you don't have to move
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9140 your hands. I find I have to turn my hand a little to press the left ctrl key.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9141
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9142 These are some maps i use for C programming.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9143
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9144 map ' ` map &lt;C-f&gt; :w&lt;C-m&gt;:!make&lt;C-m&gt; map &lt;M-]&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9145 &lt;C-]&gt; Tags map &lt;M-[&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9146 &lt;C-t&gt; Tags map &lt;M-u&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9147 :!ctags -R *&lt;C-m&gt; Build
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9148 Tags map &lt;M-c&gt; I/*&lt;Esc&gt;A*/&lt;Esc&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9149 Comment current line map &lt;M-d&gt; ^xx$xx
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9150 Delete comment for a single line map &lt;M-l&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9151 [{zf% Fold upto the enclosing brace
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9152 level map &lt;M-o&gt; zo open fold
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9153 map &lt;M-i&gt; zc close fold map
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9154 &lt;M-.&gt; :cn&lt;C-m&gt; Go
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9155 to next error in list map &lt;M-,&gt; :cp&lt;C-m&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9156 previous error in list
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9157
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9158 imap &lt;Tab&gt; &lt;C-p&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9159 Complete word inoremap &lt;S-Tab&gt; &lt;Tab&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9160 Tab inoremap { &lt;CR&gt;{&lt;CR&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9161 Brace and line inoremap } &lt;CR&gt;}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9162 brace and line. saves one enter stroke
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9163
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9164 imap &lt;M-j&gt; &lt;Esc&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9165 Escape. Don't want to move my hand to esc key. imap &lt;M-k&gt; &lt;C-y&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9166 Copy line from above. imap &lt;M-q&gt; /* */&lt;Esc&gt;hhi
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9167 Comment selected lines
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9168
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9169 noremap &lt;M-r&gt; ddko{&lt;C-m&gt;}&lt;Esc&gt;kpko Convert a
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9170 simple statement to a compound statement. And place cursor above prev line.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9171 noremap &lt;M-k&gt; ddko{&lt;C-m&gt;}&lt;Esc&gt;kpo Same as
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9172 above but place cursor below old line.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9173
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9174 vnoremap &lt;M-j&gt; &lt;Esc&gt; vnoremap &lt;M-c&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9175 di/*&lt;C-m&gt;/&lt;C-m&gt;&lt;Esc&gt;kkp Commented selected text
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9176
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9177 nmap &lt;M-n&gt; :noh&lt;CR&gt; No hilight
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9178
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9179 Bye,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9180 Nithin.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9181
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9182 </pre></tip> </html> <Tip category="KVim"> <html><center>Vim
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9183 in Microsoft Visual Foxpro</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9184 HREF="http://vim.sf.net/tip_view.php?tip_id=328">http://vim.sf.net/tip_view.php?tip_id=328</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9185
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9186 You can tell MS VFP to use an external editor for editing project files.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9187 To tell MS VFP to use Vim:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9188
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9189 start regedit locate [HKEY_CURRENT_USER
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9190 \Software
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9191 \Microsoft
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9192 \VisualFoxPro
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9193 \5.0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9194 \Options]
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9195
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9196 and create a new item TEDIT with string content "/N
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9197 C:\Progra~1\vim\vim61\gvim.exe" (or whatever your path to Vim happens to be.)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9198
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9199 This will not replace the internal VFP editor for such things as modifying the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9200 "click method" for a button (unfortunately), but when you modify a program,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9201 VFP will fire up gvim.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9202
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9203 Start MS VFP, start Help and look for TEDIT. ;-)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9204
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9205 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9206 <html><center>A map for swapping words</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9207 HREF="http://vim.sf.net/tip_view.php?tip_id=329">http://vim.sf.net/tip_view.php?tip_id=329</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9208
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9209 Put the following map into your &lt;.vimrc&gt;:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9210
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9211 nmap &lt;silent&gt; gw
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9212 "_yiw:s/\(\%#\w\+\)\(\W\+\)\(\w\+\)/\3\2\1/&lt;cr&gt;&lt;c-o&gt;&lt;c-l&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9213
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9214 Then when you put the cursor on or in a word, press "gw", and the word will
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9215 be swapped with the next word. The words may even be separated by punctuation
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9216 (such as "abc = def").
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9217
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9218 While we're talking swapping, here's a map for swapping characters:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9219
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9220 nmap &lt;silent&gt; gc xph
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9221
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9222 This hint was formed in a collaboration between Chip Campbell - Arun Easi -
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9223 Benji Fisher
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9224
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9225 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9226 <html><center>how to stop auto indenting</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9227 HREF="http://vim.sf.net/tip_view.php?tip_id=330">http://vim.sf.net/tip_view.php?tip_id=330</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9228
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9229 Since VIM 6.0 the indent has been improved so much. But sometimes when
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9230 we are pasting formated text (source code or HTML etc) into a buffer, VIM
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9231 indents again so that lines will be padded with too much spaces.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9232
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9233 Setting nocindent, noautoindent, nosmartindent still cannot stop this. All you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9234 need to do is "set paste", then paste your stuff, and then "set nopaste" again.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9235
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9236 Ref: indentexpr
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9237
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9238 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9239 <html><center>modline magic...</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9240 HREF="http://vim.sf.net/tip_view.php?tip_id=331">http://vim.sf.net/tip_view.php?tip_id=331</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9241
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9242 One of the things about vim that are both quite simple yet very
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9243 useful is that you can store by-file settings... that is each file can
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9244 contain settings specific to it. this thing is called a modline (:help
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9245 modline). though this is limited to only the 'set' command arguments, you
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9246 can do allot of local to file things like the indent type, folding method
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9247 and so on.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9248
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9249 the syntax is as follows:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9250
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9251 // vim:set ts=4 sw=4 nowrap:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9252
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9253 or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9254
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9255 /* vim:noai:ts=2:sw=4: */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9256
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9257 The modlines can be contained in comments so as to not interfere with
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9258 the file syntax (shown here for C/C++). these lines are read by vim when
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9259 it loads the file, and they can either be in the first or last 5 lines
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9260 (by default).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9261
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9262 refer to ':help modline'
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9263
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9264 //and a happy 20th birthday to the good old smiley!! :-)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9265
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9266 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9267 <html><center>make footnotes in vim</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9268 HREF="http://vim.sf.net/tip_view.php?tip_id=332">http://vim.sf.net/tip_view.php?tip_id=332</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9269
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9270 I found at <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9271 HREF="http://groups.google.com/groups?q=vim+changing+shell+to+zsh&hl=en&lr=&ie=UTF-8&selm=S_Rh9.716%24a5.124150%40news.uchicago.edu&rnum=4">http://groups.google.com/groups?q=vim+changing+shell+to+zsh&hl=en&lr=&ie=UTF-8&selm=S_Rh9.716%24a5.124150%40news.uchicago.edu&rnum=4</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9272 a macro to insert footnotes in vim, but it doesn't work as of vim6.0. so i
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9273 wrote my own; this macro requires two differents shortcuts, one for entering
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9274 the first footnote, the other one for all subsequent footnotes.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9275
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9276 when you hit "K0" (first footnote) or "KK" (all other footnotes) in normal
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9277 mode, your cursor is positionned at the end of the document, in the footnote &
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9278 in insert mode. The "a" bookmark is set to the place where you entered the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9279 footnote in the text. so a "`a" will bring you back to the location of the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9280 footnote in the text.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9281
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9282 " for now requires entering K0 for the first footnote and then KK
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9283 nmap K0 i[0]&lt;esc&gt;maG$i&lt;end&gt;&lt;enter&gt;[0] nmap KK
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9284 maG$?\[[0-9]*\]&lt;enter&gt;yt]G$i&lt;end&gt;&lt;enter&gt;&lt;esc&gt;p&lt;C-a&gt;i&lt;end&gt;]&lt;esc&gt;`aP&lt;C-a&gt;&lt;right&gt;i]&lt;esc&gt;maG$i&lt;end&gt;&lt;end&gt;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9285
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9286 </pre></tip> </html> <Tip category="KVim">
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9287 <html><center>Syntax-based folding for c/c++/java</center> <pre> <A
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9288 HREF="http://vim.sf.net/tip_view.php?tip_id=333">http://vim.sf.net/tip_view.php?tip_id=333</A><BR>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9289
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9290 Here's a function to toggle the use of syntax-based folding for a c/c++/java
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9291 file. It also handles folding markers.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9292
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9293 function! OutlineToggle()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9294 if (! exists ("b:outline_mode"))
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9295 let b:outline_mode = 0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9296 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9297
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9298 if (b:outline_mode == 0)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9299 syn region myFold start="{" end="}" transparent fold syn sync
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9300 fromstart set foldmethod=syntax
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9301
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9302 silent! exec "%s/{{{/&lt;&lt;&lt;/" silent! exec "%s/}}}/&gt;&gt;&gt;/"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9303
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9304 let b:outline_mode = 1
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9305 else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9306 set foldmethod=marker
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9307
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9308 silent! exec "%s/&lt;&lt;&lt;/{{{/" silent! exec "%s/&gt;&gt;&gt;/}}}/"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9309
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9310 let b:outline_mode = 0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9311 endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9312 endfunction
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9313
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9314 </html></tip>