windows下的vimrc

Posted h-riven

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了windows下的vimrc相关的知识,希望对你有一定的参考价值。

很奇怪的事...不会解释

建议编译位置第一次设置为

map <F9> :call CR()<CR>
func! CR()
exec "w"
exec "!g++ -std=c++11 % -o %<"
exec "!gdb %<.exe"
endfunc

然后运行一次过后在设置为如下代码

技术图片
set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8
set fileformats=unix
set encoding=prc

source $VIMRUNTIME/vimrc_example.vim
behave xterm

set diffexpr=MyDiff()
function MyDiff()
  let opt = -a --binary 
  if &diffopt =~ icase | let opt = opt . -i  | endif
  if &diffopt =~ iwhite | let opt = opt . -b  | endif
  let arg1 = v:fname_in
  if arg1 =~   | let arg1 = " . arg1 . " | endif
  let arg1 = substitute(arg1, !, !, g)
  let arg2 = v:fname_new
  if arg2 =~   | let arg2 = " . arg2 . " | endif
  let arg2 = substitute(arg2, !, !, g)
  let arg3 = v:fname_out
  if arg3 =~   | let arg3 = " . arg3 . " | endif
  let arg3 = substitute(arg3, !, !, g)
  if $VIMRUNTIME =~  
    if &sh =~ <cmd
      if empty(&shellxquote)
        let l:shxq_sav = ‘‘
        set shellxquote&
      endif
      let cmd = " . $VIMRUNTIME . diff"
    else
      let cmd = substitute($VIMRUNTIME,  , " , ‘‘) . diff"
    endif
  else
    let cmd = $VIMRUNTIME . diff
  endif
  let cmd = substitute(cmd, !, !, g)
  silent execute ! . cmd .   . opt . arg1 .   . arg2 .  >  . arg3
  if exists(l:shxq_sav)
    let &shellxquote=l:shxq_sav
  endif
endfunction

"共享剪贴板  
set clipboard =unnamed,unnamedplus
" 语法高亮
syntax on
colorscheme industry

inoremap  ‘‘<ESC>i
inoremap " ""<ESC>i
inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {<CR>}<ESC>O
inoremap ) <c-r>=ClosePair())<CR>
inoremap } <c-r>=ClosePair(})<CR>
inoremap ] <c-r>=ClosePair(])<CR>
function! ClosePair(char)
    if getline(.)[col(.) - 1] == a:char
        return "<Right>"
    else
        return a:char
    endif
endfunction
filetype plugin indent on 
""""""""""""""""""""""""""""""""""键盘设置""""""""""""""""""""""""""""""""""""
" F2 行号开关,用于鼠标复制代码用
" 为方便复制,用<F2>开启/关闭行号显示:
function! HideNumber()
  if(&relativenumber == &number)
    set relativenumber! number!
  elseif(&number)
    set number!
  else
    set relativenumber!
  endif
  set number?
endfunc
nnoremap <F2> :call HideNumber()<CR>

"F9编译"
map <F9> :call CR()<CR>
func! CR()
exec "w"
exec "!g++ -std=c++11 % -o %<"
exec "!%<.exe"
endfunc
""""""""""""""""""""""""""""""""""显示""""""""""""""""""""""""""""""""""""
"设置编码"
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936
set fileencoding=utf-8
" 允许backspace和光标键跨越行边界
set whichwrap=<,>,[,],h,l
"显示行号"
set nu
"当前行"
"set cursorline
"使用鼠标"
set mouse=a
set selection=exclusive
set selectmode=mouse,key
set listchars=tab:>-,trail:-
" 显示中文帮助
if version >= 603
    set helplang=cn
    set encoding=utf-8
endif
set magic                   " 设置魔术
set guioptions-=T           " 隐藏工具栏
set guioptions-=m           " 隐藏菜单栏
"总是显示状态栏"
set laststatus=2
" 高亮显示匹配的括号
set showmatch
" 匹配括号高亮的时间(单位是十分之一秒)
hi MatchParen ctermbg=blue guibg=lightblue
set matchtime=5
"显示光标当前位置"
set ruler
" 我的状态行显示的内容(包括文件类型和解码)
set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%]
set cmdheight=2
""""""""""""""""""""""""""""""""""使用""""""""""""""""""""""""""""""""""""
"自动缩进
set autoindent     ""自动缩进
set cindent        ""以C语言的方式缩进
set shiftwidth=4   ""设置自动缩进的空格数量
set softtabstop=4  ""tab键的实际占有空格数,统一缩进
set tabstop=4      ""设置tab键的空格数
set smarttab       ""在行和段开始处使用制表符
"代码补全 
set completeopt=preview,menu 
"从不备份  
set nobackup
"允许插件  
" 侦测文件类型
filetype on
" 载入文件类型插件
filetype plugin on
" 保存全局变量
set viminfo+=!
" 带有如下符号的单词不要被换行分割
set iskeyword+=_,$,@,%,#,-
" 字符间插入的像素行数目
set linespace=0
" 增强模式中的命令行自动完成操作
set wildmenu
" 使回格键(backspace)正常处理indent, eol, start等
set backspace=2
" 通过使用: commands命令,告诉我们文件的哪一行被改变过
set report=0
" 在被分割的窗口间显示空白,便于阅读
set fillchars=vert: ,stl: ,stlnc:" 光标移动到buffer的顶部和底部时保持3行距离
set scrolloff=3
"禁止生成临时文件
set nobackup
set noswapfile
" 设置当文件被改动时自动载入
set autoread
"自动保存
set autowrite
"允许插件  
filetype plugin on
" 历史记录数
set history=1000
" 在处理未保存或只读文件的时候,弹出确认
set confirm
"搜索忽略大小写
set ignorecase
"搜索逐字符高亮
set hlsearch
set incsearch
"行内替换
set gdefault
" 相对行号: 行号变成相对,可以用 nj/nk 进行跳转
set relativenumber number
au FocusLost * :set norelativenumber number
au FocusGained * :set relativenumber
" 插入模式下用绝对行号, 普通模式下用相对
autocmd InsertEnter * :set norelativenumber number
autocmd InsertLeave * :set relativenumber
" 复制选中区到系统剪切板中
vnoremap <leader>y "+y
" 打开自动定位到最后编辑的位置, 需要确认 .viminfo 当前用户可写
if has("autocmd")
  au BufReadPost * if line("‘"") > 1 && line("‘"") <= line("$") | exe "normal! g‘"" | endif
endif
"""""""""""""""""""""""""""""""""新文件标题""""""""""""""""""""""""""""""""""""
"新建.c,.h,.sh,.java文件,自动插入文件头 
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()" 
""定义函数SetTitle,自动插入文件头 
func SetTitle()
    "如果文件类型为.sh文件 
    if &filetype == sh 
        call setline(1,"###############################################################") 
        call append(line("."), "# File Name    : ".expand("%")) 
        call append(line(".")+1, "# Author       : Jiaaaaaaaqi") 
        call append(line(".")+2, "# Created Time : ".strftime("%c")) 
        call append(line(".")+3, "###############################################################") 
        call append(line(".")+4, "#!/bin/bash") 
    else 
        call setline(1, "/***************************************************************") 
        call append(line("."), "    > File Name    : ".expand("%")) 
        call append(line(".")+1, "    > Author       : Jiaaaaaaaqi") 
        call append(line(".")+2, "    > Created Time : ".strftime("%c")) 
        call append(line(".")+3, " ***************************************************************/") 
        call append(line(".")+4, "")
    endif
    if &filetype == cpp
        call append(line(".")+5, "#include <map>")
        call append(line(".")+6, "#include <set>")
        call append(line(".")+7, "#include <list>")
        call append(line(".")+8, "#include <ctime>")
        call append(line(".")+9, "#include <cmath>")
        call append(line(".")+10, "#include <stack>")
        call append(line(".")+11, "#include <queue>")
        call append(line(".")+12, "#include <cfloat>")
        call append(line(".")+13, "#include <string>")
        call append(line(".")+14, "#include <vector>")
        call append(line(".")+15, "#include <cstdio>")
        call append(line(".")+16, "#include <bitset>")
        call append(line(".")+17, "#include <cstdlib>")
        call append(line(".")+18, "#include <cstring>")
        call append(line(".")+19, "#include <iostream>")
        call append(line(".")+20, "#include <algorithm>")
        call append(line(".")+21, "#define  lowbit(x)  x & (-x)")
        call append(line(".")+22, "#define  mes(a, b)  memset(a, b, sizeof a)")
        call append(line(".")+23, "#define  fi         first")
        call append(line(".")+24, "#define  se         second")
        call append(line(".")+25, "#define  pii        pair<int, int>")
        call append(line(".")+26, "")
        call append(line(".")+27, "typedef unsigned long long int ull;")
        call append(line(".")+28, "typedef long long int ll;")
        call append(line(".")+29, "const int    maxn = 1e5 + 10;")
        call append(line(".")+30, "const int    maxm = 1e5 + 10;")
        call append(line(".")+31, "const ll     mod  = 1e9 + 7;")
        call append(line(".")+32, "const ll     INF  = 1e18 + 100;")
        call append(line(".")+33, "const int    inf  = 0x3f3f3f3f;")
        call append(line(".")+34, "const double pi   = acos(-1.0);")
        call append(line(".")+35, "const double eps  = 1e-8;")
        call append(line(".")+36, "using namespace std;")
        call append(line(".")+37, "")
        call append(line(".")+38, "int n, m;")
        call append(line(".")+39, "int cas, tol, T;")
        call append(line(".")+40, "")
        call append(line(".")+41, "int main() {")
        call append(line(".")+42, "")
        call append(line(".")+43, "}")
        call append(line(".")+44, "")
    endif
endfunc 
    "新建文件后,自动定位到文件末尾
    autocmd BufNewFile * normal G
View Code

 

以上是关于windows下的vimrc的主要内容,如果未能解决你的问题,请参考以下文章

vimrc文件配置的全文收录(史上最全,附带中文解释)

vim代码片段插件ultisnips的使用

VIM 代码片段插件 ultisnips 使用教程

配置linux下的vimrc

vim基本操作

在Tomcat的安装目录下conf目录下的server.xml文件中增加一个xml代码片段,该代码片段中每个属性的含义与用途