-
Notifications
You must be signed in to change notification settings - Fork 6
/
Vim2IDE.html
257 lines (201 loc) · 5.36 KB
/
Vim2IDE.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Vim2IDE</title>
<link rel="stylesheet" href="templates/SyntaxHighlighter.css"></link>
<link rel="stylesheet" href="templates/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script language="javascript" src="templates/shCore.js"></script>
<script language="javascript" src="templates/shBrushCpp.js"></script>
<script language="javascript" src="templates/shBrushJScript.js"></script>
<script language="javascript" src="templates/shBrushPhp.js"></script>
<script language="javascript" src="templates/shBrushJava.js"></script>
<script language="javascript" src="templates/shBrushXml.js"></script>
<script language="javascript" src="templates/shBrushCss.js"></script>
<script language="javascript" src="templates/shBrushObjectiveC.js"></script>
<script language="javascript" src="templates/vimwiki.js"></script>
</head>
<body>
<div class="navbar">
<div class="navbar-container">
<a class="brand" href="index.html">NieNet</a>
<div class="nav-collapse">
<ul class="nav">
<li><a href="index.html">主页</a></li>
<li><a href="about.html">关于</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<div class="container">
<div id="content">
<p>
记录使用vim查看kernel代码的过程,逐步打造成为一个Souce Insight。
</p>
<h2 id="toc_0.1">session & viminfo</h2>
<p>
使用vim打开编辑了一些文件,并想把这些文件作为一个工程,下次直接恢复编辑。
</p>
<p>
:mks sesseion-kernel.vim
</p>
<p>
可以在vim启动时设置参数读取session文件来还原设置
</p>
<p>
$vim -S /path/to/Session.vim
</p>
<p>
如果启动vim后想读取一个session设置,重新打开该工程
</p>
<p>
:source session-kernel.vim
</p>
<p>
后面编辑增减了文件,更新session文件
</p>
<p>
:mks! session-kernel.vim
</p>
<p>
工程文件中保存相对路径(这样该工程文件就可以在不同机器上通用)。
</p>
<p>
:set sessionoptions -= curdir
:set sessionoptions += sesdir
:set sessionoptions?
sessionoptions=blank,buffers,folds,help,options,tabpages,winsize,sesdir
</p>
<p>
使用.vimrc配置简化操作
</p>
<pre>
" execute project related configuration in current directory
autocmd VimEnter * :call s:ReadSession()
function! s:ReadSession()
let session_file = "./session.vim"
if filereadable( session_file )
execute "so " . session_file
endif
endfunction
autocmd VimLeave * :call s:WriteSession()
function! s:WriteSession()
let session_file = "./session.vim"
if filereadable( session_file )
execute "mks! " . session_file
endif
endfunction
</pre>
<h2 id="toc_0.2">多窗口</h2>
<p>
打开当前文件所在的目录
,fe
</p>
<p>
使用,fe打开了一个目录窗口,需要在上一个窗口打开目录窗口中的某个文件
P
</p>
<p>
浏览当前打开的所有文件
,be
,bv
</p>
<p>
Ctrl-W h 移动到窗口左边
Ctrl-W j 移动到窗口下边
Ctrl-W k 移动到窗口上边
Ctrl-W l 移动到窗口右边
</p>
<p>
:vnew //垂直打开一个新的窗口
</p>
<h2 id="toc_0.3">tags</h2>
<p>
将当前目录下的所有文件生成tags文,放置在当前路径下
#ctags -R ./
</p>
<p>
打开vim,设置tags选项为当前目录下的tags文件
:set tags=tags
</p>
<p>
跳转到指定的标签,例如跳转到main函数
:tag main
</p>
<p>
显示标签栈
:tags
</p>
<p>
跳转到当前光标下的标签
CTRL-]
</p>
<p>
跳到标签栈中较早的标签
CTRL-T
</p>
<p>
查看所有的main函数
:ts main
</p>
<h2 id="toc_0.4">打开gitk工具</h2>
<pre>
#gitk //当前目录打开gitk这个GUI
Ctrl + Z //将gitk到后台运行
#jobs //查看后台运行的程序
#bg //将程序到后台运行
</pre>
<h2 id="toc_0.5">文件搜索</h2>
<p>
设置vim的文件搜索路径:
</p>
<pre>
set path=.,/usr/include,,~/workspace/4412/kernel-4412/**
</pre>
<p>
解释一下各项的含义:
</p>
<ul>
<li>
. //在当前文件所在目录中搜索
<li>
/usr/include //在/usr/include目录中搜索
<li>
//表示一个空的字符,在当前工作路径中搜索,也就是:pwd命令显示的路径
<li>
~/workspace/4412/kernel-4412/** //在其所有子目录树中进行搜索
</ul>
<p>
设置了path之后,如何查找文件呢?
</p>
<ul>
<li>
将光标定位到某个文件的单词,在normal模式下按下"gf",使用Ctrl+^可以返回上一个文件;
<li>
将光标定位到某个文件的单词,在normal模式下按下"ctrl+w f"可以在一个水平窗口打开该文件
<li>
使用:find命令,例如:find printk.c
</ul>
<h2 id="toc_0.6">lookupfile插件</h2>
<p>
生成文件名列表tag文件,为lookupfile插件所用:
</p>
<pre>
$echo '!_TAG_FILE_SORTED 2 /2=foldcase/' >tagfile
$find `pwd` -type f \( -name "*.[ch]" -o -name "*.[ch]pp" \) -printf "%f\t%p\t1\n"|sort -f >> filenametags
</pre>
<p>
有关lookupfile插件的使用,参考vimrc的gist文件。
</p>
</div>
</div>
<footer>
<p id="legal">Copyright © 2012 NIE-YONG. All Rights Reserved.</p>
</footer>
<a class="go2top" style="display: none;"><span></span></a>
</body>
<script language="javascript">
dp.SyntaxHighlighter.HighlightAll('code');
</script>
</html>