いくつかのvimテクニック


前言
vimという超面白いエディタがずっと好きで、プログラマーにプログラミングの楽しさを本当に体得させ、迅速で簡単な命令でもっと多くの仕事をすることに力を入れることができます.簡単なので、強いです.学習を始めると、学習曲線はやや急峻ですが、よく使われるコマンドを身につけると、すばやく編集することができます.日常の学习の使用の中で、いくつかの経験を総括して、同时にいくつかの他の人の使う技巧を参考にして、続々と贴って、学びたい同志は见ることができて、もちろん自分で时々振り返ることができて、ほほほ.
 
vimのランタイム構成
vimのランタイムプロファイルはvimのランタイムのすべての動作のテンプレートであり、カスタマイズがうまくいけば、自分の編集速度が大幅に向上します.*nixの下でvimの配置は.vimrcのファイルの中で、持っています.プレフィックスのファイルは*nixシステムでは通常非表示です.Windowsでは、このファイルは通常_vimrc、vimのインストールディレクトリの下に置きます.
 
.vimrcファイル(2009-07-22)これが私が今使っているvimrcで、もう手に入れました.
" 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   
  
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 the back space
set backspace=indent,eol,start "      ,   vim         backspace      

colorscheme desert " color scheme   
  
let Tlist_Use_Right_Window=0    " for tag_list plugin only   
let Tlist_File_Fold_Auto_Close=1 " for tag_list plugin only   
  
let g:winManagerWindowLayout="FileExplorer|TagList" " for winmanager    
  
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   
  
" this is a setting of font   
if has("win32")   
    set guifont=Courier_New:h10:cANSI   
endif   
  
" make sure that syntax always on   
if exists("syntax_on")   
    syntax reset   
else   
    syntax on    
endif   
  

" java complete
if has("autocmd")
    autocmd Filetype java setlocal omnifunc=javacomplete#Complete
endif

""""""""""""""""""""""""""""""""""""""""""""""""""""""
let performance_mode=1

function! MySys()
    if has("win32")
        return "win32"
    elseif has("unix")
        return "unix"
    else
        return "mac"
    endif
endfunction

if MySys() == "unix" || MySys() == "mac"
    set shell=bash
else
    " set win32 shell
endif

" set auto read when file is changed from outside
if exists("&autoread")
    set autoread
endif

" enable the mouse
if exists("&mouse")
    set mouse=a
endif

" set mapleader
let mapleader=","
let g:mapleader=","

"fast saving
nmap <leader>x :xa!<cr>
nmap <leader>w :w!<cr>

"switch to current directory
map <leader>cd :cd %:p:h<cr>

" just for fun
map <F9> ggVGg?

" folding code
if exists("&foldenable")
    set fen
endif

if exists("&foldlevel")
    set fdl=0
endif

" tag list --
map <F3> :Tlist<cr>

"remove the windows ^M windows               ^M       ,       
noremap <leader>m :%s/"r//g<cr>

 
 
このrcファイルは前回の基础の上でいくつかの前人の配置をプラスして、比较的に自分の使い方の习惯に适して、そして大部分注釈があって、みんなは自分で参考にします.個人的には「史上最強」というような配置はなく、自分に合った配置しかないと思います.
 
ここには大侠のvim tipsがあります.興味があれば見てください.多くのテクニックを学ぶことができます.http://www.rayninfo.co.uk/vimtips.html
 
さて、今日はvimでファイルシステムを開くファイル、大文字と小文字の変換などのコマンドを貼ります.
 
---------------------------------------- 
" Exploring        vim explorer  ,vim7.x       ,         (:)

:e . : file explorer 
:Exp(lore) : file explorer note capital Ex 
:Sex(plore) : file explorer in split window 
:browse e : windows style browser 
:ls : list of buffers 
:cd .. : move to parent directory 
:args : list of files 
:args *.php : open list of files (you need this!) 
:lcd %:p:h : change to directory of current file         

---------------------------------------- 

" Changing Case 
guu : lowercase line        
gUU : uppercase line 
Vu : lowercase line 
VU : uppercase line 
g~~ : flip case line      ,     
vEU : Upper Case Word 
vE~ : Flip Case Word 
ggguG : lowercase entire file         

 
 
mapコマンドマッピング
mapコマンドは、vimを高度にカスタマイズ可能な編集システムにするために、ユーザにキーバインドをカスタマイズする機能を提供します.たとえば、他のエディタでCTRL+Sを使用して保存することに慣れている場合、vimではデフォルトの動作は:w、うまくいかないと思うかもしれませんが、ファイルを保存するコマンドをmappingすることができます.
 
imap :w
ここでiは挿入モードであることを示す.
 
ショートカットキーとしてFunctionキーを使うのが好きです.
 
imap :w!
imap :w!i
 
さて、今回はこれだけお話しします.文章が長すぎると、かえって学習効率に影響します.興味があれば、vimに関する以前のいくつかの文章を参考にしてください.
  • vimコマンドプロファイルhttp://abruzzi.iteye.com/blog/416049
  • vimプロファイルhttp://abruzzi.iteye.com/blog/273250
  •