backup de julho
[h2N7SspZmY.git] / data / cache / 9 / 9e230bbb1ddf90708f520c153d8f2c51.xhtml
blob1505ad2da1a61bdddb98811b32b127d9d3c96574
4 <h1><a name="vim" id="vim">Vim</a></h1>
5 <div class="level1">
7 <p>
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.
10 </p>
12 <p>
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/>
15 </p>
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"/>
19 </a>
20 </div>
22 </div>
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>
25 <div class="level2">
27 <p>
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:
30 </p>
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">&gt;&gt;</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"/>
36 </a>
37 </div>
39 </div>
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>
42 <div class="level2">
44 <p>
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:
47 </p>
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">&gt;&gt;</span> ~<span class="sy0">/</span>.vimrc</pre>
51 <p>
52 This loads my .vimrc file everytime you open Vim.
53 </p>
55 <p>
56 These are the extra configurations I use:
57 </p>
58 <dl class="file">
59 <dt><a href="/~kssilveira/site/doku.php?do=export_code&amp;id=vim:vim&amp;codeblock=2" title="Download Snippet" class="mediafile mf_vimrc">.vimrc</a></dt>
60 <dd><pre class="code file vim"><span class="co1">&quot; show line numbers</span>
61 set number
62 <span class="co1">&quot; incremental search</span>
63 set incsearch
64 <span class="co1">&quot; auto indentation</span>
65 set autoindent
66 <span class="co1">&quot; tab size</span>
67 set tabstop=<span class="nu0">2</span>
68 <span class="co1">&quot; indentation size (used on auto indentation)</span>
69 set shiftwidth=<span class="nu0">2</span>
70 <span class="co1">&quot; smart indentation (indent beginning of blocks (e.g. '{') and unnindent ending of blocks (e.g. '}'))</span>
71 set smartindent
72 <span class="co1">&quot; save with Ctrl+S</span>
73 <span class="kw3">map</span><span class="sy0">!</span> <span class="sy0">&lt;</span>C<span class="sy0">-</span>s<span class="sy0">&gt;</span> <span class="sy0">&lt;</span>Esc<span class="sy0">&gt;:</span>w<span class="sy0">&lt;</span>CR<span class="sy0">&gt;</span>
74 <span class="kw3">map</span> <span class="sy0">&lt;</span>C<span class="sy0">-</span>s<span class="sy0">&gt;</span> <span class="sy0">&lt;</span>Esc<span class="sy0">&gt;:</span>w<span class="sy0">&lt;</span>CR<span class="sy0">&gt;</span>
75 <span class="co1">&quot; call make with F9</span>
76 <span class="kw3">map</span><span class="sy0">!</span> <span class="sy0">&lt;</span>F9<span class="sy0">&gt;</span> <span class="sy0">&lt;</span>Esc<span class="sy0">&gt;:</span>make<span class="sy0">&lt;</span>CR<span class="sy0">&gt;&lt;</span>CR<span class="sy0">&gt;</span>
77 <span class="kw3">map</span> <span class="sy0">&lt;</span>F9<span class="sy0">&gt;</span> <span class="sy0">&lt;</span>Esc<span class="sy0">&gt;:</span>make<span class="sy0">&lt;</span>CR<span class="sy0">&gt;&lt;</span>CR<span class="sy0">&gt;</span>
78 <span class="co1">&quot; auto save files</span>
79 set autowrite
80 set autowriteall
81 <span class="co1">&quot; abreviations</span>
82 iab #i #include
83 iab #d #define
84 <span class="co1">&quot; reload file automatically when it changes</span>
85 set autoread
86 <span class="co1">&quot; call make -B with F8</span>
87 <span class="kw3">map</span><span class="sy0">!</span> <span class="sy0">&lt;</span>F8<span class="sy0">&gt;</span> <span class="sy0">&lt;</span>Esc<span class="sy0">&gt;:</span>make <span class="sy0">-</span>B<span class="sy0">&lt;</span>CR<span class="sy0">&gt;&lt;</span>CR<span class="sy0">&gt;</span>
88 <span class="kw3">map</span> <span class="sy0">&lt;</span>F8<span class="sy0">&gt;</span> <span class="sy0">&lt;</span>Esc<span class="sy0">&gt;:</span>make <span class="sy0">-</span>B<span class="sy0">&lt;</span>CR<span class="sy0">&gt;&lt;</span>CR<span class="sy0">&gt;</span></pre>
89 </dd></dl>
91 <p>
92 If the save with Ctrl+S isn&#039;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>).
93 </p>
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"/>
97 </a>
98 </div>
100 </div>
101 <!-- SECTION "Useful Vim Configurations" [605-1769] -->
102 <h2><a name="commands" id="commands">Commands</a></h2>
103 <div class="level2">
107 <a href="/~kssilveira/site/doku.php?id=vim:commands" class="wikilink1" title="vim:commands">Vim Commands</a>
108 </p>
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"/>
112 </a>
113 </div>
115 </div>
116 <!-- SECTION "Commands" [1770-1823] -->
117 <h2><a name="edit-compile-execute_cycle" id="edit-compile-execute_cycle">Edit-Compile-Execute Cycle</a></h2>
118 <div class="level2">
119 <table class="inline">
120 <tr class="row0">
121 <th class="col0 leftalign" colspan="2"> Session </th>
122 </tr>
123 <tr class="row1">
124 <td class="col0"> :mks(ession) </td><td class="col1"> create a session file </td>
125 </tr>
126 <tr class="row2">
127 <td class="col0"> vim -S </td><td class="col1"> load a session file </td>
128 </tr>
129 <tr class="row3">
130 <th class="col0 leftalign" colspan="2"> Make </th>
131 </tr>
132 <tr class="row4">
133 <td class="col0"> :mak(e) </td><td class="col1"> run make </td>
134 </tr>
135 <tr class="row5">
136 <td class="col0"> :cl(ist) </td><td class="col1"> show make output </td>
137 </tr>
138 <tr class="row6">
139 <td class="col0"> :cope(n) </td><td class="col1"> open a window with make output </td>
140 </tr>
141 <tr class="row7">
142 <td class="col0"> :cn(ext) </td><td class="col1"> go to next error </td>
143 </tr>
144 <tr class="row8">
145 <td class="col0"> :cp(revious) </td><td class="col1"> go to previous error </td>
146 </tr>
147 <tr class="row9">
148 <td class="col0"> :cc </td><td class="col1"> go to current error </td>
149 </tr>
150 <tr class="row10">
151 <td class="col0"> :ccl(ose) </td><td class="col1"> close the window with make output </td>
152 </tr>
153 <tr class="row11">
154 <th class="col0 leftalign" colspan="2"> Motion </th>
155 </tr>
156 <tr class="row12">
157 <td class="col0"> Ctrl+O </td><td class="col1"> go to previous edition </td>
158 </tr>
159 <tr class="row13">
160 <td class="col0"> Ctrl+I </td><td class="col1"> go to next edition </td>
161 </tr>
162 </table>
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"/>
166 </a>
167 </div>
169 </div>
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>
172 <div class="level2">
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&amp;do=showtag&amp;tag=tag%3Aprogramming" class="wikilink1" title="tag:programming" rel="tag">programming</a>
176 </span></div>
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"/>
180 </a>
181 </div>
183 </div>
184 <!-- SECTION "How to use visual bell instead of beeping" [2297-] -->