Vimscript:
to see a list of currently undefined variables:
-let
let count=1 #global
let s:count=11 #local
b: local to a buffer
w:local to a window
g:global
v:predefined by vim.
:unlet s:count #deletes the variable
variables survive ending of script. if ! exists("s:call_count")
let s:call_count=0

In Vim all that is not 0 is true.

############################################
Vim links:
shortcuts
shortcuts II
online vim book

Vimrc:
my .vimrc file is here.
For default setup in vim create a ~/.vimrc file and put it in the home directory:
:set=changes parameters afterwards
set number|nonumber
set option&#38=sets an option to its default value.
set option?=displays the options value.
set all=shows all possible options.
set autowrite=automatically write changes when exiting.
/* vim: set shiftwidth=4 autoindent : */
changes vims configuration, for this file only.
to enter your vimrc from within vim :e $MYVIMRC

Move Cursor
h/j/k/l=left/down/up/right.
:33=go to line 33.
o/O=insert at a new line below/above.
CTRL-]=go into function under cursor.
CTRL-t=go back.
''=moves cursor to its previous location.
*/#=travels searching, forwards/backwards.
//?a=go to next/previous a.
n/N=repeat search forwards/backwards.
:m2=move line to line number two.
:m+1=move line one down.
n/N=repeat last search forwards/backwards.

Move Screen
ctrl-o/n=older/newer file..
ctrl-6=last file.
gd=go to function/var.
gf=go to pathfile.
CTRL-^=switch files.
CTRL-]=go to definition.

File travel
when selecting files from then b
:e trees=go to file trees.
:bp=goes back from gf
:bf=go back from gf. (doesn't work)


Yank/Delete/Change
Optional precedences:d/y/c, delete/yank/change. none=movement only. a=all
x/X=delete infront/behind.
3x=delete 3 characters infront.
rx=replace character with x.
aw=all word
as=all sentence.
%=go to the matching pair.
ya)=yank all within current bracket.
[{/}=beginning/end of the block.
[/][=next/previous function.
[/]=previous/next empty line.
i}=all content in current bracket.
aB={} block.
cw=change word.
dd/3dd=delete 1/3 lines.


Substitute Text
`.=go to the line that you last edited.
:%s/ten/10/g=substitutes all "ten" with "10". (page 169) /s=lets user decide for each replace. a then means all.
%=all lines.
.,.+10=current line to tenth following line.
.,$=current line through end of work buffer.
1,$=all work buffer.
to replace a specific set of lines you can enter visual mode (v) and in there :
then you can type s/hero/HEEEEERO/g that replaces all instances within the selected area.

:/s/good/great/gci - substitutes good with great on the whole line and both ignores case
and prompts for confirmation
:12,100/x/y/gc -substitutes x with y for within lines 12-100 and confirms each replacement
K-looks up the word your cursor is on when you press it and displays the results
:s/sub_from/sub_to/g -substitutes, but only on current line.
s.,+5 s/a/vooow_i_found_an_a/g;
#replaces a with that sentence anywhere from currentline to currentline + 5.
$=last line. 1=first line.


Auto Complete:
ctrl-p|n=autofill.
<C-X><C-L>=Line complete SUPER USEFUL
set dictionary=file,file,...
sets files to be searched when doing autocomplete.
set dictionary=hemmi/kalli/siggi. adds those words to autocomplete list.
each search is stored. /=repeats last search.


Shell:
You can execute shell commands from within vim by simply entering :! while in command mode.
So, by entering the following command you can compile the file named test_app.c:
:!gcc test_app.c
:! perl %
vim -d file1 file2=shows the difference between the two files.


Help:
:help subject
to find out how to delete text, use this command: help deleting
:help usr_41.txt
:help function-list


Miscellaneous:
J=merge line with below.
:reg=display content of all registers.
1p=paste reg1
map <F2> :r!ls<CR>


ma-=make a bookmark and label it 'a'.
'a=go to bookmark labeled a.
'.=go to last line edited.
ma=Make a bookmark named a at the current cursor position.

A bookmark can be named any lowercase letter. You can't see the bookmark, but it's there!
`a=Go to bookmark a. Important: that's a backtick, not a single quote. The backtick is located to the left of the 1 on most keyboards. `.=Go to the line that you last edited. This is very useful!
If you need to scroll through the file to look something up, you can go back to where you were without bookmarking it by using the `. command.
gd=Go to the definition (or declaration) of the function or variable under the cursor.

>aB=indents the block you're in.
va{=highlights the block you're in.
da<=Delete an html tag.
dap=Delete current paragraph (handy to delete a whole function).
daw=Delete a word.
ctrl-A/X=in/de-crement a number under the cursor.
CTRL-R {register}.
previous=goes to previous file.
ga=show character info
typing vimtutor in the terminal gives you a vim tutor.
!!date=timestamp.

~=switch case.
guu=lowercase line
gUU=uppercase line