我的gvim配置

功能简介:
alt+8 设置透明度高
alt+9 设置透明度较高
alt+0 设置透明度较低
alt+1 设置为不透明
ctrl+a 全选
ctrl+c 复制
ctrl+v 粘贴
ctrl+s 保存
alt+m 注释该行
alt+F5/F6/F7/F8 边框大小调整
F8 g++编译、报错
F9 g++编译后运行
F12 多窗口编辑
F6 运行python程序
F3 Grep
ctrl+j/k/h/l 大幅度移动光标
F2 tex文件中xelatex编译
shift+F2 tex文件中pdflatex编译

" REQUIRED. This makes vim invoke latex-suite when you open a tex file.
filetype plugin on
" IMPORTANT: win32 users will need to have 'shellslash' set so that latex
" can be called correctly.
set shellslash
" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse latex-suite. Set your grep
" program to alway generate a file-name.
set grepprg=grep\ -nH\ $*
" OPTIONAL: This enables automatic indentation as you type.
filetype indent on
" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vi	  m-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'
let g:Tex_FormatDependency_pdf = 'dvi,ps,pdf'
let g:Tex_CompileRule_dvi = 'latex --interaction=nonstopmode $*'
let g:Tex_CompileRule_ps = 'dvips -Ppdf -o $*.ps $*.dvi'
let g:Tex_CompileRule_pdf = 'ps2pdf $*.ps'
let g:Tex_ViewRule_pdf = 'd:/SumatraPDF/SumatraPDF.exe'
let g:Tex_ViewRule_pdfs = 'd:/SumatraPDF/SumatraPDF.exe'
let g:Tex_ViewRule_pdfm = 'd:/SumatraPDF/SumatraPDF.exe'
let g:Tex_ViewRule_pdfx = 'd:/SumatraPDF/SumatraPDF.exe'

set fileencodings=ucs-bom,utf-8,chinese,cp936
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
"消除声音
set visualbell t_vb=  "关闭visual bell
au GuiEnter * set t_vb= "关闭beep
"设置魔术(不知道)
set magic

"不要使用vi的键盘模式,而是vim自己的
set nocompatible

"支持256色,使得vim配色支持终端
set t_Co=256

"C缩进
set smartindent
set cindent

"在处理未保存或只读文件的时候,弹出确认
set confirm

"语法高亮
syntax enable
syntax on

"不要备份文件
set nobackup

"不要生成swap文件
set noswapfile

"在状态行上显示光标所在位置的行号和列号
set ruler

"命令行(在状态行下)的高度,默认为1,这里是2
set cmdheight=1

"使回格键(backspace)正常处理indent,eol,start等
set backspace=indent,eol,start

"不让vim发出讨厌的滴滴声
set noerrorbells

"高亮显示匹配的括号(不好用)
"set showmatch

"在搜索时,输入的词句的逐字符高亮
set incsearch

"2为总显示最后一个窗口的状态行
"设为1则窗口数多于一个的时候显示最后一个窗口的状态行;
"0不显示最后一个窗口的状态行
set laststatus=2

"继承前一行的缩进方式,特别适用于多行注释
set autoindent

"显示行号
set number

"制表符为4
set tabstop=4

"统一缩进为4
set softtabstop=4
set shiftwidth=4

"不要用空格代替制表符
set noexpandtab

"在行和段开始处使用制表符
set smarttab

"高亮被搜索的句子
set hlsearch

"突出显示当前行
set cursorline

"突出显示当前列
set cursorcolumn

"不要图形按钮
set go=

"自动保存
set autowrite

"文件在Vim之外修改过,自动重新读入
set autoread

"自动切换当前目录为当前文件所在的目录
set autochdir

"设置背景和字体
color candy 
set guifont=Consolas:h15:cANSI
set guifontwide=KaiTi:h15:cANSI

set background=dark


map <A-4> <Esc>:call Quick1()<cr>
function! Quick1()
	set guifont=Consolas:h13:cANSI
endfunction
map <A-5> <Esc>:call Quick2()<cr>
function! Quick2()
	set guifont=Consolas:h15:cANSI
endfunction

"设置透明度
au GUIEnter * call libcallnr ( "vimtweak.dll" , "SetAlpha" , 210 ) 
map <A-8> <Esc>:call libcallnr("vimtweak.dll", "SetAlpha", 90)<CR>
map <A-9> <Esc>:call libcallnr("vimtweak.dll", "SetAlpha", 170)<CR>
map <A-0> <Esc>:call libcallnr("vimtweak.dll", "SetAlpha", 220)<CR>
map <A-1> <ESC>:call libcallnr("vimtweak.dll", "SetAlpha", 255)<CR>

let mapleader="-"

map <leader>as 1GVG"+y

"Ctrl+a全选,Ctrl+c复制,Ctrl+v粘贴,Ctrl+s保存
"全选
map <C-a> <Esc>ggVG
"复制
vmap <C-c> "+y<Esc>
"保存
map <C-s> :w!<CR>
imap <C-s> <Esc>:w!<CR>
"粘贴
map <C-v> "+p
imap <C-v> <Esc>"+p<i>
"注释
map <A-m> I//<Esc>

"边框大小调整
map <A-F5> <c-w>+
map <A-F6> <c-w>-
map <A-F7> <c-w><
map <A-F8> <c-w>>

"大幅度移动光标
map <C-j> 6j
map <C-h> 6h
map <C-k> 6k
map <C-l> 6l

"映射一个快捷键
map <Space> <C-w>
map Y "+y
map P "+gP

map <F8> :call Quick_Fix()<cr>
imap <F8> <Esc><F8>

map <F9> :call Compile_Run_Cpp()<cr>
map <C-F9> :call Compile_Run_Cpp_O2()<cr>

imap <F9> <Esc><F9>
imap <C-F9> <Esc><C-F9>

map <F12> :call Debug_Mode1()<cr>
map <C-F12> : call Debug_Mode2()<cr>

function! Quick_Fix()
	exec "wall"
	set makeprg=g++\ %\ -o\ %<
	exec "make"
	exec "cw 6"
endfunction

function! Compile_Run_Cpp()
	exec "wall"
	exec "!g++ % -o %<.exe"
	exec "!%<.exe"
endfunction

function! Compile_Run_Cpp_O2()
	exec "wall"
	exec "!g++ % -o %<.exe -O2"
	exec "!%<.exe"
endfunction

function! Debug_Mode1()
	exec "vsp %<.out"
	exec "sp %<.in"
endfunction

function! Debug_Mode2()
	exec "vsp output.out"
	exec "sp input.in"
endfunction

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"按<F2>自动生成代码设置
map <F2> :call SetTitle() <cr>'s

autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()" 
"定义函数SetTitle,自动插入文件头 
function! SetTitle()
		let l = 0
		let l = l + 1 | call setline(1, "/*************************************************************************") 
		let l = l + 1 | call setline(l,"	> File Name: ".expand("%")) 
		let l = l + 1 | call setline(l,"	> Author: Knowledge_llz") 
		let l = l + 1 | call setline(l,"	> Mail: 925538513@qq.com ") 
		let l = l + 1 | call setline(l,"	> Blog: https: https://www.cnblogs.com/Knowledge-Pig/ ") 
		let l = l + 1 | call setline(l,"	> Created Time: ".strftime("%c")) 
		let l = l + 1 | call setline(l," ************************************************************************/") 
		let l = l + 1 | call setline(l,"")
		let l = l + 1 | call setline(l, "#include<bits/stdc++.h>")
		let l = l + 1 | call setline(l, "#define For(i,a,b) for(int i=(a);i<=(b);++i)")
		let l = l + 1 | call setline(l, "#define LL long long")
		let l = l + 1 | call setline(l, "#define pb push_back")
		let l = l + 1 | call setline(l, "#define fi first")
		let l = l + 1 | call setline(l, "#define se second")
		let l = l + 1 | call setline(l, "#define pr pair<int,int>")
		let l = l + 1 | call setline(l, "#define mk(a,b) make_pair(a,b)")
		let l = l + 1 | call setline(l, "using namespace std;")
		let l = l + 1 | call setline(l, "int read(){")
		let l = l + 1 | call setline(l, "	char x=getchar(); int u=0,fg=0;")
		let l = l + 1 | call setline(l, "	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }")
		let l = l + 1 | call setline(l, "	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }")
		let l = l + 1 | call setline(l, "	return fg?-u:u;")
		let l = l + 1 | call setline(l, "}")
		let l = l + 1 | call setline(l, "int main()")
		let l = l + 1 | call setline(l, "{")
		let l = l + 1 | call setline(l, "#ifndef ONLINE_JUDGE")
		let l = l + 1 | call setline(l, "	freopen(\"input.in\", \"r\", stdin);")
		let l = l + 1 | call setline(l, "	freopen(\"output.out\", \"w\", stdout);")
		let l = l + 1 | call setline(l, "#endif")
		let l = l + 1 | call setline(l, "")
		let l = l + 1 | call setline(l, "	return 0;")
		let l = l + 1 | call setline(l, "}")
    "新建文件后,自动定位到文件末尾
    autocmd BufNewFile * normal G
endfunction

"我的状态行显示的内容(包括文件类型和解码)
highlight StatusLine cterm=bold ctermfg=yellow ctermbg=blue
" 获取当前路径,将$HOME转化为~
function! CurDir()
		let curdir = substitute(getcwd(), $HOME, "~", "g")
		return curdir
endfunction
set statusline=%f%m%r%h%=%l/%L,%c\ %p%%\ \[%b\] 
"set statusline=[%n]\ %f%m%r%h\ \|\ %{CurDir()}\ \|%=[Line:%l/%L,Column:%c][%p%%]\ \|\ ASCII=%b\ \|%{strftime(\"%y/%m/%d\ -\ %H:%M\")}

map <F6> :!py %<cr>
imap <F6> <Esc><F6>
nnoremap <silent> <F3> :Grep<CR>
posted @ 2020-11-28 23:51  Knowledge-Pig  阅读(369)  评论(0编辑  收藏  举报