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.
11 <div class=
"plugin_uparrow">
12 <a href=
"#" title=
"Back to top">
13 <img src=
"lib/plugins/uparrow/images/tango-small.png" alt=
"Back to top"/>
18 <!-- SECTION "Vim" [1-159] -->
19 <h2><a name=
"how_to_change_vim_configuration" id=
"how_to_change_vim_configuration">How to change vim configuration
</a></h2>
24 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:
26 <pre class=
"code bash"><span class=
"co0"># append to ~/.vimrc
</span>
27 $
<span class=
"kw3">echo
</span> <span class=
"st_h">'set number'
</span> <span class=
"sy0">>></span> ~
<span class=
"sy0">/
</span>.vimrc
</pre>
28 <div class=
"plugin_uparrow">
29 <a href=
"#" title=
"Back to top">
30 <img src=
"lib/plugins/uparrow/images/tango-small.png" alt=
"Back to top"/>
35 <!-- SECTION "How to change vim configuration" [160-505] -->
36 <h2><a name=
"useful_vim_configurations" id=
"useful_vim_configurations">Useful Vim Configurations
</a></h2>
41 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:
43 <pre class=
"code bash"><span class=
"co0"># append to ~/.vimrc
</span>
44 $
<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>
47 This loads my .vimrc file everytime you open Vim.
51 These are the extra configurations I use:
54 <dt><a href=
"/~kssilveira/site/doku.php?do=export_code&id=vim&codeblock=2" title=
"Download Snippet" class=
"mediafile mf_vimrc">.vimrc
</a></dt>
55 <dd><pre class=
"code file vim"><span class=
"co1">" show line numbers
</span>
57 <span class=
"co1">" incremental search
</span>
59 <span class=
"co1">" auto indentation
</span>
61 <span class=
"co1">" tab size
</span>
62 set tabstop=
<span class=
"nu0">2</span>
63 <span class=
"co1">" indentation size (used on auto indentation)
</span>
64 set shiftwidth=
<span class=
"nu0">2</span>
65 <span class=
"co1">" smart indentation (indent beginning of blocks (e.g. '{') and unnindent ending of blocks (e.g. '}'))
</span>
67 <span class=
"co1">" save with Ctrl+S
</span>
68 <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>
69 <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>
70 <span class=
"co1">" call make with F9
</span>
71 <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>
72 <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>
73 <span class=
"co1">" auto save files
</span>
76 <span class=
"co1">" abreviations
</span>
79 <span class=
"co1">" reload file automatically when it changes
</span>
81 <span class=
"co1">" call make -B with F8
</span>
82 <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>
83 <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>
87 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=bash" class=
"wikilink2" title=
"bash" rel=
"nofollow">Bash
</a>).
89 <div class=
"plugin_uparrow">
90 <a href=
"#" title=
"Back to top">
91 <img src=
"lib/plugins/uparrow/images/tango-small.png" alt=
"Back to top"/>
96 <!-- SECTION "Useful Vim Configurations" [506-1665] -->
97 <h2><a name=
"commands" id=
"commands">Commands
</a></h2>
102 <a href=
"/~kssilveira/site/doku.php?id=vim:commands" class=
"wikilink1" title=
"vim:commands">Vim Commands
</a>
104 <div class=
"plugin_uparrow">
105 <a href=
"#" title=
"Back to top">
106 <img src=
"lib/plugins/uparrow/images/tango-small.png" alt=
"Back to top"/>
111 <!-- SECTION "Commands" [1666-1719] -->
112 <h2><a name=
"edit-compile-execute_cycle" id=
"edit-compile-execute_cycle">Edit-Compile-Execute Cycle
</a></h2>
114 <table class=
"inline">
116 <th class=
"col0 leftalign" colspan=
"2"> Session
</th>
119 <td class=
"col0"> :mks(ession)
</td><td class=
"col1"> create a session file
</td>
122 <td class=
"col0"> vim -S
</td><td class=
"col1"> load a session file
</td>
125 <th class=
"col0 leftalign" colspan=
"2"> Make
</th>
128 <td class=
"col0"> :mak(e)
</td><td class=
"col1"> run make
</td>
131 <td class=
"col0"> :cl(ist)
</td><td class=
"col1"> show make output
</td>
134 <td class=
"col0"> :cope(n)
</td><td class=
"col1"> open a window with make output
</td>
137 <td class=
"col0"> :cn(ext)
</td><td class=
"col1"> go to next error
</td>
140 <td class=
"col0"> :cp(revious)
</td><td class=
"col1"> go to previous error
</td>
143 <td class=
"col0"> :cc
</td><td class=
"col1"> go to current error
</td>
146 <td class=
"col0"> :ccl(ose)
</td><td class=
"col1"> close the window with make output
</td>
149 <th class=
"col0 leftalign" colspan=
"2"> Motion
</th>
152 <td class=
"col0"> Ctrl+O
</td><td class=
"col1"> go to previous edition
</td>
155 <td class=
"col0"> Ctrl+I
</td><td class=
"col1"> go to next edition
</td>
158 <div class=
"tags"><span>
159 <a href=
"/~kssilveira/site/doku.php?id=tag:programming&do=showtag&tag=tag%3Aprogramming" class=
"wikilink1" title=
"tag:programming" rel=
"tag">programming
</a>
161 <div class=
"plugin_uparrow">
162 <a href=
"#" title=
"Back to top">
163 <img src=
"lib/plugins/uparrow/images/tango-small.png" alt=
"Back to top"/>
168 <!-- SECTION "Edit-Compile-Execute Cycle" [1720-] -->