"----------------------------------------------------
" vimrc file for ed lim
" @author - Ed Lim
"----------------------------------------------------
"------------ editor behaviour block ------------------
set ruler " show curser position at all times
set sw=8 " Use 8 spaces when text is indented
set tabstop=8 " sets how many spaces a tab is
"set ai " auto indent
"set si " smart indent - attempts to guess where to indent
set et " tabs converted to spaces, uncomment when needed
set incsearch " incremental search
set nohlsearch " no highlight on searching
set nowrapscan " turn off search wrapping
set nowrap " no text wraps
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set term=ansi
"set background=dark " user brighter color if xterm has a dark background
set noerrorbells " do not beep on errors
set ttyfast " Smoother scrolling
set mouse=a " have mouse enabled at all time
set virtualedit=all " allows curser to roam freely
set backspace=2 " allows backspacing over everything
set showmode " show current mode you are in
set showcmd " display incomplete commands
set showmatch " show matching braces
set undolevels=500 " set the number of undo's
set novisualbell " no sound on error
set t_vb= " turn off error bells
set noerrorbells " No sound on error
set title " Shows title in console window
set ls=2 " always show status line
set foldmethod=marker " fold method using markers
"set foldmethod=indent " fold method using indent
"-------------- backup block ------------------
set backup
set backupdir=$HOME/.VimData/vimbak
set directory=$HOME/.VimData/vimtmp
set errorfile=$HOME/.VimData/vimtmp/errors.vim
"------------ Graphical block -----------------
syntax on " Turns on syntax highlighting
set nu " Line numbers
"------------- Color definitions ----------------
hi Comment terM=bold cterm=NONE ctermfg=DarkGreen ctermbg=NONE gui=NONE guifg=Blue guibg=NONE
hi Constant term=underline cterm=NONE ctermfg=DarkRed ctermbg=NONE gui=NONE guifg=Magenta guibg=NONE
hi Special term=bold cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=SlateBlue guibg=NONE
"hi Identifier term=bold cterm=NONE ctermfg=Black ctermbg=NONE gui=NONE guifg=DarkCyan guibg=NONE
hi Statement term=bold cterm=NONE ctermfg=DarkBlue ctermbg=NONE gui=bold guifg=Brown guibg=NONE
hi PreProc term=underline cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=Purple guibg=NONE
hi Type term=underline cterm=NONE ctermfg=DarkBlue ctermbg=NONE gui=bold guifg=SeaGreen guibg=NONE
hi Underlined term=underline cterm=underline ctermfg=DarkMagenta gui=underline guifg=SlateBlue
hi Ignore term=NONE cterm=NONE ctermfg=white ctermbg=NONE gui=NONE guifg=bg guibg=NONE
"hi LineNr term=underline ctermfg=Black guifg=Black
" --------- key mappings --------------
" F1 show buffers
map <f1> :buffer<cr>
" F2 select buffer
map <f2> :buffer
Saturday, November 11, 2006
vimrc
Vi
What is VI?
A screen based Unix text editor.
Why VI?
Because its basic and it always come with any unix based operating system. In other words its always there!
Warning: Vi can be extremely confusing to use for a beginner but it is very powerful once mastered.
Basic Vi commands
How to get Vi to work?
On the Unix command prompt type
vi filename
Where filename is the name of the file you want to open or create
There are basically 3 different types of mode in Vi
1) Insert mode --> to get into text mode just hit the i key
2) Command mode --> to get into command mode from text mode just hit the Esc key
3) Visual mode --> to get into this mode hit the v key, this keys allows you to highlight portions of your code
Vi commands
Undo Command
u - undo the last command.
Cursor Positioning Commands
j - Moves cursor down one line, same column.
k - Moves cursor up one line, same column.
h -Moves cursor back one character.
l - Moves cursor forward one character.
$ - Moves cursor to end of current line.
:n - Moves cursor to beginning of line n.
Text Insertion Commands
i - Inserts text before cursor. Terminated by the escape key.
I - Inserts text at the beginning of the line. Terminated by the escape key.
DEL - Overwrites last character during text insertion.
ESC - Stops text insertion.
Text Deletion Commands
x - Deletes current character.
dd - Deletes current line.
dw - Deletes the current word.
d) - Deletes the rest of the current sentence.
D, d$ - Deletes from cursor to end of line.
P - Puts back text from the previous delete.
Cut and Paste Commands
yy - Puts the current line in a buffer. Does not delete the line from its current position.
p - Places the line in the buffer after the current position of the cursor.
Exiting vi
ZZ - Exits vi and saves changes.
:wq - Writes changes to current file and quits edit session.
:q! - Quits edit session (no changes made).
- Highlight the block of code you want to fold first, once highlighted you can hit the following key combination:
zc - creates the fold
zo - opens fold
zd - deletes fold
Split screen
To split a screen type this command in vi :sp
For vertical split, type :vs this splits it vertically
To navigate through the splits first hit Ctrl-W and then the arrow key to the direction of the split