2007年09月17日 Monday , 1,330 次点击

<1> Removing an Automatic Indentation
    [0CTRL-D] removes all the automatic indents in the current and places the cursor at the beginning . This works in insert mode .
   
<2> Inserting Indent
    [CTRL-T] works as <TAB> , except its size is controlled by ‘shiftwidth’ option .
   
<3> Inserting Registers
    [CTRL-R CTRL-O <register>] pasts contents in the right form .
   
<4> Shift Details
    Usually [>>] puts in 4 spaces wherever the cursor is , if [:set shiftround] is set , [>>] moves the indent to the next shift-width boundary .
   
<5> Specifying a Formatting Program
    [:set equalprg=/usr/local/bin/indent] tells Vim to use GNU indent program when executing [=] .
   
<6> Defining a Comment
    Leave this block out .
   
<7> Customizing the C Indentation
    Leave this block out .
   
<8> Comparing Two Files
    1. Open two windows , set [:set scrollbind] , then when you scroll a window , the other fallows .
    2. [:set noscrollbind]
    3. [:syncbind] syncronizes the two windows .
   
<9> The Preview Window
    1. [:ptag <function>] opens a preview window for the defination of “function” .
    2. [:pclose] == [CTRL-Wz] == [ZZ]
   
<10> Match Pairs
    The “matchpairs” option controls what characters are matched by the % command .
    The default value is [:set matchpairs=(:),[:],{:}]
    To add “<>” , use [:set matchpairs+=<:>] .
   
<11> Showing Matches
    If [:set showmatch] is set , when you enter any type of bracket ( ( , ) , [ , ] , { , } ) , Vim will cause the cursor to jump to the matching bracket briefly .
    [:set matchtime=15] sets the jump to last 1.5s .
   
<12> Finding Unmatched Characters
    1. “[{" finds the previous unmatched { .
    2. "]{” finds the next unmatched { .
    3. “[}" finds the previous unmatched } .
    4. "]}” finds the next unmatched } .
    5. “[(" finds the previous unmatched ( .
    6. "](” finds the next unmatched ( .
    7. “[)" finds the previous unmatched ) .
    8. "])” finds the next unmatched ) .
   
<13> Method Location
    The fallowing commands move to the beginning or end of a Java method .
        1. [m : Search backward for the start of a method .
        2. [M : Search backward for the end of a method .
        3. ]m : … forward …
        4. ]M : … …

<14> Movement
    1. <count>[[ : Move backward to the preceding { in column 1 .
    <count>[] : Move backward to the preceding } in column 1 .
    <count>][ : Move forward to the next { in column 1 .
    <count>]] : Move forward to the next } in column 1 .
    2. Comment Moves
        The commands [ [/ ] and [ [* ] move you backward to the start of the first C comment it can find .
        The commands [ ]/ ] and [ ]* ] move you forward to the end of the last C comment it can find .
       
<15> Dealing with Multiple Directories
    1. [:set path^=../lib] sets a directory a part of the path list .
    2. If there is a block of text in the current file , which is : #include “pal.h” ; You place the cursor on pal.h , then execute [gf] , Vim will search through the path and open it .
    3. If “fr.c” is not in the current file and you want to edit it , use [:find fr.c]
    4. The include Path
        a. The “path” option is used to tell Vim where to look for files included in the current file .
        [:set path=directory,directory...]
        b. Some Special Directories
            ① [/etc/lib/*] means any directory under “/etc/lib” .
            ② [/etc/lib/**] means the entire tree under “/etc/lib” .
            ③ [first, ,last] : There is an empty string between “first” and “last” , it means the current directory .
            ④ [first,.,last] : . means the directory in which the file being edited resides .
           
<16> Defining a Definition
    Vim knows about C and C++ macro definitions . But to other languages , [:set define=<function>] tells Vim to look for macros that start with the string “function”.
   
<17> Locating Words
    1. [ [i ] searches for the first occurrence of the word under the cursor . Text insides comments is ignored .
    2. [ ]i ] searches for the next occurrence of the word under the cursor .
    3. [ [I ] or [ ]I ] list all the lines which contain the word .
   
<18> Multiple Error Lists
    The [:make <file>] generates an error list , Vim remembers 10 of them , [:colder] goes to a previous error list . [:cnewer] goes to a newer one .
   
<19> Customizing the “:make” Command
    1. By default , [:make] uses “make” as the program to execute . But to VC++ users , they should set [:set makeprg=nmake] .
    2. The “switchbuf” Option
        Normally when errors occur , Vim will display the offending file in the current window . When “switchbuf” is set , Vim splits the current window and opens the offending file in the new window .
        It has some values :
        ”,’split’,'useopen’ and ‘split,useopen’ .
        The description of “useopen” is in Chap 5 .
       
<20> Defining How a Tag Search is Done
    Vim performs a binary search by default , to force a linear search , use [:set notagbsearch] . It’s useful if you tag file is not sorted .
   
<21> Customizing the Syntax Highlighting
    Vim recognizes three types of terminals :
        term : Black-and-white terminal .
        cterm : Color terminal .
        GUI
    1. Color Terminal
        The following tells Vim to display comments red on blue , underlined :
        :highlight Comment cterm=underline ctermfg=red ctermbg=blue
    2. GUI Definition
        gui=<attribute> guifg=<color> guibg=<color>
    3. Syntax Elements
        a. Boolean : Constant , Error , Identifier , Macro , PreProc , SpecialComment , Structure , Typedef
        b. Character : Debug , Exception , Include , Number , Repeat , Statement , Tag
        c. Comment : Define , Float , Keyword , Operater , Special , StorageClass , Todo
        d. Conditional : Delimeter , Function , Label , PreCondit , SpecialChar , String ,Type
        e. Cursor : The character under the cursor .
            Directory : Directory names .
            ErrorMsg : Error messages displayed on the buttomline .
            IncSearch : The result of an incremental search .
            ModeMsg : The mode shown in the lower-left corner .
            MoreMsg : The prompt displayed if Vim is displayed a long message at the bottom of the screen and must display more .
            NonText : The Vim editor displays ~ for lines past the end of the file . It also uses @ to indicate a line that will not fit on the screen .
            Question : When Vim asks a question .
            SpecialKey : The [:map] command lists keyboard mapping . This defines the highlight to use for the special keys .
            StatusLine : The status line of the current window .
            StatusLineNC : Status line of other windows .
            Title : Titles for output from [:set all] , [:autocmd] , and so on .
            Visual : This color is used to highlight the visual block .
            VisualNOS : Visual-mode selection when Vim is “Not Owning the Selection” .This works only on X Window Systems .
            WarningMsg : Warning messages displayed on the last line of the window .
            WildMenu : Current match in the ‘wildmenu’ completion .
            LineNr : Line number for [:number] and [:#] commands , and when the ‘number’ option is set .
            Normal : Normal text .
            Search : The result of the last search when the ‘hlsearch’ option is enabled .
            User1~User9 : The ‘statusline’ option enables you to customize the statusline . You can use nine different highlights on this line , as defined by these names .
            Menu : Menu color for the GUI .
            Scrollbar : Scrollbar color for the GUI .
    4. Color Chart
        To see the colors , follow this :
            ① Edit $VIMRUNTIME/syntax/colortest.vim
            ② [:source %]
            Or use “Syntax|Color Test” menu in Gvim .
           
<22> The Syntax Option
            ① [:set syntax=on]
            ② [:set syntax=off]

Tags :

随机日志

來留言吧!


Please copy the string EK9s2N to the field below:

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

1 個留言

How To Start A Blog…

I couldn’t understand some parts of this article, but it sounds interesting…

It’s just a piece of note , so it is very simple , you may read the original book for ditail information .

 
 

留言板RSS 引用 URI

來留言吧!

«
»