---
title: "vim 使用 备忘"
author: "dogstar"
date: "2008-12-27T15:25:22Z"
tags: []
slug: "vim"
draft: false
lastmod: "2009-09-11T22:58:30Z"
id: 305703
url: "https://dogstar.iteye.com/blog/305703"
---

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