我自己 vimrc 配置
" Get the defaults that most users want.
source $VIMRUNTIME/vimrc_example.vim
" set nocompatible " be iMproved, required
" syntax on
set fileformat=unix
filetype off " required
" 起头为空格比较方便
let mapleader = ' '
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" 配置 vundle
Plugin 'https://gitee.com/rpbf/Vundle.vim.git'" 配置 the-nerd-tree
Plugin 'https://gitee.com/spf13plugin/nerdtree.git'
"NERDTree 配置:F2快捷键显示当前目录树
map <Leader>q :NERDTreeToggle<CR>
" 设置窗口宽度
let NERDTreeWinSize=32
" 配置颜色方案
Plugin 'tomasr/molokai'
" tab智能补全
Plugin 'ervandew/supertab'
call vundle#end() " required
filetype plugin indent on " required" 行号
set nu
set relativenumber" 自动格式化选项,选项意思自己 :help fo-table
set formatoptions=tcqmM
" 映射回车为空白行
nmap <CR> o<Esc>
" 下面5行为方便一键缩进 gg=G ,
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
set softtabstop=4
" :sn == :set nonu no number
ab sn set nonu
" 映射 括号
: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 " <c-r>=ClosePair('"')<CR>
:inoremap '' ''<ESC>i
:inoremap ' <c-r>=ClosePair("'")<CR>
function! ClosePair(char)if getline('.')[col('.') - 1] == a:charreturn "\<Right>"elsereturn a:charendif
endfunction
" 映射 fj 到 esc
:vnoremap fj <esc>
:inoremap fj <esc>
" 开始折叠
set foldenable
" 设置语法折叠
" set foldmethod=syntax
set foldmethod=indent
" 设置折叠区域的宽度
set foldcolumn=0
" 设置折叠层数为
setlocal foldlevel=1
" 打开文件是默认不折叠代码
set foldlevelstart=99
" 设置为自动关闭折叠
"set foldclose=all
" 用空格键+逗号来开关折叠, 用 za 就行
" nnoremap <Leader>, @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
" Quickly edit/reload the vimrc file
nnoremap <Leader>ev :tabe $MYVIMRC<CR>
nnoremap <Leader>t :terminal<CR>
" 设置背景为黑色
" set bg=dark"文件编码模式指定utf
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
"语言设置
"set langmenu=zh_CN.UTF-8
"set helplang=cn
" 我的状态行显示的内容(包括文件类型和解码)
" set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
set statusline=%F%m%r%h%w%=\ [ft=%Y]\ %{\"[fenc=\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\"+\":\"\").\"]\"}\ [ff=%{&ff}]\ [asc=%03.3b]\ [hex=%02.2B]\ [pos=%04l,%04v][%p%%]\ [len=%L]
" set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%]
" 总是显示状态行
set laststatus=2
" 命令行(在状态行下)的高度,默认为1,这里是2
set cmdheight=2
"设置不产生swp文件
set nobackup
" 自动切换目录
set autochdir
" 翻屏
map <Leader>f <c-f>
map <Leader>b <c-b>
" 映射跳转窗口
map <Leader>h <c-w>h
map <Leader>j <c-w>j
map <Leader>k <c-w>k
map <Leader>l <c-w>l
" resize window
map <Leader>= <c-w>=
map <Leader>+ <c-w>+
map <Leader>- <c-w>-
map <Leader>> <c-w>>
map <Leader>< <c-w><
" specified window heigt
map <Leader>_ <c-w>_
" specified window width
map <Leader>\| <c-w>\|
" 0 is home
map <Leader>0 <END>
" 退出
map :q :q!
" 保存全局变量
set viminfo+=!
" 带有如下符号的单词不要被换行分割
set iskeyword+=_,$,@,%,#,-
" 不换行
" set nowrap
" 字符间插入的像素行数目
set linespace=0
" 增强模式中的命令行自动完成操作
set wildmenu
" 使回格键(backspace)正常处理indent, eol, start等
set backspace=2
" 允许backspace和光标键跨越行边界
set whichwrap+=<,>,h,l
" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
" set mouse=a
" set selection=exclusive
" set selectmode=mouse,key
" 告诉我们文件的哪一行被改变过,可以通过:h report
set report=0
" 在被分割的窗口间显示空白,便于阅读
set fillchars=vert:\ ,stl:\ ,stlnc:\
" 插入括号时,匹配用
set showmatch
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=1
" 光标移动到buffer的顶部和底部时保持3行距离
set scrolloff=3
" 默认回到上次编辑的地方
" au BufReadPost * if line("'\"") > 1 | if line("'\"") <= line("$") | exe("norm '\"")|else|exe "norm $"|endif|endif" 搜索设置
" 取消搜索高亮
set nohls
" 一边打字一般搜索
" set incsearch
" 搜索到最后就停了
set nowrapscan" 颜色方案为 molokai
let g:molokai_original = 1
let g:rehash256 = 1
colorscheme molokai
" vim will ignore them
set wildignore=*.o,*~,*.pyc,*.swp,*.bak,*.class,*.DS_Store
" map <space>v to source vimrc
map <Leader>v :w<CR>:source $MYVIMRC<CR>
" search
set ignorecase
set smartcase
" auto write
set autowriteall
" Mode Settings
" SI = INSERT mode
let &t_SI.="\e[5 q"
" SR = REPLACE mode
let &t_SR.="\e[4 q"
" EI = NORMAL mode
let &t_EI.="\e[1 q"
" put undofile in .undodir directory
set undodir=~/.undodir
目录 ~/.vim/
.
├── bundle
│ ├── molokai
│ ├── nerdtree
│ ├── supertab
│ └── Vundle.vim
├── colors
│ └── molokai.vim
└── ftplugin├── java.vim└── markdown.vim
java.vim
:inoremap { {<CR>}<ESC>O
:inoremap sout System.out.print
:inoremap psvm public static void main(String[] args)" map ,r to run java
map <Leader>r :call CompileRun()<CR>
function! CompileRun()exec "w"exec "!javac %"exec "!java %<"
endfunction
" 在插入模式下输入 xtime 生成格式化时间
" ab 缩写 abbreviation
iab xtime <c-r>=strftime("%Y-%m-%d %H:%M:%S")
markdown.vim
:inoremap uu ```<CR>```<ESC>O