1 Star 1 Fork 0

luchigster/vimfiles

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
_vimrc 4.78 KB
一键复制 编辑 原始数据 按行查看 历史
luchigster 提交于 2014-12-24 15:45 . 增加全局配置文件
source $VIMRUNTIME/vimrc_example.vim
"set nobackup "不备份文件,不产生~文件
if has("win32")
set backupdir=c:/tmp "转移备份文件存储路径
endif
"Set mapleader
let mapleader = ","
let g:mapleader = ","
"设置颜色方案
colorscheme desert
"Highlight Syntax
if has("syntax")
syntax on
endif
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"开启了Vim的三种智能:
"1. 自动识别文件类型
"2. 用文件类型plugin脚本
"3. 使用缩进定义文件 编辑程序的时候, 语句的缩进可以让它自动完成
filetype plugin indent on
"开启文件类型侦测
filetype on
"根据侦测到的不同类型加载对应的插件
filetype plugin on
"根据侦测到的不同类型采用不同的缩进格式
filetype indent on
"取消补全内容以分割子窗口形式出现,只显示补全列表
set completeopt=longest,menu
"启用new-omni-completion
set ofu=syntaxcomplete#Complete
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set nocompatible
"set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
"set smartcase " Do smart case matching
set incsearch " Incremental search
set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
set mouse=a " Enable mouse usage (all modes)
" 允许退格键删除和tab操作
set smartindent
set smarttab
set expandtab
set backspace=2
set textwidth=79
" 不讨论制表符为8 还是为4 较好,这里设置(软)制表符宽度为4
set tabstop=4
set softtabstop=4
" 设置缩进的空格数为4
set shiftwidth=4
" 设置自动缩进:即每行的缩进值与上一行相等;使用 noautoindent 取消设置
set autoindent
" 设置C/C++语言的具体缩进方式
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
" 左侧显示文本的行号
set nu
"设置文件格式
"unix <LF>
"dos <CR><LF>
"mac <CR>
set fileformats=dos
"设置中文编码
if has("multi_byte")
"终端编码,终端处理文本或表示文本时所使用的编码.
if &termencoding == ""
let &termencoding = &encoding
endif
"Vim 的内部编码,Vim在处理文本或表示文本时所使用的编码.
set encoding=utf-8
"Vim 打开文件时的尝试使用的编码.
set fileencodings=ucs-bom,utf-8,chinese,latin1
"文件编码,就是文件的数据在磁盘中存储所使用的编码.
if has("win32")
set fileencoding=chinese
"宽度“不明”的字符宽度置为双倍字符宽度(中文字符宽度)
set ambiwidth=double
else
set fileencoding=utf-8
endif
endif
"解决菜单乱码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"解决consle输出乱码
language messages zh_CN.utf-8
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
" 括号自动补全
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap ' ''<ESC>i
:inoremap " ""<ESC>i
function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return ")"
else
return a:char
endif
endfunction
"按两下,即可返回普通模式<ESC>
inoremap <leader><leader> 
"绑定保存快捷键
nnoremap  :w<CR>
inoremap <leader> :w<CR>a
"绑定粘贴快捷键
inoremap <leader>p p
inoremap <leader>P P
"绑定撤销/恢复快捷键
inoremap <leader><C-z> ua
inoremap <leader><C-y> a
"折叠方法,用标计marker来标识代码的折叠,系统默认是{{{和}}}
set foldmethod=marker
"Windows下的复制粘贴
map <C-c> "+y
map <C-v> "+P
inoremap <leader><C-v> "+pa
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
VimL
1
https://gitee.com/luchigster/vimfiles.git
git@gitee.com:luchigster/vimfiles.git
luchigster
vimfiles
vimfiles
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385