[wellylug] Vim Tips

John Grace j_r_grace at hotmail.com
Wed Aug 3 14:56:03 NZST 2005


>From: "Grant McLean" <grant at mclean.net.nz>
>Reply-To: wellylug at lists.naos.co.nz
>To: <wellylug at lists.naos.co.nz>
>Subject: [wellylug] Vim Tips
>Date: Tue, 9 Sep 2003 13:43:12 +1200 (NZST)
>
>Further to Brenda's email, I though I'd share some of my Vim usage tips.
>Please pitch in your favourites...
>
>
>Searching:
>
>The asterisk ('*') can be used for search forwards in the document for
>the word under the cursor.  The hash ('#') is the same but searches
>backwards.
>
>The percent symbol ('%') searches for (jumps to really) the bracket
>matching the one under the cursor or the next bracket in the file if
>there isn't one under the cursor
>
>   :set incsearch
>
>This turns on incremental search mode, so the search is executed as you 
>type.
>
>   :set ignorecase
>   :set nowrapscan
>
>make searches case-insensitive and don't wrap around to the beginning
>of the file if the search doesn't match.
>
>   :map <F12> :nohls<Enter>
>
>Programs the F12 key to turn off search term highlighting.
>
>Remember 'n' takes you to the next match and 'N' (shift-n) takes you
>to the previous match.
>
>
>Text Input:
>
>:map! <C-O> {<C-M>}<Esc>O<Tab>
>
>Programs Ctrl-O to 'open a matching pair of curly braces and position
>the cursor indented on the line between.  Note, the trailing '!' on the
>map makes the mapping work in insert mode.
>
>:map <F7> {gq}
>
>Programs F7 to re-flow the current paragraph, wrapping long lines and
>joining short ones.
>
>
>Using Marks:
>
>You can 'bookmark' the current cursor position by hitting 'm' followed
>by a letter.  I usually just do mm to create bookmark 'm'.
>
>You can return to a mark by typing a single quote followed by the letter
>(eg: 'm).  You can also use the backtick instead of the single quote.
>For reasons I can't quite explain, I prefer the backtick.
>
>You can delete everything from you current cursor position to a mark
>(eg: m) like this:
>
>   d`m
>
>Or yank (copy to a buffer) like this:
>
>   y`m
>
>And then paste the yanked text by moving somewhere else and pressing 'p'
>or 'P' to paste after or before the cursor respectively.
>
>The special mark called dot ('.') is automatically set to the last
>position in the file where you changed something.
>
>
>Shell Interaction:
>
>   !!command
>
>Replace the current line with the output of the command.  I often use
>
>   !!which perl
>
>and then insert #! at the beginning of the line.
>
>   :range!command
>
>Take all the lines in 'range' (1,10 = lines 1 to 10; % = all lines;
>.,$ = all lines from the current line to the end of the file), pipe
>them into command and replace them with the output of command.  Eg:
>
>   :%sort
>
>
>
>There are many many tips here:
>
>   http://vim.sourceforge.net/tips/index.php
>
>And a thread with a bunch of useful links for Vim+Perl:
>
>   http://www.perlmonks.org/index.pl?node_id=257782
>
>
>Anyone else care to share some goodies from their .vimrc?
>
>Cheers
>Grant
>
>
>
>
>--
>Wellington Linux Users Group Mailing List: wellylug at lists.naos.co.nz
>To Leave:  http://lists.naos.co.nz/mailman/listinfo/wellylug

_________________________________________________________________
Check out the latest video  @  http://xtra.co.nz/streaming




More information about the wellylug mailing list