2012年3月29日木曜日

VIM

[2012/05/06 Update]
Homepage:
http://www.vim.org/
Setting:
$VIM/_vimrc
/*
" source $VIMRUNTIME/vimrc_example.vim
" source $VIMRUNTIME/mswin.vim
source $VIM/setting.vim
*/

/etc/vim/vimrc /etc/vim/gvimrc //source /opt/setting.vim

//setting.vim
/*
set nocompatible
if has('win32') || has('win64')
 language english
 set fileformats=dos,unix
elseif has('unix')
 language en_US.UTF-8
 set fileformats=unix,dos
endif
if v:version >= 703
 autocmd InsertEnter * set nocursorcolumn nocursorline relativenumber colorcolumn=
 autocmd InsertLeave * set cursorcolumn cursorline number colorcolumn=40,80
 set colorcolumn=40,80
else
 autocmd InsertEnter * set nocursorcolumn nocursorline
 autocmd InsertLeave * set cursorcolumn cursorline
endif
if has('gui_running')
 autocmd GUIEnter * winpos 0 0
 highlight Normal guibg=black guifg=white
 highlight User1 guibg=white guifg=red
 highlight User2 guibg=white guifg=lightred
 highlight User3 guibg=white guifg=darkred
 set guioptions-=e
 set guioptions-=m
 set guioptions-=T
 set statusline=[%3*%t%*]%1*%m%r%h%w%y%*
 set statusline+=%=
 set statusline+=[%2*%{mode()}%*]
 set statusline+=[%1*%{&enc}%*]
 set statusline+=[%1*%{&fenc}%*(%1*%{&bomb}%*),%1*%{&ff}%*]
 set statusline+=[%2*%l%*,%2*%c%*(%3*%p%*%%/%3*%L%*)]
 if has('win32') || has('win64')
  autocmd InsertEnter * set noimdisable
  autocmd InsertLeave * set imdisable
  set guifont=MingLiU:h14
 elseif has('unix')
  set guifont=WenQuanYi\ Zen\ Hei\ Mono\ 14
 endif
else
 set columns=80 lines=25
 set statusline=[%t]%m%r%h%w%y
 set statusline+=%=
 set statusline+=[%{mode()}]
 set statusline+=[%{&enc}]
 set statusline+=[%{&fenc}(%{&bomb}),%{&ff}]
 set statusline+=[%l,%c(%p%%/%L)]
endif
set autoindent
set autoread
set backspace=indent,eol,start
set clipboard=unnamed
set cursorcolumn
set cursorline
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,ucs-bom,taiwan,prc,japan,korea
set foldmethod=indent
set hlsearch
set ignorecase
set incsearch
set laststatus=2
set list
set listchars=tab:>-,eol:<,trail:=
set number
set showcmd
set smartcase
set smartindent
set splitbelow
set splitright
set wrap
syntax enable
set nobackup
set noswapfile
set nowritebackup
*/
Usage:
 [

i I a A s S r R o O //[g]J << >>
v V v //o O [g]u [g]U ~ aw is as r* < >

h j k l
+ -
(e|y)
w W b B [g]e [g]E
f F t T ; ,
'' ``
(o|i) //:ju[mps]
'' '" '[ '] '(a~z|A~Z) //:marks
% () {}
0 $ ^ _
H M L
gg G (gg|G)  *%
(f|b|d|u)
z(t|z|b)
z(o|c|r|R|m|M|n|N|i|j|k)

["(a~z|A~Z|*)](x|X|d|D|dd|c|C|cc|y|Y|yy|(d|c|y)(h|j|k|l))
["(a~z|A~Z|*)][](p|P)
. q(a~z|A~Z) []@(a~z) @@
//:reg[isters]

u r

ggVG

(?|/)(\<|\>|^|$|.) //n N :noh[lsearch]
[g]* [g]#

:[range]s[ubstitute]/{pattern}/{string}/[flags]
//[range] = (1,$|%|.|+-|'*,'*|'<,'>) :
//[flags] = (c|g|i|I|n)
//"\" "+" &
:?^*?,/^*/s={pattern}={string}=[flags]
:g[lobal]/{pattern}/[cmd]

oo

:h[elp]
q:
:opt[ions]

:se[t] all

:q[uit] wq
:clo[se]
:on[ly]
:[range]r[ead] //!
:[range]w[rite]
:sav[eas]

:X :se[t] key=

:sp[lit] ws
:vs[plit]
:new wn
:vne[w]
//w[](w|h|j|k|l|t|b|H|J|K|L|+|-|_|=)

:Exp[lore]
:Tex[plore]
:Sex[plore]
:Vex[plore]

:diffthis
:diffoff
//]c [c :diffu[pdate] :diffg[et] :diffpu[t]

:tabs
:tabe[dit]
:tabc[lose]
:tabo[nly]
:tabn[ext] gt 
:tabp[revious] :tabN[ext] gT 
:tabr[ewind] :tabfir[st]
:tabl[ast]
:tabm[ove]

:e[dit] ++enc=(utf-8|ucs-bom|taiwan|prc|japan|korea)
:se[t] (fileencoding|fenc)=(utf-8|ucs-bom|taiwan|prc|japan|korea)
:se[t] (fileformat|ff)=(dos|unix)
:se[t] (guifont|gfn)=*
清空 register jump mark
Windows 7:
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Dim eespath
eespath = WshShell.ExpandEnvironmentStrings("%USERPROFILE%")& _
          "\_viminfo"
If (fso.FileExists(eespath)) Then
 fso.DeleteFile(eespath)
 MsgBox "Find _viminfo & Remove" , 0 , "Message"
Else
 MsgBox "Can't Find _viminfo & Exit" , 0 , "Message"
End If
Linux:
#!/bin/bash
if [ -f ~/.viminfo ] ; then
 rm ~/.viminfo
 echo "Find _viminfo & Remove"
else
 echo "Can't Find _viminfo & Exit"
fi
exit 0