##___[ gVim Quick Reference ]___##
##############################################################################
# Last Change: 09-Sep-2010.
# autodate.vim : A customizable plugin to update time stamps automatically. 
# http://www.vim.org/scripts/script.php?script_id=291
#
# ---------------------- #
# * Basic Commands       #
# * Advanced Commands    #
# ---------------------- #
# http://www.mteric.com/programming/gvimrefbasic.php
##############################################################################



######################-------------------------:
### Basic Commands ###    Advanced Commands    :
##############################################################################

# Changing Modes
==============================================================================
a       Enters edit mode 
        (cursor is placed after the current character)

i       Enters edit mode 
        (cursor is placed before the current character)
------------------------------------------------------------------------------
     
# Editing Text
==============================================================================
cc          Deletes the current line and leaves the cursor in insert mode.

c{motion}   Deletes the text based on the specified motion and leaves 
            the cursor in insert mode. 
            For example: c2w deletes the next two words.

C           Deletes to the end of the line and leaves the cursor 
            in insert mode. Same as c$.

dd          Deletes the current line.

ddp         Swaps two lines.

d{motion}   Deletes based on the specified motion. 
            For example: d3w deletes the next three words.

d$          deletes to the end of the line. 

D           Deletes to the end of the line. Same as d$.

[count]r    Replaces the current character with another. 
            For example: rx replaces the current character with 'x'.

[count]x    Removes [count] number of characters. 
            For example, x deletes a single character.
                        3x deletes three characters.

u           Undoes last action.

.           Repeats the last change. 
            For example, if you changed a word using cwtext, 
            then pressing '.' will repeat cw text again 
            where ever the cursor is located. 
------------------------------------------------------------------------------

# Navigation
==============================================================================
[count]h    Moves the cursor the specified number of characters 
            to the left. 
            Placing a number before a navigation command causes 
            it to be repeated that number of times. 
            For example: 4h moves the cursor left four characters.

[count]j    Moves the cursor the specified number of characters down.

[count]k    Moves the cursor the specified number of characters up.

[count]l    Moves cursor the specified number of characters to the right.

^           Moves the cursor to the first non-white space character 
            on the line.

0           Moves the cursor to the beginning of the line.

$           Moves the cursor to the end of the line.
------------------------------------------------------------------------------

# Opening and Creating Files
==============================================================================
:enew               Creates a new buffer in the current window.

:new                Creates a new buffer and splits the window.

:e[dit] {filepath}  Opens the specified file for editing.

:e[dit]             Re-opens the current file. This refreshes the file 
                    to apply changes that were made outside of gVim.

:sp {filepath}      Opens a file in split mode.
------------------------------------------------------------------------------

# Quitting
==============================================================================
:q[uit]     Quits Vim. 
            This command will not succeed if changes have been made 
            since last saving.

:q[uit]!    Closes the current file without saving changes.

:qa!        Quits the progam without saving changes.

:wq         Writes changes and quits.
     
# Yank and Put
==============================================================================
y{motion}   Yanks the specified text into a default register. 
            This is like copying. 
            For example: yw yanks the current word into the register.

[count]yy   Yanks a specified number of lines to the default register. 
            The count is optional.

p           Puts the text from the default register onto the screen. 
            This is like pasting.
------------------------------------------------------------------------------

# Yank and Put Using the Clipboard
==============================================================================
"*y{motion} Yanks the specified text to the clipboard. 
            The gVim GUI commands can be used for copying and 
            pasting (CTRL-C, CTRL-V), but you can also use the yank/put 
            commands to access the clipboard. 
            The commands are the same as normal yanking, 
            except "* is prepended to the command. 

"*yy        Copies the current line to the clipboard.

"*p         Pastes the text from the clipboard onto the screen.
------------------------------------------------------------------------------

:----------------------#########################
:    Basic Commands    ### Advanced Commands ###
##############################################################################

# Editing Text
==============================================================================
cas
    Removes the current sentence, regardless of the cursor position, 
    and leaves the cursor in insert mode. "Change A Sentence". 

cis
    Works the same way as cas, except it inserts a space after the 
    changed sentence, whereas cas does not. "Change Inner Sentence".

das
    Deletes the current sentence, regardless of the position of the cursor. 
    "Deletes A Sentence".

daw
    Deletes the current word, regardless of the position of the cursor. 
    "Deletes A Word".

dt{char}    
    Deletes everything 'til before the specified character on 
    the current line. 
    For example: 
    dt( - deletes everything up to the open parenthesis character.

gu{motion}  
    Changes text to lowercase.
    For example: guh - changes previous character to lowercase.

gU{motion}  
    Changes text to uppercase.
    For example: gUw - changes next word to uppercase.

"xyw
dw
"xp 
    Use this sequence of commands to replace a word with a yanked word. 
    For example, yank a word using "xyw. 
    This puts the word into register x. 
    Then navigate to the word you wish to replace. 
    Delete the word using dw. 
    Finally paste the text from register x using "xp. 
------------------------------------------------------------------------------

# Markers (AKA Marks)
==============================================================================
ma  
    Sets a marker with a label of 'a'. 
    Any alpha character can be substituted for 'a'.

'a  
    Jumps to a marker with a label of 'a'.

:marks  
    Lists available markers.
------------------------------------------------------------------------------
     
# Navigation
==============================================================================
CTRL + W, K     Move cursor up to next split window.

CTRL + W, J     Move cursor down to next split window.

CTRL + W, _     Maximizes the current split window.

number + G      Goes to the specified line number.

:set number     Shows line numbers in front of every line.

:set nonumber   Hides line numbers.

H or M or L     Moves cursor to Home, Middle, or Last 
                respectively in the current view.

zz              Centers current line vertically in the window.
------------------------------------------------------------------------------

# Searching and Substitution
==============================================================================
:/text/ 
    Searches for text. Case sensitive.
    Note: 
    pressing n jumps to the next match and N jumps to the previous match.

:/\ctext/   
    Searches for text. Case insensitive.

:nohls  
    Clears search highlighting.

:%s/fromText/toText/g   
    Substitues "fromText" with "toText".
        % means all lines.
        g means all occurances on a line.

:%s/searchText/&/g  
    Counts the number of occurances of "searchText" in the current file.
        The count is determined by the number of substitutions.

:s/,\( \)\@\!/, /g  
    Puts a space after every comma that doesn't already have one. 
    Uses negative lookahead.

:s/\.\(.*\)\,/\.\1 AS \'Client\1\'\,/   
    Changes "A.Name," to "A.Name AS 'ClientName',". Uses capturing.

------------------------------------------------------------------------------
     
# Syntax Highlighting
==============================================================================
:set syntax=language    
    Sets the syntax highlighting to the specified language.
    Common syntaxes: cpp, cs, html, sql, vb, xml.
------------------------------------------------------------------------------

# Using Asian Fonts (Unicode Encoding)
==============================================================================
set guifont=ms_gothic:h10:w5:
set enc=utf-8
set fenc=utf-8  
    Sets the GUI font to an appropriate unicode-supportive font and 
    changes the encoding to UTF-8 so that the file is saved using unicode. 
        Add the commands on the left to your _vimrc file. 
        This example uses "MS Gothic", which works well for Japanese.
------------------------------------------------------------------------------

##############################################################################
"" All Space to TAB
:set noexpandtab
:%retab!

"" All TAB to Space
:set expandtab
:%retab
##############################################################################