博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
vimrc
阅读量:5098 次
发布时间:2019-06-13

本文共 15175 字,大约阅读时间需要 50 分钟。

1 " All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by  2 " the call to :runtime you can find below.  If you wish to change any of those  3 " settings, you should do it in this file (/etc/vim/vimrc), since debian.vim  4 " will be overwritten everytime an upgrade of the vim packages is performed.  5 " It is recommended to make changes after sourcing debian.vim since it alters  6 " the value of the 'compatible' option.  7   8 " This line should not be removed as it ensures that various options are  9 " properly set to work with the Vim-related packages available in Debian. 10 runtime! debian.vim 11 " Uncomment the next line to make Vim more Vi-compatible 12 " NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous 13 " options, so any other options should be set AFTER setting 'compatible'. 14 "set compatible 15  16 " Vim5 and later versions support syntax highlighting. Uncommenting the next 17 " line enables syntax highlighting by default. 18 if has("syntax") 19   syntax on 20 endif 21  22 " If using a dark background within the editing area and syntax highlighting 23 " turn on this option as well 24 "set background=dark 25  26 " Uncomment the following to have Vim jump to the last position when 27 " reopening a file 28 "if has("autocmd") 29 "  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif 30 "endif 31  32 " Uncomment the following to have Vim load indentation rules and plugins 33 " according to the detected filetype. 34 "if has("autocmd") 35 "  filetype plugin indent on 36 "endif 37  38 " The following are commented out as they cause vim to behave a lot 39 " differently from regular Vi. They are highly recommended though. 40 set showcmd        " Show (partial) command in status line. 41 set showmatch        " Show matching brackets. 42 "set ignorecase        " Do case insensitive matching 43 "set smartcase        " Do smart case matching 44 "set incsearch        " Incremental search 45 set autowrite        " Automatically save before commands like :next and :make 46 "set hidden        " Hide buffers when they are abandoned 47 set mouse=a        " Enable mouse usage (all modes) 48  49 " Source a global configuration file if available 50 if filereadable("/etc/vim/vimrc.local") 51   source /etc/vim/vimrc.local 52 endif 53  54 set nu 55 set tabstop=4 56 set softtabstop=4 57 set shiftwidth=4 58 "set smartindent 59 set cursorline 60 set ruler 61 "set autoindent 62 set showcmd 63 set formatoptions=tcrqn    "自动格式化 64 set clipboard+=unnamed 65 set autowrite 66 "set confirm 67 set smarttab 68 set history=1000 69 set autoread 70 "禁止生成临时文件 71 set nobackup 72 set noswapfile 73  74 set foldenable    "允许折叠 75 set foldmethod=manual    "手动折叠 76  77 " 匹配括号高亮的时间(单位是十分之一秒) 78 set matchtime=1 79  80 set backspace=2 81 " 允许backspace和光标键跨越行边界 82  83 map
:call AddHeader()
84 "auto BufNewFile *.cpp exec ":call AddHeader()" 85 func AddHeader() 86 if &filetype == 'cpp' 87 call setline(line("."),"#include
") 88 let l=line(".")-1 89 let l=l+1 | call append(l,"#include
") 90 let l=l+1 | call append(l,"#include
") 91 let l=l+1 | call append(l,"#include
") 92 let l=l+1 | call append(l,"#include
") 93 let l=l+1 | call append(l,"#include
") 94 let l=l+1 | call append(l,"#include
") 95 let l=l+1 | call append(l,"#include
") 96 let l=l+1 | call append(l,"#include
") 97 let l=l+1 | call append(l,"#include
") 98 let l=l+1 | call append(l,"#include
") 99 endif100 autocmd BufNewFile * normal Gkkk101 endfunc102 103 auto BufNewFile *.cpp exec ":call Addline()"104 map
:call Addline()
105 func Addline()106 if &filetype == 'cpp'107 call setline(line("."),"#include
")108 let l=line(".")-1109 let l=l+1 | call append(l,"using namespace std;")110 let l=l+1 | call append(l,"typedef long long LL;")111 let l=l+1 | call append(l,"const int N=1e5+10;")112 let l=l+1 | call append(l,"const int INF=0x3f3f3f3f;")113 let l=l+1 | call append(l,"int cas=1,T;")114 let l=l+1 | call append(l,"int main()")115 let l=l+1 | call append(l,"{")116 let l=l+1 | call append(l,"// freopen(\"1.in\",\"w\",stdout);")117 let l=l+1 | call append(l,"// freopen(\"1.in\",\"r\",stdin);")118 let l=l+1 | call append(l,"// freopen(\"1.out\",\"w\",stdout);")119 let l=l+1 | call append(l,"// scanf(\"%d\",&T);")120 let l=l+1 | call append(l,"// cerr<<\"time=\"<<(double)clock()/CLOCKS_PER_SEC<
w :w!
142 nmap
f :find
143 "映射全选+复制 ctrl+a144 map
ggVGY145 "map!
ggVGY146 map
gg=G147 "选中状态下 ctrl+c 复制148 vmap
"+y149 map zz 0i//
150 map tt 0lli
151 152 "C,C++ 按F5编译运行153 map
:call CompileRunGcc()
154 func! CompileRunGcc()155 :w156 if &filetype == 'c'157 :! gcc % -o %<158 :! %<.exe159 elseif &filetype == 'cpp'160 ":! g++ -std=c++11 % -o %<161 ":! %<.exe162 :!g++ -std=c++11 % -o G:/exe/%<163 :! G:/exe/%<.exe164 elseif &filetype == 'java' 165 :! javac % 166 :! java %<167 elseif &filetype == 'sh'168 :! %<.sh169 elseif &filetype == 'html'170 :! chrome G:/cpp/%171 else172 :!python G:/cpp/%173 endif174 endfunc175 176 " getline('.')获取当前行字符串 line('.')获取当前行行号177 " col('.')获取当前列号178 "自动补全179 "inoremap ( ()
180 "inoremap )
=ClosePair(')')
181 "inoremap { {}
182 "inoremap }
=ClosePair('}')
183 "inoremap [ []
184 "inoremap ]
=ClosePair(']')
185 "inoremap
=Line('}')
186 "inoremap "
=Pair('"')
187 "inoremap '
=Pair("\'")
188 function! Line(char)189 if getline('.')[col('.')-1] == a:char190 return "\
\
\
\t"191 else192 return "\
"193 endif194 endfunction195 function! Pair(char)196 if getline('.')[col('.')-1] == a:char197 return "\
"198 else199 let s=a:char.a:char."\
"200 return s201 endif202 endfunction203 function! ClosePair(char)204 if getline('.')[col('.') - 1] == a:char205 return "\
"206 else207 return a:char208 endif209 endfunction210 filetype plugin indent on 211 "打开文件类型检测, 加了这句才可以用智能补全212 set completeopt=longest,menu213 """"""""""""""""""""""""'""214 215 " 显示相关 216 " """""""""""""""""""217 set shortmess=atI " 启动的时候不显示那个援助乌干达儿童的提示 218 winpos -4 -4 " 设定窗口位置 219 set lines=40 columns=170 " 设定窗口大小 220 " "set nu " 显示行号 221 " set go= " 不要图形按钮 222 colorscheme desert " 设置背景主题 223 set guifont=Consolas:h14:cANSI " 设置字体 224 " "syntax on " 语法高亮 225 " autocmd InsertLeave * se nocul " 用浅色高亮当前行 226 "autocmd InsertEnter * se cul " 用浅色高亮当前行 227 " "set ruler " 显示标尺 228 " set showcmd " 输入的命令显示出来,看的清楚些 229 set cmdheight=1 " 命令行(在状态行下)的高度,设置为1 230 "set whichwrap+=<,>,h,l " 允许backspace和光标键跨越行边界(不建议) 231 set scrolloff=10 " 光标移动到buffer的顶部和底部时保持3行距离 232 "set novisualbell " 不要闪烁(不明白) 233 " set statusline=%F%m%r%h%w\ [FORMAT=%{234 " &ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{235 " strftime(\"%d/%m/%y\ -\ %H:%M\")} "状态行显示的内容 236 " set laststatus=1 " 启动显示状态行(1),总是显示状态行(2) 237 " set foldenable " 允许折叠 238 " set foldmethod=manual " 手动折叠 239 "set background=dark "背景使用黑色 240 " set nocompat241 "242 243 " 解决菜单乱码 244 "----------------------------------- 245 set langmenu=zh_CN 246 let $LANG = 'zh_CN.UTF-8' 247 source $VIMRUNTIME/delmenu.vim 248 source $VIMRUNTIME/menu.vim 249 250 source $VIMRUNTIME/vimrc_example.vim 251 source $VIMRUNTIME/mswin.vim 252 behave mswin 253 "----------------------------------- 254 255 " 256 "vim 提示信息乱码解决方法 257 "language messages zh_CN.UTF-8 258 if has("win32") 259 set termencoding=chinese 260 language message zh_CN.UTF-8 261 endif
windows _vimrc
1 " All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by  2 " the call to :runtime you can find below.  If you wish to change any of those  3 " settings, you should do it in this file (/etc/vim/vimrc), since debian.vim  4 " will be overwritten everytime an upgrade of the vim packages is performed.  5 " It is recommended to make changes after sourcing debian.vim since it alters  6 " the value of the 'compatible' option.  7   8 " This line should not be removed as it ensures that various options are  9 " properly set to work with the Vim-related packages available in Debian. 10 runtime! debian.vim 11 " Uncomment the next line to make Vim more Vi-compatible 12 " NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous 13 " options, so any other options should be set AFTER setting 'compatible'. 14 "set compatible 15  16 " Vim5 and later versions support syntax highlighting. Uncommenting the next 17 " line enables syntax highlighting by default. 18 if has("syntax") 19   syntax on 20 endif 21  22 " If using a dark background within the editing area and syntax highlighting 23 " turn on this option as well 24 "set background=dark 25  26 " Uncomment the following to have Vim jump to the last position when 27 " reopening a file 28 "if has("autocmd") 29 "  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif 30 "endif 31  32 " Uncomment the following to have Vim load indentation rules and plugins 33 " according to the detected filetype. 34 "if has("autocmd") 35 "  filetype plugin indent on 36 "endif 37  38 " The following are commented out as they cause vim to behave a lot 39 " differently from regular Vi. They are highly recommended though. 40 set showcmd        " Show (partial) command in status line. 41 set showmatch        " Show matching brackets. 42 "set ignorecase        " Do case insensitive matching 43 "set smartcase        " Do smart case matching 44 "set incsearch        " Incremental search 45 set autowrite        " Automatically save before commands like :next and :make 46 "set hidden        " Hide buffers when they are abandoned 47 "set mouse=a        " Enable mouse usage (all modes) 48  49 " Source a global configuration file if available 50 if filereadable("/etc/vim/vimrc.local") 51   source /etc/vim/vimrc.local 52 endif 53  54 set nu 55 set tabstop=4 56 set softtabstop=4 57 set shiftwidth=4 58 "set smartindent 59 set cursorline 60 set ruler 61 "set autoindent 62 set showcmd 63 set formatoptions=tcrqn    "自动格式化 64 set clipboard+=unnamed 65 set autowrite 66 "set confirm 67 set smarttab 68 set history=1000 69 set autoread 70 "禁止生成临时文件 71 set nobackup 72 set noswapfile 73  74 set foldenable    "允许折叠 75 set foldmethod=manual    "手动折叠 76  77 " 匹配括号高亮的时间(单位是十分之一秒) 78 set matchtime=1 79  80 set backspace=2 81 " 允许backspace和光标键跨越行边界 82  83 map
:call AddHeader()
84 "auto BufNewFile *.cpp exec ":call AddHeader()" 85 func AddHeader() 86 if &filetype == 'cpp' 87 call setline(line("."),"#include
") 88 let l=line(".")-1 89 let l=l+1 | call append(l,"#include
") 90 let l=l+1 | call append(l,"#include
") 91 let l=l+1 | call append(l,"#include
") 92 let l=l+1 | call append(l,"#include
") 93 let l=l+1 | call append(l,"#include
") 94 let l=l+1 | call append(l,"#include
") 95 let l=l+1 | call append(l,"#include
") 96 let l=l+1 | call append(l,"#include
") 97 let l=l+1 | call append(l,"#include
") 98 let l=l+1 | call append(l,"#include
") 99 endif100 autocmd BufNewFile * normal Gkkk101 endfunc102 103 auto BufNewFile *.cpp exec ":call Addline()"104 map
:call Addline()
105 func Addline()106 if &filetype == 'cpp'107 call setline(line("."),"#include
")108 let l=line(".")-1109 let l=l+1 | call append(l,"using namespace std;")110 let l=l+1 | call append(l,"typedef long long LL;")111 let l=l+1 | call append(l,"const int N=1e5+10;")112 let l=l+1 | call append(l,"const int INF=0x3f3f3f3f;")113 let l=l+1 | call append(l,"int cas=1,T;")114 let l=l+1 | call append(l,"int main()")115 let l=l+1 | call append(l,"{")116 let l=l+1 | call append(l,"// freopen(\"1.in\",\"w\",stdout);")117 let l=l+1 | call append(l,"// freopen(\"1.in\",\"r\",stdin);")118 let l=l+1 | call append(l,"// freopen(\"1.out\",\"w\",stdout);")119 let l=l+1 | call append(l,"// scanf(\"%d\",&T);")120 let l=l+1 | call append(l,"// cerr<<\"time=\"<<(double)clock()/CLOCKS_PER_SEC<
w :w!
142 nmap
f :find
143 "映射全选+复制 ctrl+a144 map
ggVGY145 "map!
ggVGY146 map
gg=G147 "选中状态下 ctrl+c 复制148 vmap
"+y149 map P "+p150 map zz 0i//
151 map tt 0lli
152 153 "C,C++ 按F5编译运行154 map
:call CompileRunGcc()
155 func! CompileRunGcc()156 :w157 if &filetype == 'c'158 :! gcc % -o %<159 :! ./%<160 elseif &filetype == 'cpp'161 :! g++ -std=c++11 % -o %<162 :! ./%<163 ":!g++ -std=c++11 % -o G:/exe/%<164 ":! G:/exe/%<.exe165 elseif &filetype == 'java' 166 :! javac % 167 :! java %<168 elseif &filetype == 'sh'169 :! bash %170 elseif &filetype == 'html'171 :! chrome %172 ":! chrome G:/cpp/%173 elseif &filetype == 'python'174 :! python3 %175 ":!python G:/cpp/%176 elseif &filetype == 'javascript'177 :! node %178 elseif &filetype == 'go'179 :! go run %180 endif181 endfunc182 183 " getline('.')获取当前行字符串 line('.')获取当前行行号184 " col('.')获取当前列号185 "自动补全186 "inoremap ( ()
187 "inoremap )
=ClosePair(')')
188 "inoremap { {}
189 "inoremap }
=ClosePair('}')
190 "inoremap [ []
191 "inoremap ]
=ClosePair(']')
192 "inoremap
=Line('}')
193 "inoremap "
=Pair('"')
194 "inoremap '
=Pair("\'")
195 function! Line(char)196 if getline('.')[col('.')-1] == a:char197 return "\
\
\
\t"198 else199 return "\
"200 endif201 endfunction202 function! Pair(char)203 if getline('.')[col('.')-1] == a:char204 return "\
"205 else206 let s=a:char.a:char."\
"207 return s208 endif209 endfunction210 function! ClosePair(char)211 if getline('.')[col('.') - 1] == a:char212 return "\
"213 else214 return a:char215 endif216 endfunction217 filetype plugin indent on 218 "打开文件类型检测, 加了这句才可以用智能补全219 set completeopt=longest,menu220 """"""""""""""""""""""""'""221 222 " 显示相关 223 " """""""""""""""""""224 set shortmess=atI " 启动的时候不显示那个援助乌干达儿童的提示 225 winpos -4 -4 " 设定窗口位置 226 set lines=40 columns=170 " 设定窗口大小 227 " "set nu " 显示行号 228 " set go= " 不要图形按钮 229 colorscheme desert " 设置背景主题 230 set guifont=Consolas:h14:cANSI " 设置字体 231 " "syntax on " 语法高亮 232 " autocmd InsertLeave * se nocul " 用浅色高亮当前行 233 "autocmd InsertEnter * se cul " 用浅色高亮当前行 234 " "set ruler " 显示标尺 235 " set showcmd " 输入的命令显示出来,看的清楚些 236 set cmdheight=1 " 命令行(在状态行下)的高度,设置为1 237 "set whichwrap+=<,>,h,l " 允许backspace和光标键跨越行边界(不建议) 238 set scrolloff=10 " 光标移动到buffer的顶部和底部时保持3行距离 239 "set novisualbell " 不要闪烁(不明白) 240 " set statusline=%F%m%r%h%w\ [FORMAT=%{241 " &ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{242 " strftime(\"%d/%m/%y\ -\ %H:%M\")} "状态行显示的内容 243 " set laststatus=1 " 启动显示状态行(1),总是显示状态行(2) 244 " set foldenable " 允许折叠 245 " set foldmethod=manual " 手动折叠 246 "set background=dark "背景使用黑色 247 " set nocompat248 "249 250 " 解决菜单乱码 251 "----------------------------------- 252 set langmenu=zh_CN 253 let $LANG = 'zh_CN.UTF-8' 254 source $VIMRUNTIME/delmenu.vim 255 source $VIMRUNTIME/menu.vim 256 257 "source $VIMRUNTIME/vimrc_example.vim 258 "source $VIMRUNTIME/mswin.vim 259 behave mswin 260 "----------------------------------- 261 262 " 263 "vim 提示信息乱码解决方法 264 "language messages zh_CN.UTF-8 265 if has("win32") 266 set termencoding=chinese 267 language message zh_CN.UTF-8 268 endif 269 270 271 "taglist272 let Tlist_Show_One_File=1273 let Tlist_Exit_OnlyWindow=1274 "winmanager275 let g:winManagerWindowLayout='FileExplorer|TagList'276 nmap wm :WMToggle
ubuntu .vimrc

 

转载于:https://www.cnblogs.com/cdyboke/p/4919018.html

你可能感兴趣的文章
A股主要指数的市盈率(PE)估值高度
查看>>
mysql语法备忘
查看>>
文件操作
查看>>
dockerfile
查看>>
2. Struts2 基础
查看>>
python-字典
查看>>
排序算法的个人心得体会。
查看>>
Spring—Ioc
查看>>
3:2 OGNL 简介
查看>>
android的消息处理机制(图+源码分析)——Looper,Handler,Message
查看>>
WCF的用户名+密码认证方式
查看>>
Spring 读取配置文件(一)
查看>>
FTP文件夹打开错误,Windows无法访问此文件夹
查看>>
UVALive - 3700 Interesting Yang Hui Triangle
查看>>
HDU - 1205 吃糖果
查看>>
正确实现 IDisposable 接口
查看>>
移动平均(moving average,MA)简单介绍
查看>>
模型驱动复习整理
查看>>
自我介绍及软件工程学习计划
查看>>
PLC状态机编程第三篇-RS信号处理
查看>>