Chinaunix首页 | 论坛 | 博客
  • 博客访问: 329729
  • 博文数量: 100
  • 博客积分: 2620
  • 博客等级: 少校
  • 技术积分: 920
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-16 02:50
文章分类

全部博文(100)

文章存档

2011年(5)

2010年(12)

2009年(83)

分类:

2009-12-04 16:00:08

vimrc
综合了很多人的.vimrc,自己在用,做个记录吧,也欢迎你拿去用,嘎嘎!
说明一下,以下vimrc实现的主要的快捷键功能:
(1)添加抬头
    快捷键F9,添加文件头描述信息
(2)产生cpp初始程序
    由于经常写一些小的cpp测试程序,所以每次都需要包括头文件,写main,麻烦之极,所以这里在vimrc里面加了一个快捷键F10,调用CppFramework直接产生cpp的初始信息。
(3)添加注释
    F4位一行添加注释/**/
(4)注释一行
    F5注释当前行
(5)自动格式化
    F8自动按照K&R风格格式化整个文件
(6)taglist
    F7自动打开、关闭taglist
.vimrc文件内容如下:
"turn off vim compatible check
set nocompatible
"check file type
filetype on
"histroy line count
set history=1000
"set background
set background=dark
syntax on
set autoindent
set smartindent
"show match '(' and ')'
set showmatch
"left-down status line
set ruler
"auto match targets
set incsearch
"high light search
set hlsearch
"auto backup file with filename+~
set backup
set title
set foldenable
"fold code by syntax 'cmd':
"'zi' open/close all folds
"'za' open/close current fold
"'zM' close all folds
"'zR' open all folds
set foldmethod=syntax
"set foldmethod=marker
"set foldmethod=indent
set foldcolumn=3
set foldopen=all
"set foldclose=all
"colorscheme evening
"set cinoptions+={2,0,p0,t0
set cindent
set syntax=cpp
set formatoptions=tcqr
set nu
function MyTitle()
 call setline(1,"/**************************************")
 call append(line("."),  "Author  : Thunder")
 call append(line(".")+1,"Time    :".strftime("%c"))
 call append(line(".")+2,"FileName:".expand("%"))
 call append(line(".")+3,"Desc    :")
 call append(line(".")+4,"*************************************/")
endf
"add header
map :call MyTitle():$o
function CppFramework()
 call setline(8,"#include")
 call setline(9,"#include")
 call setline(10,"using namespace std;")
 call setline(11,"")
 call setline(12,"int main(int argc, char* argv[])")
 call setline(13,"{")
 call setline(14," return 0;")
 call setline(15,"}")
endf
"add cpp framework
map :call CppFramework():$2ko
function AddComment()
 if &syntax=="cpp" || &syntax=="c"
  execute "normal \\a\/* */\2ha"
 elseif &syntax=="py"
  execute "normal \\a\#\2ha"
 elseif &syntax=="lua"
  execute "normal \\a\--\2ha"
 endif
endf
"add comment
map :call AddComment()i
function CommOneLine()
 let tmp=getline(".")
 call setline(line("."),"/*")
 call append(line("."),"".tmp." //by thunder ".strftime("%c"))
 call append(line(".")+1," */")
endf
map :call CommOneLine()
"foramt code with K&R style
map :1,$g/^$/dgg=Ggg
let Tlist_Ctags_Cmd='/usr/bin/Ctags'
map :TlistToggle
 
 
foldopen参数说明:
{not available when compiled without the |+folding|feature}
Specifies for which type of commands folds will be opened, if the
command moves the cursor into a closed fold.  It is a comma separated
list of items.
item commands ~
all any
block "(", "{", "[[", "[{", etc.
hor horizontal movements: "l", "w", "fx", etc.
insert any command in Insert mode
jump far jumps: "G", "gg", etc.
mark jumping to a mark: "'m", CTRL-O, etc.
percent "%"
quickfix ":cn", ":crew", ":make", etc.
search search for a pattern: "/", "n", "*", "gd", etc.
(not for a search pattern in a ":" command)
tag jumping to a tag: ":ta", CTRL-T, etc.
undo undo or redo: "u" and CTRL-R
When the command is part of a mapping this option is not used.  Add
the |zv| command to the mapping to get the same effect.
When a movement command is used for an operator (e.g., "dl" or "y%")
this option is not used.  This means the operator will include the
whole closed fold.
Note that vertical movements are not here, because it would make it
very difficult to move onto a closed fold.
In insert mode the folds containing the cursor will always be open
when text is inserted.
To close folds you can re-apply 'foldlevel' with the |zx| command or
set the 'foldclose' option to "all".
阅读(872) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~