4 <h1><a name=
"vim" id=
"vim">Vim
</a></h1>
9 <a href=
"http://en.wikipedia.org/wiki/Vim" class=
"interwiki iw_wp" title=
"http://en.wikipedia.org/wiki/Vim">Vim
</a> is an wonderful editor. You have to spent some time to get used to this, but since then you will gain much more in produtivity.
13 See also
<a href=
"http://www.inf.ufrgs.br/~kssilveira/vim_quick_reference.html" class=
"urlextern" title=
"http://www.inf.ufrgs.br/~kssilveira/vim_quick_reference.html" rel=
"nofollow">Vim Quick Reference
</a> <br/>
16 <div class=
"plugin_uparrow">
17 <a href=
"#" title=
"Back to top">
18 <img src=
"lib/plugins/uparrow/images/tango-small.png" alt=
"Back to top"/>
23 <!-- SECTION "Vim" [1-258] -->
24 <h2><a name=
"how_to_change_vim_configuration" id=
"how_to_change_vim_configuration">How to change vim configuration
</a></h2>
29 The file ~/.vimrc is read and executed every time you open vim. So if you want that a configuration change (like set number) to be true the next time you open vim, you must append it to the ~/.vimrc. Here is an example code:
31 <pre class=
"code bash"><span class=
"co0"># append to ~/.vimrc
</span>
32 $
<span class=
"kw3">echo
</span> <span class=
"st_h">'set number'
</span> <span class=
"sy0">>></span> ~
<span class=
"sy0">/
</span>.vimrc
</pre>
33 <div class=
"plugin_uparrow">
34 <a href=
"#" title=
"Back to top">
35 <img src=
"lib/plugins/uparrow/images/tango-small.png" alt=
"Back to top"/>
40 <!-- SECTION "How to change vim configuration" [259-604] -->
41 <h2><a name=
"useful_vim_configurations" id=
"useful_vim_configurations">Useful Vim Configurations
</a></h2>
46 Download my
<a href=
"http://www.inf.ufrgs.br/~kssilveira/.vimrc" class=
"urlextern" title=
"http://www.inf.ufrgs.br/~kssilveira/.vimrc" rel=
"nofollow">.vimrc
</a> file and do the following:
48 <pre class=
"code bash"><span class=
"co0"># append to ~/.vimrc
</span>
49 $
<span class=
"kw3">echo
</span> <span class=
"st_h">':source path/to/my/vimrc/file/on/your/pc'
</span> <span class=
"sy0">>></span> ~
<span class=
"sy0">/
</span>.vimrc
</pre>
52 This loads my .vimrc file everytime you open Vim.
56 These are the extra configurations I use:
59 <dt><a href=
"/~kssilveira/site/doku.php?do=export_code&id=vim:vim&codeblock=2" title=
"Download Snippet" class=
"mediafile mf_vimrc">.vimrc
</a></dt>
60 <dd><pre class=
"code file vim"><span class=
"co1">" show line numbers
</span>
62 <span class=
"co1">" incremental search
</span>
64 <span class=
"co1">" auto indentation
</span>
66 <span class=
"co1">" tab size
</span>
67 set tabstop=
<span class=
"nu0">2</span>
68 <span class=
"co1">" indentation size (used on auto indentation)
</span>
69 set shiftwidth=
<span class=
"nu0">2</span>
70 <span class=
"co1">" smart indentation (indent beginning of blocks (e.g. '{') and unnindent ending of blocks (e.g. '}'))
</span>
72 <span class=
"co1">" save with Ctrl+S
</span>
73 <span class=
"kw3">map
</span><span class=
"sy0">!
</span> <span class=
"sy0"><</span>C
<span class=
"sy0">-
</span>s
<span class=
"sy0">></span> <span class=
"sy0"><</span>Esc
<span class=
"sy0">>:
</span>w
<span class=
"sy0"><</span>CR
<span class=
"sy0">></span>
74 <span class=
"kw3">map
</span> <span class=
"sy0"><</span>C
<span class=
"sy0">-
</span>s
<span class=
"sy0">></span> <span class=
"sy0"><</span>Esc
<span class=
"sy0">>:
</span>w
<span class=
"sy0"><</span>CR
<span class=
"sy0">></span>
75 <span class=
"co1">" call make with F9
</span>
76 <span class=
"kw3">map
</span><span class=
"sy0">!
</span> <span class=
"sy0"><</span>F9
<span class=
"sy0">></span> <span class=
"sy0"><</span>Esc
<span class=
"sy0">>:
</span>make
<span class=
"sy0"><</span>CR
<span class=
"sy0">><</span>CR
<span class=
"sy0">></span>
77 <span class=
"kw3">map
</span> <span class=
"sy0"><</span>F9
<span class=
"sy0">></span> <span class=
"sy0"><</span>Esc
<span class=
"sy0">>:
</span>make
<span class=
"sy0"><</span>CR
<span class=
"sy0">><</span>CR
<span class=
"sy0">></span>
78 <span class=
"co1">" auto save files
</span>
81 <span class=
"co1">" abreviations
</span>
84 <span class=
"co1">" reload file automatically when it changes
</span>
86 <span class=
"co1">" call make -B with F8
</span>
87 <span class=
"kw3">map
</span><span class=
"sy0">!
</span> <span class=
"sy0"><</span>F8
<span class=
"sy0">></span> <span class=
"sy0"><</span>Esc
<span class=
"sy0">>:
</span>make
<span class=
"sy0">-
</span>B
<span class=
"sy0"><</span>CR
<span class=
"sy0">><</span>CR
<span class=
"sy0">></span>
88 <span class=
"kw3">map
</span> <span class=
"sy0"><</span>F8
<span class=
"sy0">></span> <span class=
"sy0"><</span>Esc
<span class=
"sy0">>:
</span>make
<span class=
"sy0">-
</span>B
<span class=
"sy0"><</span>CR
<span class=
"sy0">><</span>CR
<span class=
"sy0">></span></pre>
92 If the save with Ctrl+S isn
't working, maybe you have to change your bash configuration (see
<a href=
"/~kssilveira/site/doku.php?id=main:bash" class=
"wikilink1" title=
"main:bash">Bash
</a>).
94 <div class=
"plugin_uparrow">
95 <a href=
"#" title=
"Back to top">
96 <img src=
"lib/plugins/uparrow/images/tango-small.png" alt=
"Back to top"/>
101 <!-- SECTION "Useful Vim Configurations" [605-1769] -->
102 <h2><a name=
"commands" id=
"commands">Commands
</a></h2>
107 <a href=
"/~kssilveira/site/doku.php?id=vim:commands" class=
"wikilink1" title=
"vim:commands">Vim Commands
</a>
109 <div class=
"plugin_uparrow">
110 <a href=
"#" title=
"Back to top">
111 <img src=
"lib/plugins/uparrow/images/tango-small.png" alt=
"Back to top"/>
116 <!-- SECTION "Commands" [1770-1823] -->
117 <h2><a name=
"edit-compile-execute_cycle" id=
"edit-compile-execute_cycle">Edit-Compile-Execute Cycle
</a></h2>
119 <table class=
"inline">
121 <th class=
"col0 leftalign" colspan=
"2"> Session
</th>
124 <td class=
"col0"> :mks(ession)
</td><td class=
"col1"> create a session file
</td>
127 <td class=
"col0"> vim -S
</td><td class=
"col1"> load a session file
</td>
130 <th class=
"col0 leftalign" colspan=
"2"> Make
</th>
133 <td class=
"col0"> :mak(e)
</td><td class=
"col1"> run make
</td>
136 <td class=
"col0"> :cl(ist)
</td><td class=
"col1"> show make output
</td>
139 <td class=
"col0"> :cope(n)
</td><td class=
"col1"> open a window with make output
</td>
142 <td class=
"col0"> :cn(ext)
</td><td class=
"col1"> go to next error
</td>
145 <td class=
"col0"> :cp(revious)
</td><td class=
"col1"> go to previous error
</td>
148 <td class=
"col0"> :cc
</td><td class=
"col1"> go to current error
</td>
151 <td class=
"col0"> :ccl(ose)
</td><td class=
"col1"> close the window with make output
</td>
154 <th class=
"col0 leftalign" colspan=
"2"> Motion
</th>
157 <td class=
"col0"> Ctrl+O
</td><td class=
"col1"> go to previous edition
</td>
160 <td class=
"col0"> Ctrl+I
</td><td class=
"col1"> go to next edition
</td>
163 <div class=
"plugin_uparrow">
164 <a href=
"#" title=
"Back to top">
165 <img src=
"lib/plugins/uparrow/images/tango-small.png" alt=
"Back to top"/>
170 <!-- SECTION "Edit-Compile-Execute Cycle" [1824-2296] -->
171 <h2><a name=
"how_to_use_visual_bell_instead_of_beeping" id=
"how_to_use_visual_bell_instead_of_beeping">How to use visual bell instead of beeping
</a></h2>
173 <pre class=
"code vim"><span class=
"sy0">:
</span>set visualbell
</pre>
174 <div class=
"tags"><span>
175 <a href=
"/~kssilveira/site/doku.php?id=tag:programming&do=showtag&tag=tag%3Aprogramming" class=
"wikilink1" title=
"tag:programming" rel=
"tag">programming
</a>
177 <div class=
"plugin_uparrow">
178 <a href=
"#" title=
"Back to top">
179 <img src=
"lib/plugins/uparrow/images/tango-small.png" alt=
"Back to top"/>
184 <!-- SECTION "How to use visual bell instead of beeping" [2297-] -->