阿俊de坑

一个漂泊的小孩儿

导航

vimrc 设置

Posted on 2014-10-16 10:47  阿俊de坑  阅读(319)  评论(0编辑  收藏  举报
1 "===============================================================================
 2 "        Filename: vimrc
 3 "          Author: Wu Yin(吴垠)
 4 "           Email: lazy_fox#gmail.com
 5 "        Homepage: http://blog.csdn.net/wooin
 6 "         Created: 2007-10-26
 7 "===============================================================================
 8 set encoding=gb2312
 9 set guifont=Luxi/ Mono/ 9   " 设置字体,字体名称和字号
 10 set tabstop=4       " 设置tab键的宽度
 11 set backspace=2     " 设置退格键可用
 12 set nu!             " 显示行号
 13 set vbt_vb=        " vim进行编辑时,如果命令错误,会发出一个响声,该设置去掉响声
 14 "set wrap           " 自动换行
 15 "set nowrap         " 不自动换行
 16 set linebreak       " 整词换行
 17 set whichwrap=b,s,<,>,[,]       " 光标从行首和行末时可以跳到另一行去
 18 "set list                       " 显示制表符
 19 "set listchars = tab:>-,trail:- " 将制表符显示为'>---',将行尾空格显示为'-'
 20 set listchars=tab:./ ,trail:.   " 将制表符显示为'.   '
 21 set autochdir                   " 自动设置目录为正在编辑的文件所在的目录
 22 set hidden          " 没有保存的缓冲区可以自动被隐藏
 23 set scrolloff=5
 24 
 25 "--------------------------------------------------------------------------------
 26 " 查找/替换相关的设置
 27 "--------------------------------------------------------------------------------
 28 set hlsearch        " 高亮显示搜索结果
 29 set incsearch       " 查询时非常方便,如要查找book单词,当输入到/b时,会自动找到
 30                     " 第一个b开头的单词,当输入到/bo时,会自动找到第一个bo开头的
 31                     " 单词,依次类推,进行查找时,使用此设置会快速找到答案,当你
 32                     " 找要匹配的单词时,别忘记回车
 33 set gdefault        " 替换时所有的行内匹配都被替换,而不是只有第一个
 34 
 35 "--------------------------------------------------------------------------------
 36 " 状态栏相关的设置
 37 "--------------------------------------------------------------------------------
 38 set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%]
 39 set laststatus=2    " always show the status line
 40 set ruler           " 在编辑过程中,在右下角显示光标位置的状态行
 41 
 42 "--------------------------------------------------------------------------------
 43 " 编程相关的设置
 44 "--------------------------------------------------------------------------------
 45 set completeopt=longest,menu    " 关掉智能补全时的预览窗口
 46 filetype pluginindenton       " 加了这句才可以用智能补全
 47 :set tags=/home/nfs/microwindows/src/tags
 48 syn on              " 打开语法高亮
 49 set showmatch       " 设置匹配模式,类似当输入一个左括号时会匹配相应的那个右括号
 50 set smartindent     " 智能对齐方式
 51 set shiftwidth=4    " 换行时行间交错使用4个空格
 52 set autoindent      " 自动对齐
 53 set ai!             " 设置自动缩进
 54 colorscheme desert_wuyin
 55 
 56 "--------------------------------------------------------------------------------
 57 " 代码折叠
 58 "--------------------------------------------------------------------------------
 59 "set foldmarker={,}
 60 "set foldmethod=marker
 61 set foldmethod=syntax
 62 set foldlevel=100       " Don't autofold anything (but I can still fold manually)
 63 "set foldopen-=search   " don't open folds when you search into them
 64 "set foldopen-=undo     " don't open folds when you undo stuff
 65 "set foldcolumn=4
 66 
 67 "--------------------------------------------------------------------------------
 68 " 模仿MS Windows中的快捷键
 69 "--------------------------------------------------------------------------------
 70 vmap <C-c> "yy
 71 vmap <C-x> "yd
 72 nmap <C-v> "yp
 73 vmap <C-v> "yp
 74 nmap <C-a> ggvG$
 75 
 76 "--------------------------------------------------------------------------------
 77 " 窗口操作的快捷键
 78 "--------------------------------------------------------------------------------
 79 nmap wv     <C-w>v     " 垂直分割当前窗口
 80 nmap wc     <C-w>c     " 关闭当前窗口
 81 nmap ws     <C-w>s     " 水平分割当前窗口
 82 
 83 "--------------------------------------------------------------------------------
 84 " 模仿MS Windows中的保存命令: Ctrl+S
 85 "--------------------------------------------------------------------------------
 86 imap <C-s> <Esc>:wa<cr>i<Right>
 87 nmap <C-s> :wa<cr>
 88 
 89 
 90 
 91 
 92 "###############################################################################
 93 " The following is the Plugins' setting
 94 "###############################################################################
 95 
 96 "--------------------------------------------------------------------------------
 97 " TagList :Tlist
 98 "--------------------------------------------------------------------------------
 99 let Tlist_Show_One_File=1
100 let Tlist_Exit_OnlyWindow = 1
101 "let Tlist_Use_Right_Window=1
102 
103 "--------------------------------------------------------------------------------
104 " netrw 文件浏览器 :e <PATH>
105 "--------------------------------------------------------------------------------
106 "let g:netrw_winsize = 30       " 浏览器宽度
107 
108 "--------------------------------------------------------------------------------
109 " QuickFix
110 "--------------------------------------------------------------------------------
111 nmap <F6> :cn<cr>   " 切换到下一个结果
112 nmap <F7> :cp<cr>   " 切换到上一个结果
113 
114 "--------------------------------------------------------------------------------
115 " WinManager :WMToggle
116 "--------------------------------------------------------------------------------
117 let g:winManagerWindowLayout='FileExplorer|TagList'
118 "let g:winManagerWidth = 30
119 "let g:defaultExplorer = 0
120 "nmap <C-w><C-b> :BottomExplorerWindow<cr> " 切换到最下面一个窗格
121 "nmap <C-w><C-f> :FirstExplorerWindow<cr>   " 切换到最上面一个窗格
122 nmap wm :WMToggle<cr> " 是nomal模式的命令,不是Ex模式的
123 
124 "--------------------------------------------------------------------------------
125 " MiniBufExp
126 "--------------------------------------------------------------------------------
127 "let g:miniBufExplMapWindowNavVim = 1
128 let g:miniBufExplMapWindowNavArrows = 1
129 let g:miniBufExplMapCTabSwitchBufs = 1
130 "let g:miniBufExplModSelTarget = 1
131 
132 "--------------------------------------------------------------------------------
133 " cscope
134 "--------------------------------------------------------------------------------
135 cs add /home/nfs/microwindows/src/cscope.out /home/nfs/microwindows/src
136 :set cscopequickfix=s-,c-,d-,i-,t-,e-
137 :set cscopetag
138 " 按下面这种组合键有技巧,按了<C-_>后要马上按下一个键,否则屏幕一闪
139 " 就回到nomal状态了
140 " <C-_>s的按法是先按"Ctrl+Shift+-",然后很快再按"s"
141 nmap <C-_>s :cs find s <C-R>=expand("<cword>")<cr><cr> :cw<cr>
142 nmap <C-_>g :cs find g <C-R>=expand("<cword>")<cr><cr> :cw<cr>
143 nmap <C-_>c :cs find c <C-R>=expand("<cword>")<cr><cr> :cw<cr>
144 nmap <C-_>t :cs find t <C-R>=expand("<cword>")<cr><cr> :cw<cr>
145 nmap <C-_>e :cs find e <C-R>=expand("<cword>")<cr><cr> :cw<cr>
146 nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<cr><cr>
147 nmap <C-_>i :cs find i <C-R>=expand("<cfile>")<cr><cr> :cw<cr>
148 nmap <C-_>d :cs find d <C-R>=expand("<cword>")<cr><cr> :cw<cr>
149 
150 "--------------------------------------------------------------------------------
151 " Grep
152 "--------------------------------------------------------------------------------
153 "直接按下<F3>键来查找光标所在的字符串
154 nnoremap <silent> <F3> :Rgrep<CR>
155 
156 "--------------------------------------------------------------------------------
157 " A
158 "--------------------------------------------------------------------------------
159 nnoremap <silent> <F12> :A<CR>
160 
161 "--------------------------------------------------------------------------------
162 " NERD_commenter
163 "--------------------------------------------------------------------------------
164 let NERD_c_alt_style = 1    " 将C语言的注释符号改为//, 默认是/**/
165 "nmap <F5> ,cc
166 
167 "--------------------------------------------------------------------------------
168 " SuperTab :SuperTabHelp
169 "--------------------------------------------------------------------------------
170 let g:SuperTabRetainCompletionType = 2
171 let g:SuperTabDefaultCompletionType = "<C-X><C-O>"
172 
173 "--------------------------------------------------------------------------------
174 " CVim :help csupport
175 "--------------------------------------------------------------------------------
176 let g:C_Comments = "no"         " 用C++的注释风格
177 let g:C_BraceOnNewLine = "no"   " '{'是否独自一行
178 let g:C_AuthorName = "Wu Yin"
179 let g:C_Project="F9"
180 let g:Cpp_Template_Function = "c-function-description-wuyin"
181 let g:C_TypeOfH = "c"           " *.h文件的文件类型是C还是C++
182 
183 "##################################################################
184 "########################## End Of Vimrc ##########################
185 "##################################################################
186 
187 " if filetype is C
188 "   TODO
189 " fi

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
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
$ cat .vimrc
"==
"Author :roc
"Website:roclinux.cn
"Version:1.0
"==
 
"按编程语言的语法,对代码进行彩色标示,术语叫做语法高亮
syntax on
 
"显示行数标示
set number
 
"打开状态栏的坐标信息
set ruler
 
"取消底部状态栏显示。1为关闭,2为开启。
set laststatus=1
 
"将输入的命令显示出来,便于查看当前输入的信息
set showcmd
 
"设置魔术匹配控制,可以通过:h magic查看更详细的帮助信息
set magic
 
"设置vim存储的历史命令记录的条数
set history=100
 
"下划线高亮显示光标所在行
set cursorline
 
"插入右括号时会短暂地跳转到匹配的左括号
set showmatch
 
"搜索时忽略大小写
set ignorecase
 
"不对匹配的括号进行高亮显示
let loaded_matchparen=1
 
"在执行宏命令时,不进行显示重绘;在宏命令执行完成后,一次性重绘,以便提高性能。
set lazyredraw
 
"设置一个tab对应4个空格
set tabstop=4
 
"在按退格键时,如果前面有4个空格,则会统一清除
set softtabstop=4
 
"cindent对c语法的缩进更加智能灵活,
"而shiftwidth则是在使用&lt;和&gt;进行缩进调整时用来控制缩进量。
"换行自动缩进,是按照shiftwidth值来缩进的
set cindent shiftwidth=4
 
"最基本的自动缩进
set autoindent shiftwidth=4
 
"比autoindent稍智能的自动缩进
set smartindent shiftwidth=4
 
"将新增的tab转换为空格。不会对已有的tab进行转换
set expandtab
 
"高亮显示搜索匹配到的字符串
set hlsearch
 
"在搜索模式下,随着搜索字符的逐个输入,实时进行字符串匹配,并对首个匹配到的字符串高亮显示
set incsearch
 
"设置自定义快捷键的前导键
let mapleader=","
 
"利用前导键加b,则可以在一个单子两边加上大括号
map b wbi{<Esc>ea}<Esc>
 
"使用前导键加w来实现加速文件保存,来代替:w!加回车
nmap w :w!<CR>
 
"匹配那些末尾有空格或TAB的行。(es:Endspace Show)
map es :/.*\s\+$<CR>
 
"删除行末尾的空格或TAB(ed:Endspace Delete)
map ed :s#\s\+$##<CR>
 
"如果所选行的行首没有#,则给所选行行首加上注释符#(#a:# add)
map #a :s/^\([^#]\s*\)/#\1/<CR>
 
"如果所选行行首有#,则将所选行行首所有的#都去掉(#d:# delete)
map #d :s/^#\+\(\s*\)/\1/<CR>
 
"如果所选行的行首没有//,则给所选行行首加上注释符///a:/ add)
map /a :s/^\([^\/\/]\s*\)/\/\/\1/<CR>
 
"如果所选行行首有//,则将所选行行首的//都去掉(/d:/ delete)
map /d :s/^\/\/\(\s*\)/\1/<CR>

http://roclinux.cn/?p=2675