您的位置:首页 > 其它

vim学习笔记-0

2010-12-08 18:13 423 查看
先看截图

linux:



windows



0.序

参考

[1]vim下载,http://www.vim.org/download.php

[2]手把手教你把Vim改装成一个IDE编程环境(图文),http://blog.csdn.net/wooin/archive/2007
/10/31/1858917.aspx

[3]vim中文帮助文档下
载,http://vimcdoc.sf.net

[4]史上最强的 Vim
配置文件,http://amix.dk/vim/vimrc.html

[5]vim使用进阶,http://easwy.com
/blog/archives/advanced-vim-skills-catalog/

安装中文帮助文档非常重要,仔细阅读vim帮助文档,这里是最权威、最准确的介绍。

浏览过文档后我发觉,即使什么插件也不安装,vim也基本够用
了。

心里有了底之后,在怎么折腾也就不怕了。

后续章节是操作记录

1.windows配置

1.1. plugin

//C:/PROGRAM FILES/VIM/VIMFILES/PLUGIN

bufexplorer.vim

minibufexpl.vim

mru.vim

surround.vim

taglist.vim

vimcdoc.vim

winfileexplorer.vim

winmanager.vim

wintagexplorer.vim

1.2. _vimrc

//C:/Program Files/Vim/_vimrc

set nocompatible

source $VIMRUNTIME/vimrc_example.vim

source $VIMRUNTIME/mswin.vim

behave mswin

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

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" 以下copy自amix

" 黑体部分为新加或变更

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => General

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Sets how many lines of history VIM has to remember

set history=700

" Enable filetype plugin

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 = ","

" Fast saving

nmap <leader>w :w!<cr>

" Fast editing of the .vimrc

map <leader>e :e! $VIM/_vimrc<cr>

" When vimrc is edited, reload it

autocmd! bufwritepost vimrc source $VIM/_vimrc

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => VIM user interface

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Set 7 lines to the curors - when moving vertical..

set so=7

set wildmenu "Turn on WiLd menu

set ruler "Always show current position

set cmdheight=2 "The commandbar height

set hid "Change buffer - without saving

" Set backspace config

set backspace=eol,start,indent

set whichwrap+=<,>,h,l

set ignorecase "Ignore case when searching

set smartcase

set hlsearch "Highlight search things

set incsearch "Make search act like search in modern browsers

set nolazyredraw "Don't redraw while executing macros

set magic "Set magic on, for regular expressions

set showmatch "Show matching bracets when text indicator is over them

set mat=2 "How many tenths of a second to blink

" No sound on errors

set noerrorbells

set novisualbell

set t_vb=

set tm=500

" Show line number

set nu!

" ColorScheme

colo desert


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Text, tab and indent related

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

set expandtab

set shiftwidth=4

set tabstop=4

set smarttab

set lbr

set tw=500

set ai "Auto indent

set si "Smart indet

set wrap "Wrap lines

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Moving around, tabs and buffers

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Map space to / (search) and c-space to ? (backgwards search)

map <space> /

map <c-space> ?

map <silent> <leader><cr> :noh<cr>

" Smart way to move btw. windows

map <C-j> <C-W>j

map <C-k> <C-W>k

map <C-h> <C-W>h

map <C-l> <C-W>l

" Close the current buffer

map <leader>bd :Bclose<cr>

" Close all the buffers

map <leader>ba :1,300 bd!<cr>

" Use the arrows to something usefull

map <right> :bn<cr>

map <left> :bp<cr>

" Tab configuration

map <leader>tn :tabnew<cr>

map <leader>te :tabedit

map <leader>tc :tabclose<cr>

map <leader>tm :tabmove

" When pressing <leader>cd switch to the directory of the open buffer

map <leader>cd :cd %:p:h<cr>

command! Bclose call <SID>BufcloseCloseIt()

function! <SID>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)

endif

endfunction

" Specify the behavior when switching between buffers

try

set switchbuf=usetab

set stal=2

catch

endtry

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Statusline

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Always hide the statusline

set laststatus=2

" Format the statusline

set statusline=/ %{HasPaste()}%F%m%r%h/ %w/ / CWD:/ %r%{CurDir()}%h/ / / Line:/ %l/%L:%c

function! CurDir()

let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")

return curdir

endfunction

function! HasPaste()

if &paste

return 'PASTE MODE '

else

return ''

endif

endfunction

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" 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
"

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Taglist

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

let Tlist_Show_One_File=1

let Tlist_Exit_OnlyWindow=1

set tags=./tags,./../tags,./*/tags

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => winManager

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

let g:winManagerWindowLayout='FileExplorer|TagList'

nmap wm :WMToggle<cr>


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => bufExplorer plugin

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

let g:bufExplorerDefaultHelp=0

let g:bufExplorerShowRelativePath=1

map <leader>o :BufExplorer<cr>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Minibuffer plugin

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

let g:miniBufExplModSelTarget = 1

let g:miniBufExplorerMoreThanOne = 2

let g:miniBufExplModSelTarget = 0

let g:miniBufExplUseSingleClick = 1

let g:miniBufExplMapWindowNavVim = 1

let g:miniBufExplVSplit = 20

let g:miniBufExplSplitBelow=1

let g:bufExplorerSortBy = "name"

autocmd BufRead,BufNew :call UMiniBufExplorer

map <leader>u :TMiniBufExplorer<cr>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => MRU plugin

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

let MRU_Max_Entries = 400

map <leader>f :MRU<CR>

""""""""""""""""""""""""""""""

" => 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 up

noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm

"Quickly open a buffer for scripbble

map <leader>q :e ~/buffer<cr>

au BufRead,BufNewFile ~/buffer iab <buffer> xh1 ===========================================

map <leader>pp :setlocal paste!<cr>

map <leader>bb :cd ..<cr>

2.Linux

与windows基本相同,直接修改了下amix

2.1. 用户配置文件:~$.vimrc

1)--------------------------------------------------------

在=General上方添加:

func! MySys()

return "linux"

endfunc

2)--------------------------------------------------------

更改命令映射.vimrc路径

" Fast editing of the .vimrc

map <leader>e :e! ~/.vimrc<cr>

" When vimrc is edited, reload it

autocmd! bufwritepost vimrc source ~/.vimrc

3)--------------------------------------------------------

我喜欢的颜色设置

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Colors and Fonts

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

syntax enable "Enable syntax hl

" Set font according to system

if MySys() == "mac"

set gfn=Menlo:h14

set shell=/bin/bash

elseif MySys() == "windows"

set gfn=Bitstream/ Vera/ Sans/ Mono:h10

elseif MySys() == "linux"

set gfn=Monospace/ 10

set shell=/bin/bash

endif

colo desert

set nu!


if has("gui_running")

set guioptions-=T

set t_Co=256

" set background=dark

" colorscheme peaksea

" set nonu


else

" colorscheme zellner

" set background=dark

" set nonu


endif

4)--------------------------------------------------------

添加如下内容

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Taglist

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

let Tlist_Show_One_File=1

let Tlist_Exit_OnlyWindow=1

set tags=./tags,./../tags,./*/tags

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => winManager

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

let g:winManagerWindowLayout='FileExplorer|TagList'

nmap wm :WMToggle<cr>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: