windows下的vimrc

时间:2023-12-24 22:40:01

投奔 gvim

" ===
" 设置快捷键
" ===
" inoremap ' ''<ESC>i
" inoremap " ""<ESC>i
" inoremap ( ()<ESC>i
" inoremap [ []<ESC>i
" inoremap { {<CR>}<ESC>O map Z ZZ
map - $
map ^
map S :w<CR>
map tt :tabnew
map tj :tabNext<CR>
map tk :tabnext<CR>
map ot :terminal<CR>
map gt <nop>
map gT <nop> function ToggleMenuBar()
if stridx(&guioptions, "m") =~ -
set guioptions+=m
else
set guioptions-=m
endif
endfunction
nnoremap <F1> :call ToggleMenuBar()<CR> " <F1>开启/关闭菜单栏 function! HideNumber() " <F2>开启/关闭行号显示
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"
if &filetype == 'cpp'
exec "!g++ -std=c++11 -O2 -w % -o %<.exe && %<.exe"
elseif &filetype == 'python'
exec "!python3 %"
endif
endfunc " ===
" 设置编码
" ===
set fencs=utf-,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
set termencoding=utf-
set encoding=utf-
set fileencodings=ucs-bom,utf-,cp936
set fileencoding=utf-
set guifont=Consolas:h14:cANSI:qDRAFT
autocmd GUIEnter * simalt ~x " ===
" === 基本设置
" ===
set nocompatible " 不要使用vi的键盘模式,而是vim自己的
set clipboard =unnamed,unnamedplus " 共享剪贴板
syntax on " 语法高亮
set cursorline
set whichwrap=<,>,[,],h,l " 允许backspace和光标键跨越行边界
set nu " 显示行号
set selection=exclusive
set selectmode=mouse,key
set listchars=tab:>-,trail:-
set magic " 设置魔术
set guioptions-=T " 隐藏工具栏
set guioptions-=m " 隐藏菜单栏
set laststatus= " 总是显示状态栏
set showmatch " 高亮显示匹配的括号
"匹配括号高亮的时间(单位是十分之一秒)
hi MatchParen ctermbg=blue guibg=lightblue
set matchtime=
set ruler " 显示光标当前位置
"我的状态行显示的内容(包括文件类型和解码)
set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%]
set cmdheight=
set autoindent " 自动缩进
set cindent " 以C语言的方式缩进
set shiftwidth= " 设置自动缩进的空格数量
set softtabstop= " tab键的实际占有空格数,统一缩进
set tabstop= " 设置tab键的空格数
set smarttab " 在行和段开始处使用制表符
set mouse=a " 使用鼠标
set completeopt=preview,menu " 代码补全
set nobackup " 从不备份
filetype plugin indent on " 允许插件
filetype on " 侦测文件类型
filetype plugin on " 载入文件类型插件
set viminfo+=! " 保存全局变量
set iskeyword+=_,$,@,%,#,- " 带有如下符号的单词不要被换行分割
set linespace= " 字符间插入的像素行数目
set wildmenu " 增强模式中的命令行自动完成操作
set backspace= " 使回格键(backspace)正常处理indent, eol, start等
set report= " 通过使用: commands命令,告诉我们文件的哪一行被改变过
set fillchars=vert:\ ,stl:\ ,stlnc:\ " 在被分割的窗口间显示空白,便于阅读
set scrolloff= " 光标移动到buffer的顶部和底部时保持3行距离
set nobackup " 禁止生成临时文件
set noswapfile " 禁止生成交换文件
set autoread " 设置当文件被改动时自动载入
set autowrite " 自动保存
set history= " 历史记录数
set confirm " 在处理未保存或只读文件的时候,弹出确认
set ignorecase " 搜索忽略大小写
set hlsearch " 搜索逐字符高亮
set incsearch
set gdefault " 行内替换
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
if has("autocmd") " 打开自动定位到最后编辑的位置, 需要确认 .viminfo 当前用户可写
au BufReadPost * if line("'\"") > && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif " ===
" === vimplug
" ===
call plug#begin() " 中间放插件
Plug 'scrooloose/nerdtree'
Plug 'ddollar/nerdcommenter'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'jiangmiao/auto-pairs'
call plug#end() " ===
" === NERDTree
" ===
let NERDChristmasTree= " 显示增强
let NERDTreeAutoCenter= " 自动调整焦点
let NERDTreeMouseMode= " 鼠标模式:目录单击,文件双击
let NERDTreeShowFiles= " 显示文件
" let NERDTreeShowHidden=1 " 显示隐藏文件
let NERDTreeHightCursorline= " 高亮显示当前文件或目录
let NERDTreeShowLineNumbers= " 显示行号
let NERDTreeWinPos='left' " 窗口位置
let NERDTreeWinSize= " 窗口宽度
let g:NERDTreeCaseSensitiveSort =
let g:nerdtree_tabs_open_on_console_startup=
let NERDTreeIgnore=['\.pyc','\~$','\.swp']
let g:NERDTreeIndicatorMapCustom = {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "═",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔︎",
\ 'Ignored' : '☒',
\ "Unknown" : "?"
\ }
" 快捷键
nnoremap <silent> <F3> :NERDTreeToggle<CR>
set t_Co=
set laststatus=
set lazyredraw " ===
" === airline
" ===
" let g:airline#extensions#tabline#enabled = 1
" let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline_theme="vice"
let g:airline_powerline_fonts = " ===
" === 新文件标题
" ===
" 新建.c,.h,.sh,.java文件,自动插入文件头
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()"
" 定义函数SetTitle,自动插入文件头
func SetTitle()
let l =
if &filetype == 'sh'
let l = l+ | call setline(l,"\###############################################################")
let l = l+ | call setline(l, "\# File Name : ".expand("%"))
let l = l+ | call setline(l, "\# Author : Jiaaaaaaaqi")
let l = l+ | call setline(l, "\# Created Time : ".strftime("%c"))
let l = l+ | call setline(l, "\###############################################################")
let l = l+ | call setline(l, "\#!/bin/bash")
else
let l = l+ | call setline(l, "/*************************************************************** ")
let l = l+ | call setline(l, " > File Name : ".expand("%"))
let l = l+ | call setline(l, " > Author : Jiaaaaaaaqi")
let l = l+ | call setline(l, " > Created Time : ".strftime("%c"))
let l = l+ | call setline(l, " ***************************************************************/")
let l = l+ | call setline(l, "")
endif
if &filetype == 'cpp'
let l = l+ | call setline(l, "#include <map>")
let l = l+ | call setline(l, "#include <set>")
let l = l+ | call setline(l, "#include <list>")
let l = l+ | call setline(l, "#include <ctime>")
let l = l+ | call setline(l, "#include <cmath>")
let l = l+ | call setline(l, "#include <stack>")
let l = l+ | call setline(l, "#include <queue>")
let l = l+ | call setline(l, "#include <cfloat>")
let l = l+ | call setline(l, "#include <string>")
let l = l+ | call setline(l, "#include <vector>")
let l = l+ | call setline(l, "#include <cstdio>")
let l = l+ | call setline(l, "#include <bitset>")
let l = l+ | call setline(l, "#include <cstdlib>")
let l = l+ | call setline(l, "#include <cstring>")
let l = l+ | call setline(l, "#include <iostream>")
let l = l+ | call setline(l, "#include <algorithm>")
let l = l+ | call setline(l, "#include <unordered_map>")
let l = l+ | call setline(l, "#define lowbit(x) x & (-x)")
let l = l+ | call setline(l, "#define mes(a, b) memset(a, b, sizeof a)")
let l = l+ | call setline(l, "#define fi first")
let l = l+ | call setline(l, "#define se second")
let l = l+ | call setline(l, "#define pb push_back")
let l = l+ | call setline(l, "#define pii pair<int, int>")
let l = l+ | call setline(l, "")
let l = l+ | call setline(l, "typedef unsigned long long int ull;")
let l = l+ | call setline(l, "typedef long long int ll;")
let l = l+ | call setline(l, "const int maxn = 1e5 + 10;")
let l = l+ | call setline(l, "const int maxm = 1e5 + 10;")
let l = l+ | call setline(l, "const ll mod = 1e9 + 7;")
let l = l+ | call setline(l, "const ll INF = 1e18 + 100;")
let l = l+ | call setline(l, "const int inf = 0x3f3f3f3f;")
let l = l+ | call setline(l, "const double pi = acos(-1.0);")
let l = l+ | call setline(l, "const double eps = 1e-8;")
let l = l+ | call setline(l, "using namespace std;")
let l = l+ | call setline(l, "")
let l = l+ | call setline(l, "int n, m;")
let l = l+ | call setline(l, "int cas, tol, T;")
let l = l+ | call setline(l, "")
let l = l+ | call setline(l, "int main() {")
let l = l+ | call setline(l, ' // freopen("in", "r", stdin);')
let l = l+ | call setline(l, "")
let l = l+ | call setline(l, " return 0;")
let l = l+ | call setline(l, "}")
let l = l+ | call setline(l, "")
endif
endfunc
" 新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G