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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
| set nocompatible source $VIMRUNTIME/vimrc_example.vim source $VIMRUNTIME/mswin.vim behave mswin
set encoding=utf-8 fileencodings=utf-8 termencoding=utf-8 "自动识别utf8 source $VIMRUNTIME/delmenu.vim "解决右键乱码 source $VIMRUNTIME/menu.vim "解决consle输出乱码 language messages zh_CN.utf-8
"设置默认保存位置 exec 'cd ' . fnameescape("C:\\Users\\Public\\Desktop") set autochdir "自动识别当前打开文件路径 set autoread " 开启文件监视,外部修改会提示 set pythonthreedll="C:\Program Files\Python38\python38.dll "改成自己的版本 "set pythonthreehome="C:\Program Files\Python38"
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 arg2 = v:fname_new if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif let arg3 = v:fname_out if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif let eq = '' if $VIMRUNTIME =~ ' ' if &sh =~ '\<cmd' let cmd = '""' . $VIMRUNTIME . '\diff"' let eq = '"' else let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"' endif else let cmd = $VIMRUNTIME . '\diff' endif silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq endfunction
filetype on " 打开文件类型检测功能,通过$vimRUNTIME/filetype.vim和$vimRUNTIME/scripts.vim来判断 filetype plugin on " 允许vim加载文件类型插件 filetype indent on " 为不同类型的文件定义不同的缩进格式 syntax on " 高亮 set cindent " C代码里需要的缩排 set smartindent set autoindent " 自动缩进 set tabstop=4 " 修改 tab 字符的显示宽度 set shiftwidth=4 " 自动缩进所使用的空白长度 set softtabstop=4 " tab转换为多少个空格 "set expandtab " tab转换为空格 "set ts=4 "set sw=4 "set sts=4 "缩进 if $OS == 'Windows_NT' set mouse=a else set mouse-=a " Linux鼠标使用 endif color molokai "colo desert "主题 set number " 行号 set cursorline "所在行高亮 set guifont=Consolas:h15 "Linux: set guifont=Consolas\ h16 set backspace=2 set ruler " 显示标尺(光标位置) "set bs=2 set clipboard=unnamed " 共享剪切板 set go= " 不要图形按钮 set nobackup " 不创建备份文件 set noswapfile " 不创建交换文件 set undofile " 保留历史撤销记录 " 保存 undo 历史,生成文件到该目录 set undodir=D:/ProgramData/Vim/.undo_history "set backupdir=~/.vim/.backup// "set directory=~/.vim/.swp "set undodir=~/.vim/.undo/ set spell spelllang=en_us " 拼写检查
" 括号补全 inoremap ( ()<esc>i inoremap [ []<esc>i inoremap { {}<esc>i inoremap ' ''<esc>i inoremap " ""<esc>i " 插入模式按住ctrl的光标移动 inoremap <C-h> <Left> inoremap <C-j> <Down> inoremap <C-k> <Up> inoremap <C-l> <Right>
function! Compile() exec "w" if &filetype == 'python' exec "!python %" elseif &filetype == 'cpp' exec "!g++ % -o %< -std=c++11 -static-libgcc -Wall -g3 -DDEBUG" "exec "!g++ % -o %< -std=c++17 -static-libgcc -Wall -g3 -fexec-charset=GBK -finput-charset=UTF-8" elseif &filetype == 'c' exec "!g++ % -o %<" elseif &filetype == 'kotlin' exec "!kotlinc -d . %" elseif &filetype == 'java' exec "!javac -source 14 %" else exec "!start %" endif endfunction
function! Run() if &filetype == 'kotlin' exec "!kotlin %<Kt" elseif &filetype == 'java' exec "!java %<" elseif &filetype == 'go' exec "!go run %" else exec "!start %<" endif endfunction
function! Open() exec "vsp %<.out" exec "sp %<.in" endfunction
":call libcallnr("vimtweak64.dll", "SetAlpha", 200) au GUIEnter * call libcallnr("vimtweak64.dll", "SetAlpha", 185) "自动透明
syntax enable map<F4> <Esc>:call Open() <CR> imap<F4> <Esc>:call Open() <CR> map<F9> <Esc>:call Compile() <CR> imap<F9> <Esc>:call Compile() <CR> map<F10> <Esc>:call Run() <CR> imap<F10> <Esc>:call Run() <CR> map<F11> <F9> <CR> <F10> <CR> imap<F11> <F9> <CR> <F10> <CR>
" <CTRL>-w m : mark first window " <CTRL>-w m : swap with that window let s:markedWinNum = -1 function! MarkWindowSwap() let s:markedWinNum = winnr() endfunction function! DoWindowSwap() "Mark destination let curNum = winnr() let curBuf = bufnr( "%" ) exe s:markedWinNum . "wincmd w" "Switch to source and shuffle dest->source let markedBuf = bufnr( "%" ) "Hide and open so that we aren't prompted and keep history exe 'hide buf' curBuf "Switch to dest and shuffle source->dest exe curNum . "wincmd w" "Hide and open so that we aren't prompted and keep history exe 'hide buf' markedBuf endfunction function! WindowSwapping() if s:markedWinNum == -1 call MarkWindowSwap() else call DoWindowSwap() let s:markedWinNum = -1 endif endfunction nnoremap <C-w>m :call WindowSwapping()<CR>
" 设置环境保存项 set sessionoptions="blank,buffers,globals,localoptions,tabpages,sesdir,folds,help,options,resize,winpos,winsize" " 保存快捷键 " 定义快捷键的前缀,即<Leader> let mapleader=";" " 敲下;ss即可保存到路径下 map <leader>ss :mksession! D:/ProgramData/Vim/.undo_history/my.vim<cr> :wviminfo! D:/ProgramData/Vim/.undo_history/my.viminfo<cr> " 恢复快捷键 map <leader>rs :source D:/ProgramData/Vim/.undo_history/my.vim<cr> :rviminfo D:/ProgramData/Vim/.undo_history/my.viminfo<cr>
|