开始折腾Ubuntu 14.04 下的GVIM
这次装上了Ubuntu 14.04是有目的的,我要锻炼我在Linux下的生存能力,vim这种神器怎么能少,于是开始了我的折腾vim之旅。话说当年我也是vim的小入门的了,那时是大三,当时已经用了vim做一些开发工作,不过,后来就放下了,这次我会坚持下去。
现在的样式如下:

配置文件如下:
"==========================================
" Initial Plugin 加载插件
"==========================================
" 开启语法高亮
syntax on
" 缩进
filetype plugin indent on
"==========================================
" General Settings 基础设置
"==========================================
" history存储容量
set history=2000
"检测文件类型
filetype on
"针对不同的文件类型采用不同的缩进格式
filetype indent on
"允许插件
filetype plugin on
"启动自动补全
filetype plugin indent on
set autoread " 文件修改之后自动载入。
set shortmess=atI " 启动的时候不显示那个援助索马里儿童的提示
" 备份,到另一个位置. 防止误删, 目前是取消备份
"set backup
"set backupext=.bak
"set backupdir=/tmp/vimbk/
" 取消备份。 视情况自己改
set nobackup
" 关闭交换文件
set noswapfile
"create undo file
set undolevels=1000 " How many undos
set undoreload=10000 " number of lines to save for undo
if v:version >= 730
set undofile " keep a persistent backup file
set undodir=/tmp/vimundo/
endif
set wildignore=*.swp,*.bak,*.pyc,*.class,.svn
" 突出显示当前行等
set cursorcolumn
set cursorline " 突出显示当前行
"设置 退出vim后,内容显示在终端屏幕, 可以用于查看和复制
"好处:误删什么的,如果以前屏幕打开,可以找回
set t_ti= t_te=
"- 则点击光标不会换,用于复制
set mouse-=a " 鼠标暂不启用, 键盘党....
" 修复ctrl+m 多光标操作选择的bug,但是改变了ctrl+v进行字符选中时将包含光标下的字符
"set selection=exclusive
set selection=inclusive
set selectmode=mouse,key
" No annoying sound on errors
" 去掉输入错误的提示声音
set title " change the terminal's title
set novisualbell " don't beep
set noerrorbells " don't beep
set t_vb=
set tm=500
" Remember info about open buffers on close"
set viminfo^=%
" For regular expressions turn magic on
set magic
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
"==========================================
" Display Settings 展示/排版等界面格式设置
"==========================================
"
"显示当前的行号列号:
set ruler
""在状态栏显示正在输入的命令
set showcmd
" 左下角显示当前vim模式
set showmode
" 在上下移动光标时,光标的上方或下方至少会保留显示的行数
set scrolloff=7
" set winwidth=79
" 命令行(在状态行下)的高度,默认为1,这里是2
set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P
" Always show the status line - use 2 lines for the status bar
set laststatus=2
"显示行号:
set number
" 取消换行。
set nowrap
" 括号配对情况,跳转并高亮一下匹配的括号
set showmatch
" How many tenths of a second to blink when matching brackets
set matchtime=2
"设置文内智能搜索提示
" 高亮search命中的文本。
set hlsearch
" 打开增量搜索模式,随着键入即时搜索
set incsearch
" 搜索时忽略大小写
set ignorecase
" 有一个或以上大写字母时仍大小写敏感
set smartcase " ignore case if search pattern is all lowercase, case-sensitive otherwise
" 代码折叠
set foldenable
" 折叠方法
" manual 手工折叠
" indent 使用缩进表示折叠
" expr 使用表达式定义折叠
" syntax 使用语法定义折叠
" diff 对没有更改的文本进行折叠
" marker 使用标记进行折叠, 默认标记是 {{{ 和 }}}
set foldmethod=indent
set foldlevel=99
" 缩进配置
set smartindent " Smart indent
set autoindent " 打开自动缩进
" never add copyindent, case error " copy the previous indentation on autoindenting
" tab相关变更
set tabstop=2 " 设置Tab键的宽度 [等同的空格个数]
set shiftwidth=2 " 每一次缩进对应的空格数
set softtabstop=2 " 按退格键时可以一次删掉 4 个空格
set smarttab " insert tabs on the start of a line according to shiftwidth, not tabstop 按退格键时可以一次删掉 4 个空格
set expandtab " 将Tab自动转化成空格 [需要输入真正的Tab键时,使用 Ctrl+V + Tab]
set shiftround " 缩进时,取整 use multiple of shiftwidth when indenting with '<' and '>'
" A buffer becomes hidden when it is abandoned
set hidden
set wildmode=list:longest
set ttyfast
" 00x增减数字时使用十进制
set nrformats=
"==========================================
" FileEncode Settings 文件编码,格式
"==========================================
" 设置新文件的编码为 UTF-8
set encoding=utf-8
" 自动判断编码时,依次尝试以下编码:
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set helplang=cn
"set langmenu=zh_CN.UTF-8
"set enc=2byte-gb18030
" 下面这句只影响普通模式 (非图形界面) 下的 Vim。
set termencoding=utf-8
" Use Unix as the standard file type
set ffs=unix,dos,mac
" 如遇Unicode值大于255的文本,不必等到空格再折行。
set formatoptions+=m
" 合并两行中文时,不在中间加空格:
set formatoptions+=B
"==========================================
" others 其它设置
"==========================================
autocmd! bufwritepost _vimrc source % " vimrc文件修改之后自动加载。 windows。
autocmd! bufwritepost .vimrc source % " vimrc文件修改之后自动加载。 linux。
" 自动补全配置
"让Vim的补全菜单行为与一般IDE一致(参考VimTip1228)
set completeopt=longest,menu
" 增强模式中的命令行自动完成操作
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc,*.class
"离开插入模式后自动关闭预览窗口
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
"回车即选中当前项
inoremap pumvisible() ? "\" : "\"
"上下左右键的行为 会显示其他信息
inoremap pumvisible() ? "\" : "\"
inoremap pumvisible() ? "\" : "\"
inoremap pumvisible() ? "\\\" : "\"
inoremap pumvisible() ? "\\\" : "\"
" if this not work ,make sure .viminfo is writable for you
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
"==========================================
" HotKey Settings 自定义快捷键设置
"==========================================
" 主要按键重定义
" 关闭方向键, 强迫自己用 hjkl
map
map
map
map
"Treat long lines as break lines (useful when moving around in them)
"se swap之后,同物理行上线直接跳
nnoremap k gk
nnoremap gk k
nnoremap j gj
nnoremap gj j
" F1 - F6 设置
" F1 废弃这个键,防止调出系统帮助
" F2 行号开关,用于鼠标复制代码用
" F3 显示可打印字符开关
" F4 换行开关
" F5 粘贴模式paste_mode开关,用于有格式的代码粘贴
" F6 语法开关,关闭语法可以加快大文件的展示
" I can type :help on my own, thanks. Protect your fat fingers from the evils of
noremap "
""为方便复制,用开启/关闭行号显示:
function! HideNumber()
if(&relativenumber == &number)
set relativenumber! number!
elseif(&number)
set number!
else
set relativenumber!
endif
set number?
endfunc
nnoremap :call HideNumber()
nnoremap :set list! list?
nnoremap :set wrap! wrap?
"set paste
set pastetoggle= " when in insert mode, press to go to
" paste mode, where you can paste mass data
" that won't be autoindented
" disbale paste mode when leaving insert mode
au InsertLeave * set nopaste
nnoremap :exec exists('syntax_on') ? 'syn off' : 'syn on'
"Smart way to move between windows 分屏窗口移动
map j
map k
map h
map l
" Go to home and end using capitalized directions
noremap H ^
noremap L $
"Map ; to : and save a million keystrokes
" ex mode commands made easy 用于快速进入命令行
nnoremap ; :
" 命令行模式增强,ctrl - a到行首, -e 到行尾
cnoremap
cnoremap
cnoremap
cnoremap
" 搜索相关
" Map to / (search) and Ctrl- to ? (backwards search)
map /
" 进入搜索Use sane regexes"
nnoremap / /\v
vnoremap / /\v
"Keep search pattern at the center of the screen."
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
" switch # *
nnoremap # *
nnoremap * #
" 去掉搜索高亮
noremap / :nohls
" --------tab/buffer相关
"Use arrow key to change buffer"
noremap :bp
noremap :bn
map tn :tabnew
map to :tabonly
map tc :tabclose
map tm :tabmove
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map te :tabedit =expand("%:p:h")/
" ------- 选中及操作改键
"Reselect visual block after indent/outdent.调整缩进后自动选中,方便再次操作
vnoremap < >gv
" y$ -> Y Make Y behave like other capitals
map Y y$
" select all
map sa ggVG"
" select block
nnoremap v V`}
" w!! to sudo & write a file
cmap w!! w !sudo tee >/dev/null %
" 滚动Speed up scrolling of the viewport slightly
nnoremap 2
nnoremap 2
"Jump to start and end of line using the home row keys
nmap t ok
nmap T Oj
" Quickly close the current window
nnoremap q :q
" Swap implementations of ` and ' jump to markers
" By default, ' jumps to the marked line, ` jumps to the marked line and
" column, so swap them
nnoremap ' `
nnoremap ` '
" remap U to for easier redo
nnoremap U
" Quickly edit/reload the vimrc file
nmap ev :e $MYVIMRC
nmap sv :so $MYVIMRC
"==========================================
" Theme Settings 主题设置
"==========================================
" Set extra options when running in GUI mode
if has("gui_running")
"set guifont=M+_1mn_regular:h18
set guioptions-=T
set guioptions+=e
set guioptions-=r
set guioptions-=L
set guioptions+=b
set guitablabel=%M\ %t
set showtabline=1
set linespace=2
set noimd
set t_Co=256
endif
if has("gui_gtk2")
set guifont=M+\ 1mn\ regular\ 14
elseif has("gui_macvim")
set guifont=M+_1mn_regular:h14
elseif has("gui_win32")
set guifont=M+_1mn_regular:h14
end
" theme主题
"set background=dark
colorscheme vividchalk
set t_Co=256
现在是没有插件的裸版,参考:k-vim