vim配置
- 博客分类:
- 技术杂绘
vim配置
2011年08月17日
1、编辑用户目录下的文件.vimrc,注意这个文件名第一个字符是点号,如果没有这个文件就创建它。
2、配色设置文件放在xx.vim文件中, .vimrc 中设置colorscheme xx.
经典设置:
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Maintainer: amix the lucky stiff" http://amix.dk - amix@amix.dk"" Version: 3.6 - 25/08/10 14:40:30"" Blog_post: " http://amix.dk/blog/post/19486#The-ultimate-vim-configuration-vimrc" Syntax_highlighted:" http://amix.dk/vim/vimrc.html" Raw_version: " http://amix.dk/vim/vimrc.txt"" How_to_Install_on_Unix:" $ mkdir ~/.vim_runtime" $ svn co svn://orangoo.com/vim ~/.vim_runtime" $ cat ~/.vim_runtime/install.sh" $ sh ~/.vim_runtime/install.sh " can be `mac`, `linux` or `windows`"" How_to_Upgrade:" $ svn update ~/.vim_runtime"" Sections:" -> General" -> VIM user interface" -> Colors and Fonts" -> Files and backups" -> Text, tab and indent related" -> Visual mode related" -> Command mode related" -> Moving around, tabs and buffers" -> Statusline" -> Parenthesis/bracket expanding" -> General Abbrevs" -> Editing mappings"" -> Cope" -> Minibuffer plugin" -> Omni complete functions" -> Python section" -> JavaScript section""" Plugins_Included:" > minibufexpl.vim - http://www.vim.org/scripts/script.php?script_id=159" Makes it easy to get an overview of buffers:" info -> :e ~/.vim_runtime/plugin/minibufexpl.vim"" > bufexplorer - http://www.vim.org/scripts/script.php?script_id=42" Makes it easy to switch between buffers:" info -> :help bufExplorer"" > yankring.vim - http://www.vim.org/scripts/script.php?script_id=1234" Emacs's killring, useful when using the clipboard:" info -> :help yankring"" > surround.vim - http://www.vim.org/scripts/script.php?script_id=1697" Makes it easy to work with surrounding text:" info -> :help surround"" > snipMate.vim - http://www.vim.org/scripts/script.php?script_id=2540" Snippets for many languages (similar to TextMate's):" info -> :help snipMate"" > mru.vim - http://www.vim.org/scripts/script.php?script_id=521" Plugin to manage Most Recently Used (MRU) files:" info -> :e ~/.vim_runtime/plugin/mru.vim"" > Command-T - http://www.vim.org/scripts/script.php?script_id=3025" Command-T plug-in provides an extremely fast, intuitive mechanism for opening filesa:" info -> :help CommandT" screencast and web-help -> http://amix.dk/blog/post/19501""" Revisions:" > 3.6: Added lots of stuff (colors, Command-T, Vim 7.3 persistent undo etc.)" > 3.5: Paste mode is now shown in status line if you are in paste mode" > 3.4: Added mru.vim" > 3.3: Added syntax highlighting for Mako mako.vim " > 3.2: Turned on python_highlight_all for better syntax" highlighting for Python" > 3.1: Added revisions ;) and bufexplorer.vim"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => General"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Sets how many lines of history VIM has to rememberset history=700" Enable filetype pluginfiletype plugin onfiletype indent on" Set to auto read when a file is changed from the outsideset autoread" With a map leader it's possible to do extra key combinations" like w saves the current filelet mapleader = ","let g:mapleader = ","" Fast savingnmap w :w!" Fast editing of the .vimrcmap e :e! ~/.vim_runtime/vimrc" When vimrc is edited, reload itautocmd! bufwritepost vimrc source ~/.vim_runtime/vimrc"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => VIM user interface"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Set 7 lines to the curors - when moving vertical..set so=7set wildmenu "Turn on WiLd menuset ruler "Always show current positionset cmdheight=2 "The commandbar heightset hid "Change buffer - without saving" Set backspace configset backspace=eol,start,indentset whichwrap+=,h,lset ignorecase "Ignore case when searchingset smartcaseset hlsearch "Highlight search thingsset incsearch "Make search act like search in modern browsersset nolazyredraw "Don't redraw while executing macros set magic "Set magic on, for regular expressionsset showmatch "Show matching bracets when text indicator is over themset mat=2 "How many tenths of a second to blink" No sound on errorsset noerrorbellsset novisualbellset t_vb=set tm=500"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Colors and Fonts"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""syntax enable "Enable syntax hl" Set font according to systemif MySys() == "mac" set gfn=Menlo:h14 set shell=/bin/bashelseif MySys() == "windows" set gfn=Bitstream\ Vera\ Sans\ Mono:h10elseif MySys() == "linux" set gfn=Monospace\ 10 set shell=/bin/bashendifif has("gui_running") set guioptions-=T set t_Co=256 set background=dark colorscheme peaksea set nonuelse colorscheme zellner set background=dark set nonuendifset encoding=utf8try lang en_UScatchendtryset ffs=unix,dos,mac "Default file types"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Files, backups and undo"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Turn backup off, since most stuff is in SVN, git anyway...set nobackupset nowbset noswapfile"Persistent undotry if MySys() == "windows" set undodir=C:\Windows\Temp else set undodir=~/.vim_runtime/undodir endif set undofilecatchendtry"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Text, tab and indent related"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""set expandtabset shiftwidth=4set tabstop=4set smarttabset lbrset tw=500set ai "Auto indentset si "Smart indetset wrap "Wrap lines""""""""""""""""""""""""""""""" => Visual mode related""""""""""""""""""""""""""""""" Really useful!" In visual mode when you press * or # to search for the current selectionvnoremap * :call VisualSearch('f')vnoremap # :call VisualSearch('b')" When you press gv you vimgrep after the selected textvnoremap gv :call VisualSearch('gv')map g :vimgrep // **/*.function! CmdLine(str) exe "menu Foo.Bar :" . a:str emenu Foo.Bar unmenu Fooendfunction " From an idea by Michael Naumannfunction! VisualSearch(direction) range let l:saved_reg = @" execute "normal! vgvy" let l:pattern = escape(@", '\\/.*$^~[]') let l:pattern = substitute(l:pattern, "\n$", "", "") if a:direction == 'b' execute "normal ?" . l:pattern . "^M" elseif a:direction == 'gv' call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.') elseif a:direction == 'f' execute "normal /" . l:pattern . "^M" endif let @/ = l:pattern let @" = l:saved_regendfunction"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Command mode related"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Smart mappings on the command linecno $h e ~/cno $d e ~/Desktop/cno $j e ./cno $c e eCurrentFileDir("e")" $q is super useful when browsing on the command linecno $q eDeleteTillSlash()" Bash like keys for the command linecnoremap cnoremap cnoremap cnoremap cnoremap " Useful on some European keyboardsmap 陆 $imap 陆 $vmap 陆 $cmap 陆 $func! Cwd() let cwd = getcwd() return "e " . cwd endfuncfunc! DeleteTillSlash() let g:cmd = getcmdline() if MySys() == "linux" || MySys() == "mac" let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "") else let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\]\\).*", "\\1", "") endif if g:cmd == g:cmd_edited if MySys() == "linux" || MySys() == "mac" let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "") else let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\\]\\).*\[\\\\\]", "\\1", "") endif endif return g:cmd_editedendfuncfunc! CurrentFileDir(cmd) return a:cmd . " " . expand("%:p:h") . "/"endfunc"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Moving around, tabs and buffers"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Map space to / (search) and c-space to ? (backgwards search)map /map ?map :noh" Smart way to move btw. windowsmap jmap kmap hmap l" Close the current buffermap bd :Bclose" Close all the buffersmap ba :1,300 bd!" Use the arrows to something usefullmap :bnmap :bp" Tab configurationmap tn :tabnewmap te :tabedit map tc :tabclosemap tm :tabmove " When pressing cd switch to the directory of the open buffermap cd :cd %:p:hcommand! Bclose call BufcloseCloseIt()function! BufcloseCloseIt() let l:currentBufNum = bufnr("%") let l:alternateBufNum = bufnr("#") if buflisted(l:alternateBufNum) buffer # else bnext endif if bufnr("%") == l:currentBufNum new endif if buflisted(l:currentBufNum) execute("bdelete! ".l:currentBufNum) endifendfunction" Specify the behavior when switching between buffers try set switchbuf=usetab set stal=2catchendtry""""""""""""""""""""""""""""""" => Statusline""""""""""""""""""""""""""""""" Always hide the statuslineset laststatus=2" Format the statuslineset statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%cfunction! CurDir() let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g") return curdirendfunctionfunction! HasPaste() if &paste return 'PASTE MODE ' else return '' endifendfunction"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Parenthesis/bracket expanding""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""vnoremap $1 `>a)`vnoremap $2 `>a]`vnoremap $3 `>a}`vnoremap $$ `>a"`vnoremap $q `>a'`vnoremap $e `>a"`" Map auto complete of (, ", ', [inoremap $1 ()iinoremap $2 []iinoremap $3 {}iinoremap $4 {o}Oinoremap $q ''iinoremap $e ""iinoremap $t i"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => General Abbrevs"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""iab xdate =strftime("%d/%m/%y %H:%M:%S")"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Editing mappings""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Remap VIM 0map 0 ^"Move a line of text using ALT+[jk] or Comamnd+[jk] on macnmap mz:m+`znmap mz:m-2`zvmap :m'>+`mzgv`yo`zvmap :m'`>my` nmap vmap vmap endif"Delete trailing white space, useful for Python ;)func! DeleteTrailingWS() exe "normal mz" %s/\s\+$//ge exe "normal `z"endfuncautocmd BufWrite *.py :call DeleteTrailingWS()set guitablabel=%t"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Cope"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Do :help cope if you are unsure what cope is. It's super useful!map cc :botright copemap n :cnmap p :cp""""""""""""""""""""""""""""""" => bufExplorer plugin""""""""""""""""""""""""""""""let g:bufExplorerDefaultHelp=0let g:bufExplorerShowRelativePath=1map o :BufExplorer""""""""""""""""""""""""""""""" => Minibuffer plugin""""""""""""""""""""""""""""""let g:miniBufExplModSelTarget = 1let g:miniBufExplorerMoreThanOne = 2let g:miniBufExplModSelTarget = 0let g:miniBufExplUseSingleClick = 1let g:miniBufExplMapWindowNavVim = 1let g:miniBufExplVSplit = 25let g:miniBufExplSplitBelow=1let g:bufExplorerSortBy = "name"autocmd BufRead,BufNew :call UMiniBufExplorermap u :TMiniBufExplorer"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Omni complete functions"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""autocmd FileType css set omnifunc=csscomplete#CompleteCSS"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Spell checking""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Pressing ,ss will toggle and untoggle spell checkingmap ss :setlocal spell!"Shortcuts using map sn ]smap sp [smap sa zgmap s? z=""""""""""""""""""""""""""""""" => Python section""""""""""""""""""""""""""""""let python_highlight_all = 1au FileType python syn keyword pythonDecorator True None False selfau BufNewFile,BufRead *.jinja set syntax=htmljinjaau BufNewFile,BufRead *.mako set ft=makoau FileType python inoremap $r return au FileType python inoremap $i import au FileType python inoremap $p print au FileType python inoremap $f #--- PH ----------------------------------------------FP2xiau FileType python map 1 /class au FileType python map 2 /def au FileType python map C ?class au FileType python map D ?def """"""""""""""""""""""""""""""" => JavaScript section"""""""""""""""""""""""""""""""au FileType javascript call JavaScriptFold()au FileType javascript setl fenau FileType javascript setl nocindentau FileType javascript imap AJS.log();hiau FileType javascript imap alert();hiau FileType javascript inoremap $r return au FileType javascript inoremap $f //--- PH ----------------------------------------------FP2xifunction! JavaScriptFold() setl foldmethod=syntax setl foldlevelstart=1 syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend function! FoldText() return substitute(getline(v:foldstart), '{.*', '{...}', '') endfunction setl foldtext=FoldText()endfunction""""""""""""""""""""""""""""""" => MRU plugin""""""""""""""""""""""""""""""let MRU_Max_Entries = 400map f :MRU""""""""""""""""""""""""""""""" => Command-T""""""""""""""""""""""""""""""let g:CommandTMaxHeight = 15set wildignore+=*.o,*.obj,.git,*.pycnoremap j :CommandTnoremap y :CommandTFlush""""""""""""""""""""""""""""""" => Vim grep""""""""""""""""""""""""""""""let Grep_Skip_Dirs = 'RCS CVS SCCS .svn generated'set grepprg=/bin/grep\ -nH"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => MISC"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Remove the Windows ^M - when the encodings gets messed upnoremap m mmHmt:%s///ge'tzt'm"Quickly open a buffer for scripbblemap q :e ~/bufferau BufRead,BufNewFile ~/buffer iab xh1 ===========================================map pp :setlocal paste!map bb :cd ..
发表评论
-
CUBRID 中的线程模型
2012-01-20 10:32 832CUBRID 中的线程模型 2010 ... -
OpenNMS扩展 - 事件配置
2012-01-20 10:32 904OpenNMS扩展 - 事件配置 2011年04月24日 ... -
Process and Thread
2012-01-20 10:32 680Process and Thread 2011年02 ... -
转:构建可扩展的Java EE应用
2012-01-20 10:32 615转:构建可扩展的Java EE ... -
由C++转向C#需要注意的问题 (3)
2012-01-20 10:32 613由C++转向C#需要注意的问题 (3) 2010年06月02 ... -
python 常用类库!(转)
2012-01-19 15:32 1035python 常用类库!(转) 2011年01月21日 ... -
转:湘鄂情模式二
2012-01-19 15:32 538转:湘鄂情模式二 2011年08月10日 以人为本,建立 ... -
管理篇
2012-01-19 15:32 632管理篇 2011年01月23日 ... -
perfHUD使用说明
2012-01-19 15:32 731perfHUD使用说明 2011年04月14日 perf ... -
收拾包袱,收拾心情
2012-01-17 05:19 784收拾包袱,收拾心情 8小时前 枝鸦的枯叫,鸣醒了沉睡的 ... -
今天一说
2012-01-17 05:19 772今天一说 8小时前 本来早上是要六点起的,闹铃一 ... -
真的累了!对自己说声再见
2012-01-17 05:19 634真的累了!对自己说声再见 8小时前 这个冬天格外的寒冷, ... -
阿莫西林复方制剂
2012-01-17 05:19 1681阿莫西林复方制剂 8小 ... -
也许,再这样下去,我的心会开始为另一个他而心跳
2012-01-17 05:19 672也许,再这样下去,我的 ... -
注册必备……
2012-01-16 04:13 1123注册必备…… 2010年07 ... -
Windows下的Qt环境安装
2012-01-16 04:13 2421Windows下的Qt环境安装 20 ... -
如何破解Pocket PC (for ARM)软件
2012-01-16 04:13 977如何破解Pocket PC (for ARM)软件 2010 ... -
Visual Studio (Team Suite and Professional) 2005&2008 微软官方下载
2012-01-16 04:13 1098Visual Studio (Team Suite and P ...
相关推荐
下载vimconfig.tar.tgz,将文件拷贝到ubuntu, 执行下面命令: tar zxvf vimconfig.tar.tgz cd vimconfig cp .* ~/ -rvf 部分配置情况: "-------------TagList--------------- "设置ctags路径 let Tlist_Ctags_Cmd ...
vim配置 vim 配置 整理出来大家一起学习
vim配置文件vim配置文件vim配置文件
强大的vim配置文件,强大的vim配置文件强大的vim配置文件强大的vim配置文件强大的vim配置文件
vim配置插件
vim配置文件,vim配置文件
vim配置+各种颜色方案
vim配置C/C++开发环境,包括函数补全小括号补全等等,基本跟ide差不多,内附步骤。 注:vim中需要使用tab键来调出下拉框
vim配置包
vim配置文件 vimrc vim配置文件 vimrc vim配置文件 vimrc
vim配置文档详解
vim配置文件,可以直接使用,ubuntu在/etc/vim/vimrc
linux vim配置以及插件 linux vim配置以及插件
作者:聂飞 在终端下使用vim进行编辑时,默认情况下,编辑的界面上是没有显示行号、语法高亮度显示 工作,需要手动设置一个配置文件:.vimrc。
vim配置的例子 以及说明 可以学习下
vim配置文件含有各种插件。用着能方便一些" 编写文件时的配置 > " ----------------------------------------------------------------------------- filetype on "启用文件类型侦测 filetype plugin on "针对不同的...
强大的vim配置文件,可同时适用于linux和windows下的vim配置。 涵盖了所有主流插件的配置,常见的显示设置,编译命令的映射。 插件: ctags 代码跟踪 taglist 类视图 winmanager 文件视图 minibuffer 显示多文件...
自己的vim配置文件目录备份,包括git版本修改记录。使用方法,linux系统:解压后,运行INSTALL。Windows系统:解压后自行替换对应配置文件及目录。
.vimrc 文件 vim配置文件 字体、颜色 各类插件 ------------ 具体配置步骤找寻相关博客 仅供参考
Vim 配置文件。 支持ctags/cscope的配置。可以动态的进行代码的跳转高亮等