vim 的快捷使用方法

</pre><span style="white-space:pre">	</span>本人比较偏向于用vim进行c代码的编辑,应该是入门级编辑器,入门引导人曾经这样跟我说过,只有菜鸟和老手才用vim编辑代码,在我心里是他骂我菜鸟,他推荐我使用UE。但是我觉得VIM更加接近Linux,所以我要成为别人眼中的“老手”;接下来详细介绍一下vim的用惯的方法。<p></p><p style="text-indent:28px">1、进入~/.bashrc,配置一下alias,用户可以利用alias自定义命令的别名。添加这一行命令,alias vi=‘vim',以后使用vi替代vim,vi没有vim功能强大,但是为了编辑操作简单,我是这样改的。</p><p><span style="white-space:pre"></span>2、ctags+taglist+superTab +vim 组合实现vim编辑的快速入门。</p><p><span style="white-space:pre"></span>   ctags是vim快捷编译浏览代码的工具,包括我们经常使用的Source Insight阅读代码,里面函数之间的快速跳转,其实就是使用了ctags工具。</p><p><span style="white-space:pre"></span>   vim在使用ctags时,首先在阅读目录下使用ctags -R命令,然后进入代码,使用CTRL+】进行函数之间的跳转,非常方便,包括结构体定义,函数实现等。但跳转的路径是在当前路径下,如果有函数无法跳转,请将所有的函数copy到当前目录下面,继续操作ctags -R,然后进行代码跳转。</p><p><span style="white-space:pre">	</span>taglist 是添加函数列表功能。</p><p><span style="white-space:pre">	</span>superTab是使用Tab进行自动不全的功能。</p><p></p><p>/etc/vimrc配置文件</p><p></p><pre name="code" class="html">if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
   set fileencodings=utf-8,latin1
endif

set nocompatible	" Use Vim defaults (much better!)
set bs=indent,eol,start		" allow backspacing over everything in insert mode
"set ai			" always set autoindenting on
"set backup		" keep a backup file
set viminfo='20,\"50	" read/write a .viminfo file, don't store more
			" than 50 lines of registers
set history=50		" keep 50 lines of command line history
set ruler		" show the cursor position all the time
set number
set autoindent
set cindent
set history=100 
set backspace=2 
set clipboard+=unnamed 
" Only do this part when compiled with support for autocommands
if has("autocmd")
  augroup redhat
    " In text files, always limit the width of text to 78 characters
    autocmd BufRead *.txt set tw=78
    " When editing a file, always jump to the last cursor position
    autocmd BufReadPost *
    \ if line("'\"") > 0 && line ("'\"") <= line("$") |
    \   exe "normal! g'\"" |
    \ endif
  augroup END
endif

if has("cscope") && filereadable("/usr/bin/cscope")
   set csprg=/usr/bin/cscope
   set csto=0
   set cst
   set nocsverb
   " add any database in current directory
   if filereadable("cscope.out")
      cs add cscope.out
   " else add database pointed to by environment
   elseif $CSCOPE_DB != ""
      cs add $CSCOPE_DB
   endif
   set csverb
endif

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

set foldmethod=manual 
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc':'zo')<CR> 
if &term=="xterm"
     set t_Co=8
     set t_Sb=[4%dm
     set t_Sf=[3%dm
endif
let Tlist_Auto_Open=1
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_WinWidth=50
let Tlist_Use_Right_Window = 1 
let Tlist_Ctags_Cmd="/usr/bin/ctags"
let g:SuperTabRetainComletionType=2      //superTab配置
let g:SuperTabDefaultCompletionTye="<C-X><C-O>"   //superTab


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值