Code tagged with vim

VIM Tips

gk, gj    - Move up or down one screen line.  (Helpful if lines wrap.)

ga        - Display ASCII, hex and octal value of character under cursor.
            Helpful to search/replace control characters.  For example,
            /x1a will search for Control-Z (^Z).  ( is not literal,
            it means hit Control and v at the same time.)

gd        - Jump to declaration of local variable in a C program.
            This doesn't seem to work for multiple declarations on one line.
ge        - Move to end of previous word.
gE        - Same thing, but words are considered separated by whitespace.
W         - Go to beginning of next word after whitespace.
B         - Go to character after closest whitespace left of cursor.
E         - Go to character before closest whitespace right of cursor.
'.        - Jumps to last modified line.
`.        - Jumps to last modified position.

;         - Repeat last character search (f,F,t,T).
,         - Repeat last character search in the other direction.

C-x C-f   - Complete filename under cursor
  
g    - Display byte, word, line, etc. cursor is on.
go - Go to count byte.

     - Decrements first number after the cursor.
     - Increments first number after the cursor. 

read !... - Inserts standard output of shell command.

     - Moves cursor to beginning of command-line.
     - Moves cursor to end of command-line.
     - Deletes word before cursor on command-line.
     - Wipes command-line clean.
[I        - Grep current buffer for word under cursor.

vi *.txt                   - Open a series of files and replace all
argdo %s/pat/rep/gc | wn     occurrences of pat with rep.

set shortmess=a     Outlaws "Hit ENTER to continue" prompts.
Language Shell/Scripting / Tagged with vi, vim

Remove carriage returns (^M) from file using vi editor

Posted by Chad Humphries about 1 year ago
" 1. Load file into vi
" 2. Be sure to use the  for this to work
" 3. :1,$s///g

" Basically this starts at line 1, to end of file ($), substitutes (s) ^M with empty (//), repeating on same line ok (g)
:1,$s/^M//g
Language Unknown / Tagged with vim

How to use VIM with Rails

A very nice guide to using VIM for all of your rails/ruby work.
Language Ruby / Tagged with vim