嘉兴cms模板建站,目前口碑最好的传奇游戏,淘宝网站小视频怎么做,免费网站流量统计windows下很多人都使用source insight 编写和查看代码。linux下可以使用VIM#xff0c;刚开始会觉得VIM像windows下的记事本#xff0c;而如果使用得当#xff0c;它并不比source insight 逊色。在这里#xff0c;我会尽我所能细致地讲清楚如何把vim变成source insight, 然… windows下很多人都使用source insight 编写和查看代码。linux下可以使用VIM刚开始会觉得VIM像windows下的记事本而如果使用得当它并不比source insight 逊色。 在这里我会尽我所能细致地讲清楚如何把vim变成source insight, 然而你仍然需要积极地思考并且必须自己去摸索一些东西。 为了避免过于罗嗦我把基础的部分放在后面如果你越看越觉得太简单了那么本文并不适合你;如果看完前面的仍有疑问或者看不懂前面说的是什么东西不用担心后面会有一些必备的知识介绍。 一、用好系统自带软件ctags 大部分的unix系统都有ctags软件它能跟vim很好地合作。 用途: 生成c语言的标签文件实现相关c文件之间的跳转。 用法: 1.生成标签文件 在当前目录下(运行$提示符后面的命令):  $ctags -R . -R表示recursive递归,为当前目录及其子目录中的c文件生成标签文件。最后一个.表示在当前目录。 运行完当前目录会多一个文件tags,就是c标签的索引文件。 2.跳转 1)用vim打开一个已经建过标签的c文件     2)ctrl] 找到光标所在位置的标签定义的地方 3)ctrlt 回到跳转之前的标签处 注意此时运行vim必须在tags文件所在的目录下运行。否则运行它会找不到tags文件而需要在vim中用:set tags命令设定tags文件的路径。对于一个稍微大点的项目你可能在任何一个目录下打开vim然而在每个目录下都生成一个tags文件并不 是个好主意那么如何解决呢方法是在.vimrc中增加一行 set tagstags;/ 这是告诉vim在当前目录找不到tags文件时请到上层目录查找。 二、需要额外安装的脚本 1、taglist 下载地址http://www.vim.org/scripts/script.php?script_id273 若你下载时地址已改变请到 www.vim.org 找到正确的地址,这很简单。 用途: 打开后可以显示源码的整体架构方便地进行跳转。(用惯source insight的人一定勾起某些回忆了^_^) 用法: 下载插件并安装使用时在vim中输入命令 :Tlist 即可打开/关闭taglist窗口。 一个简单的方法是设定快捷键,在.vimrc中增加一行: nnoremap silent F8 :TlistToggleCR 这样在vim中按F8就可以打开/关闭taglist了。 更多相关配置请看后面关于.vimrc的介绍。 三、基础知识探讨 约定为了方便和准确我们约定本文中$标示符后的命令为在终端下运行而:后的命令为在vim中运行。 VIM的配置文件一般放在用户主文件夹下也就是非root状态时在终端运行 $cd ~/ 会到的那个目录文件名为.vimrc。 看不到?有两个可能 1、文件名前面有一个点表示是隐藏文件ls查看时需加-a选项。 $ls -a 2、你还没有建.vimrc文件自己创建一个就行先建个空的吧以后可以不断往里面填东西。 $touch .vimrc 主文件夹下还有一个.vim文件夹没有请自己mkdir $mkdir ~/.vim 在.vim文件夹下再建两个子文件夹plugin和doc $mkdir ~/.vim/plugin $mkdir ~/.vim/doc plugin文件夹下放插件doc文件夹下放相应的help文档。 去下一个taglist吧(我们应该把它叫作脚本还是插件呢它是放在plugin文件夹下的那么应该是插件而在vim.org它是作为scripts存在那么应当是脚本。)我们当作例子来请解。 下载的是一个zip包把它放在 ~/.vim 目录下然后 $unzip filename.zip 它已经自动把taglist.vim和taglist.txt分别放到plugin、doc文件夹下了。 这时重新启动vim $vim 运行 :Tlist 发现旁边多了一栏没有如果你打开的是c文件并且已经生成了tags文件那么里面应当会显示一些有用的信息。 这个时候taglist的help文档已经在 ~/.vim/doc 目录下了,但是你在vim下敲 :help Tlist 却没有任何反应那是因为vim还没有获取帮助文档里面的tag解决方法是在vim下 :helptags ~/.vim/doc 现在你再 :help Tlist 看看有没有反应 关于.vimrc 我自己的.vimrc也在不断地完善中完善的过程中得益于从网络上获取的很多知识感谢提供信息的朋友也是他们促使我写下这篇东西。我把自己.vimrc的一部分贴在下面你可以把这些根据需要加到你的.vimrc里面去。 .vimrc   General  For ctags, then it can find the tags file even not in current directory set tagstags;/ Get out of VIs compatible mode.. set nocompatible Sets how many lines of history VIM har to remember set history400 Set to auto read when a file is changed from the outside set autoread Have the mouse enabled all the time: when you need to copy from vim, maybe you have to :set mouse first set mousea   Colors and Fonts  Enable syntax highlight syntax enable set colorscheme colorscheme elflord endif   VIM userinterface  Set 7 lines to the curors away from the border- when moving vertical.. set so7 Turn on WiLd menu set wildmenu Always show current position set ruler The commandbar is 2 high set cmdheight2 Show line number set nu Set backspace set backspaceeol,start,indent Bbackspace and cursor keys wrap to set whichwrap,,h,l show matching bracets set showmatch How many tenths of a second to blink set mat2 Highlight search things set hlsearch imediately show the search result set is   Folding  Enable folding, I find it very useful set nofen set fdl0   Text options  set expandtab set shiftwidth2 set ambiwidthdouble set smarttab Set Tab4 spaces set ts4 set lbr set tw500 set selectioninclusive   Indent  Auto indent set ai Set auto indent width  4 spaces set sw4 Smart indet set si C-style indenting set cindent usage: select codes, press  key, the codes will autoindenting Wrap lines set wrap Encoding settings if has(multi_byte)  Set fileencoding priority if getfsize(expand(%))  0 set fileencodingsucs-bom,utf-8,cp936,big5,euc-jp,euc-kr,latin1 else set fileencodingscp936,big5,euc-jp,euc-kr,latin1 endif  CJK environment detection and corresponding setting if v:lang ~ ^zh_CN  Use cp936 to support GBK, euc-cn  gb2312 set encodingcp936 set termencodingcp936 set fileencodingcp936 elseif v:lang ~ ^zh_TW  cp950, big5 or euc-tw  Are they equal to each other? set encodingbig5 set termencodingbig5 set fileencodingbig5 elseif v:lang ~ ^ko  Copied from someones dotfile, untested set encodingeuc-kr set termencodingeuc-kr set fileencodingeuc-kr elseif v:lang ~ ^ja_JP  Copied from someones dotfile, unteste set encodingeuc-jp set termencodingeuc-jp set fileencodingeuc-jp endif  Detect UTF-8 locale, and replace CJK setting if needed if v:lang ~ utf8$ || v:lang ~ UTF-8$ set encodingutf-8 set termencodingutf-8 set fileencodingutf-8 endif else echoerr Sorry, this version of (g)vim was not compiled with multi_byte endif  plugins   Tlist if diff let Tlist_Auto_Open0 dont auto pen when compare two files else let Tlist_Auto_Open1 auto pen Tlist when open a file endif set taglist window in right, delete the following line if you dont like let Tlist_Use_Right_Window1 let Tlist_Auto_Update1  let Tlist_File_Fold_Auto_Close1 auto close Tlist when exiting file. let Tlist_Exit_OnlyWindow  1  nmap F7 :copenCR nmap F6 :ccloseCR