vim 使用 备忘
vim基本操作
i/I,a/A,o/O:插入
h,j,k,l:上下左右
ctrl+f:向下翻页
ctrl+b:向上翻页
v,V,ctrl+v:可视模式 n<>->n tab缩进
/[?]pattern:搜索
:%s/from/to/gc :询问替换
r/R:替换
d^:删至行首
D/d$:删至行尾
rx:删除一个字符
ynl/ynw:复制n个字符/单词
y$/Y:复制一行
ndd:删n行
p:粘帖
x:删除
u:取消上次操作
ctrl+r:回复上次操作
vim配置文件:
" This is my _vimrc under windows platform
" and it can be used on *nix too
" all the difference of them is the font setting session
" happy Viming, guys!
" copyLeft (#) Abruzzi John
" autoload _vimrc
autocmd! bufwritepost _vimrc source %
" vim 定制
set linebreak " line break
set nocompatible " no compatible
set history=400 " history
set ruler
set number " line number
set hlsearch " highlight search
set noincsearch " no in C search
set expandtab " expand table
set t_vb= "close bell
set foldmethod=marker
set tabstop=4 " table step
set shiftwidth=4
set nobackup " don't backup
set smarttab " smart table
set smartindent " smart indent
set autoindent " auto indent
set cindent "cindent
set cursorline " hightlight cursor line
"set guioptions-=m " 取消顶部菜单栏
set guioptions-=r " 取消右边滚动条
set guioptions-=L " 取消左边滚动条
set guioptions-=T " 取消顶部工具条
colorscheme desert " color scheme
filetype plugin indent on " filetype setting
set completeopt=longest,menu " for code complete
" the following function is used for show the status bar on the buttom
function! CurrectDir()
let curdir = substitute(getcwd(), "", "", "g")
return curdir
endfunction
set statusline=\ [file]\ %F%m%r%h\ %w\ \ [pwd]\ %r%{CurrectDir()}%h\ \ %=[line]\ %l,%c\ %=\ %P
" 字体
if has("win32")
set guifont=Courier_New:h10:cANSI
endif
" 设置语法高亮
if exists("syntax_on")
syntax reset
else
syntax on
endif
" plugin config begin
" NERDTree key-map
map <F10> :NERDTreeToggle<CR>
" plugin cofig end
" vim tab binding
map nt :tabnew %<cr> "open a new tab in normal mode
map tc :tabclose<cr> " close tab
map tn :tabnext<cr> " next tab
map tp :tabprev<cr> " preveiw tab
"绑定插入模式的hjkl
imap <c-j> <Down>
imap <c-k> <Up>
imap <c-h> <left>
imap <c-l> <Right>
" that's all, folks!
常用插件: 1.NERDTree 2.tagList
哈哈.谢谢abruzzi写这么多.我这里只是一些备忘.自己本身还没有很熟练.你写的越多越好,顺带学习一下.怎么会见怪 :)
vim中,最牛B的主题楼主都没有记录,我稍微给你补充一下吧,呵呵
1.global命令 global命令简写为g,是一个ex命令,使用范围广泛,功能强大。 一般使用形式: :g/{pattern}/{command} range : 范围,可选,默认为全文 pattern : 匹配模式(正则表达式) command : 当pattern匹配时,要执行的命令 你看看,这个命令的强大程度。如找到空行删除,找到以**开头的行删除等等等等,学习vim一定要学好这个,不然vim的优势体现的不明显。 更多信息可参看: http://blog.chinaunix.net/u2/83535/showart_1663002.html
2.宏 宏者,替换也。大多数编辑器都支持这个功能,但是向vi这样方便使用的却是没有几个,要知道宏,必须有寄存器的概念,有了寄存器,可以将多块内容同时粘贴到另一个文件buffer,然后,打乱顺序重新粘贴。 在normal模式下,使用q{宏名}开始记录宏,输入一系列的编辑命令后,按q退出录制。然后你的命令就存到{宏名}中了。录制好以后,就可以自定义播放次数。
3.其他相关插件 这个就不多说了,vim发展到今天这种地步,插件已经基本是:只有你想不到的,没有你找不到的,如果你觉得某些事应该可以很方便的完成,不妨去vim的插件库里小搜一下。
你不小心,写了这么多,再写的话有喧宾夺主之嫌,暂时打住,楼主不要见怪。