我的VIM.rc


""""""""""""""""""""""""""""""""""""""""""""""
" => General
""""""""""""""""""""""""""""""""""""""""""""""
" Set how many lines of history VIM has to remermber
set history=700 " Enable filetype plugins
filetype plugin on
filetype indent on " Set to auto read when a file is changed from the outside
set autoread " With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader=","
let g:mapleader="," "Why a extra 'g:mapleader' variable, after 'mapleader' " Fast saving
nmap <leader>w :w!<cr> " Ignore case when searching
set ignorecase " equivalent to '\ckeyword' when searching '\c' means case-ignored """"""""""""""""""""""""""""""""""""""""""""""
" ==> set encoding and fileformats
""""""""""""""""""""""""""""""""""""""""""""""
" set UTF8 as standard encoding and en_US as the standard language
set encoding=utf8 " 解决中文乱码问题
let &termencoding=&encoding " file encoding, especially 'character encoding'
" 简体中文
set fileencodings=ucs-bom,utf-8,gb2312,cp936,big5,shift-jis,euc-jp,euc-kr,latin1,chinese if has ("win32")
set fileencoding=chinese
else
set fileencoding=utf8
endif " Use Unix as the standard file type
set ffs=unix,dos,mac " 处理 consle/command line 乱码
language messages zh_CN.utf-8 if has("win32")
"处理菜单及右键菜单乱码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
endif """"""""""""""""""""""""""""""""""""""""""""""
" ==> Function *MySys* : Detect Opertaring System Platform """"""""""""""""""""""""""""""""""""""""""""""
function! MySys()
if has("win32")
return 'windows'
else
return 'linux'
endif
endfunction """"""""""""""""""""""""""""""""""""""""""""""
"" Define function SwitchToBuf(filename) """"""""""""""""""""""""""""""""""""""""""""""
function! SwitchToBuf(filename)
"let fullfn = substitute(a:filename, "^\\~/", $HOME . "/", "")
" find in current tab
let bufwinnr = bufwinnr(a:filename)
if bufwinnr != -1
exec bufwinnr . "wincmd w"
return
else
" find in each tab
tabfirst
let tab = 1
while tab <= tabpagenr("$")
let bufwinnr = bufwinnr(a:filename)
if bufwinnr != -1
exec "normal " . tab . "gt"
exec bufwinnr . "wincmd w"
return
endif
tabnext
let tab = tab + 1
endwhile
" not exist, new tab
exec "tabnew " . a:filename
endif
endfunction """"""""""""""""""""""""""""""""""""""""""""""
"Fast edit vimrc """"""""""""""""""""""""""""""""""""""""""""""
if MySys() == 'linux'
"Fast reloading of the .vimrc
map <silent> <leader>ss :source ~/.vimrc<cr>
"Fast editing of .vimrc
map <silent> <leader>ee :call SwitchToBuf("~/.vimrc")<cr>
"When .vimrc is edited, reload it
"autocmd! bufwritepost .vimrc source ~/.vimrc
elseif MySys() == 'windows'
" Set helplang
set helplang=cn
"Fast reloading of the _vimrc
"Not in Cygwin environment
map <silent> <leader>ss :source C:/Program\ Files/Vim/_vimrc<cr>
"Fast editing of _vimrc
"Not in Cygwin environment
map <silent> <leader>ee :call SwitchToBuf("C:/Program\ Files/Vim/_vimrc")<cr>
"When _vimrc is edited, reload it
"autocmd! bufwritepost _vimrc source ~/_vimrc " What does the line mean?
endif set nocompatible """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ==> For Windows version
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if MySys() == 'windows'
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
endif 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
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction """"""""""""""""""""""""""""""""""""""""""""""
" => Colors and fonts
""""""""""""""""""""""""""""""""""""""""""""""
syntax enable
syntax on set t_Co=256 "number of Colors"
set background=dark " This may not effect in VIM; It's background will be white, though.
" colorscheme desert
colorscheme molokai set number " hilight function name
autocmd BufNewFile,BufRead * :syntax match cfunctions "\<[a-zA-Z_][a-zA-Z_0-9]*\>[^()]*)("me=e-2
autocmd BufNewFile,BufRead * :syntax match cfunctions "\<[a-zA-Z_][a-zA-Z_0-9]*\>\s*("me=e-1 hi cfunctions ctermfg=81 "(这一行就是给函数名加颜色的) """"""""""""""""""""""""""""""""""""""""""""""
" change color in Gvim
""""""""""""""""""""""""""""""""""""""""""""""
if has("gui_running") endif """"""""""""""""""""""""""""""""""""""""""""""
" ==> Change color in Normal Vim
""""""""""""""""""""""""""""""""""""""""""""""
if !has("gui_running")
highlight Normal ctermfg=grey ctermbg=black "Set Vim's background color and foreground color
endif " set cursorline && higtligt current line
set cursorline
:hi CursorLine cterm=underline " ctermbg=gray ctermfg=white guibg=gray guifg=white ""highlight currentline-horizontal
" :hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
" :nnoremap <Leader>c :set cursorline! cursorcolumn!<CR> """"""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
"set expandtab "Not good for Makefile filetype " Be smart when using tabs ;)
set smarttab " 1 tab == 4 space keys
set shiftwidth=4
set tabstop=4 set ai " Auto indent
set si "Smart indent
set wrap " Wrap lines """"""""""""""""""""""""""""""""""""""""""""""
" => Status line
""""""""""""""""""""""""""""""""""""""""""""""
" Always show the status line and row=2; One is statusline ,second is the
" command line
set laststatus=2 " Format the status line
"set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %1
set statusline=[%F]%y%r%m%*%=[%{&fileencoding}][Line:%l/%L,Column:%c][%p%%] set ruler " 在编辑过程中,在右下角显示光标位置的状态行 "--------------------------------------------------------------------------------
" 窗口操作的快捷键
"--------------------------------------------------------------------------------
nmap wv <C-w>v " 垂直分割当前窗口
nmap wc <C-w>c " 关闭当前窗口
nmap ws <C-w>s " 水平分割当前窗口 "--------------------------------------------------------------------------------
" close Gvim's toolbar, menu bar, scroll bar
"--------------------------------------------------------------------------------
if has("gui_running")
set guioptions-=m "remove menu bar
set guioptions-=T "remove tool bar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=l "remove left-hand scroll bar
endif """"""""""""""""""""""""""""""
" Tag list (ctags)
""""""""""""""""""""""""""""""
if MySys() == "windows" "设定windows系统中ctags程序的位置
let Tlist_Ctags_Cmd = 'ctags'
elseif MySys() == "linux" "设定linux系统中ctags程序的位置
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
endif let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim
let Tlist_Use_Right_Window = 1 "在右侧窗口中显示taglist窗口 map <silent> <F3> :TlistToggle<cr> """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Nerd Tree
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:NERDTreeWinPos = "left" "在左侧
let NERDTreeShowHidden=0
let NERDTreeIgnore = ['\.pyc$', '__pycache__']
let g:NERDTreeWinSize=35 " open and close NERDTREEWINDOW
map <leader>nn :NERDTreeToggle<cr>
map <silent> <F2> :NERDTreeToggle<cr>
map <leader>nb :NERDTreeFromBookmark
map <leader>nf :NERDTreeFind<cr> """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vimgrep, Quickfix, Makeprg
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>
nmap <leader>cn :cn<cr>
nmap <leader>cp :cp<cr>
nmap <leader>cw :cw 10<cr>
" 编译后,如有错误则打开quickfix窗口。(光标仍停留在源码窗口)
" If error occur after compiling, then the quickfix window is opened automatically.
" the cursor is still in the source window.
"
" 注意:需要开启netsting autocmd
" Note: netsting autocmd should be opened.
autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow " 在我的vimrc中,定义下面的键映射,利用它可以在当前文件中快速查找光标下的单词
nmap <leader>lv :lv /<c-r>=expand("<cword>")<cr>/ %<cr>:lw<cr>

我的VIM.rc的更多相关文章

  1. vim.rc配置(deepin)

    set nocompatible " be iMproved, requiredfiletype off " required " set the runtime pat ...

  2. iconv内容,convmv文件名,unix2dos,dos2unix文件格式转换,od/cut/wc/dd/diff/uniq/nice/du等命令,linux文件名乱码,文件名,文件内容,vim编码设置

    1.enconv文件名编码转换,比如要将一个GBK编码的文件转换成UTF-8编码,操作如下 enconv -L zh_CN -x UTF-8 filename enconv -L GB2312 -x  ...

  3. 大神的vim配置

    大神的vim配置,O(∩_∩)O spf13-vim : Steve Francia's Vim Distribution __ _ _____ _ ___ _ __ / _/ |___ / __ _ ...

  4. vim配置python编程环境及YouCompleteMe的安装教程

    python号称人工智能语言,现在可算大热,这篇博客将介绍如何用vim打造一款自己专属的python编程环境. step1 由于安装YouCompleteMe需要vim8.0及以上版本,所以得安装使用 ...

  5. linux基础之vim编辑器

    vi : Visual Interface vim : VI Improved : VI的基础加上一些有用的插件 vim编辑器: 文本编辑器, 字处理器, 全屏编辑器, 模式化编辑器 vim的模式有三 ...

  6. vim basic

    1.基本用法 1.1.编辑模式 1.2.底行模式 1.3.环境配置 1.4.使用时发现的 2.编辑多个文档 3.选项 1.基本用法 1.1.编辑模式 插入 插入命令 插入位置 i 光标左侧 a 光标右 ...

  7. kubernetes听云实战发布版

    ➠更多技术干货请戳:听云博客 听云线上使用k8s已经有一段时间了,下面对一些听云使用过程中的问题进行一些梳理,包括架构设计,安装部署和后期维护. 目录结构如下: 下面进入正题: 我们以听云系统的一个报 ...

  8. linux的“自动化”

    h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h ...

  9. linux内核增加系统调用--Beginner‘s guide

    Linux内核中设置了一组用于实现系统功能的子程序,称为系统调用.系统调用和普通库函数调用非常相似明知是系统调用由操作系统核心提供,运行于核心态,而普通的函数调用由函数库或用户自己提供,运行于用户态. ...

随机推荐

  1. 升级到tomcat7.0碰到的问题

    今天把tomcat从6.0.18升级到7.0.25,发现了两个问题 问题1 java.lang.ClassNotFoundException: org.apache.catalina.mbeans.S ...

  2. Genymotion中文手册

    目录1.概述 22.特点 22.1最擅长于虚拟Android 22.2高可控性 22.3管理你的设备 22.4从Eclipse中开启虚拟设备 33.要求 33.1操作系统要求 33.2系统硬件要求 3 ...

  3. 汽车行业的DMS系统 IT不变应万变

    DMS是针对4S店的整车销售.零配件仓库.售后维修服务(含车间管理).客服服务涵盖4S店业务进行完整管理的系统,是对销售.维修.客户关系进行一系列的整合.其中,服务的预约.进店接待都有着跟踪处理,客户 ...

  4. iOS开发——高级技术&生成二维码

      生成二维码 因为项目里需要新增个功能,该功能用到了二维码技术.于是我便查阅了资料,先学习了二维码的生成. 我们使用libqrencode库来生成二维码.下载地址http://download.cs ...

  5. android学习日记06--View视图

    一.android 界面开发 1.三个重要的类:View视图.Canvas画布.Paint画笔2.android 界面开发常用三种视图 View            --只能在主线程中更新,没有缓存 ...

  6. 详解 MySQL 中的 explain

    来源:persister 链接:http://www.blogjava.net/persister/archive/2008/10/27/236813.html 在 explain的帮助下,您就知道什 ...

  7. 解决Windows2008Server上PLSQL登录时报ORA-12557

    公司的Oracle服务端是安装在一台Linux服务器上,版本号为11.1.0.7.0.我们开发的系统部署在Windows 2008 Server(x64),因为偶尔需要调用Oracle数据库,所以最开 ...

  8. 批量除去php页面的bom,页面meta跑到body中就是这个问题

    <?php if (isset($_GET['dir'])){ //设置文件目录 $basedir=$_GET['dir']; }else{ $basedir = '.'; } $auto = ...

  9. 【转】Split strings the right way – or the next best way

      I know many people are bored of the string splitting problem, but it still seems to come up almost ...

  10. Lucene全文检索系列(一)

    1. Lucene简介 Lucene是一个全文检索引擎的架构,提供了完整的查询引擎和索引引擎.Lucene以其方便使用.快速实施以及灵活性受到广泛的关注.它可以方便地嵌入到各种应用中实现针对应用的全文 ...