Topic Contributors
creator avatar  
mreschke
Matthew Reschke
Site Developer
Created: Jul 22nd, 2008
Updated: Feb 21st, 2012
File
Download Selected (zip)
Download Selected (tar.gz)
Edit
Select All
Select None
View
Detail
Detail Preview
Icons
Preview
Show Hidden
Hide Hidden
Full Manager
Reset Defaults
Open In New Tab
Open In New Window
List Archive Contents
Download File
Open
Download Folder (as .zip)
VIM
Post # 88 permalink Topic #88 by mreschke on 2008-07-22 19:56:07 (viewed 636 times)

Install VIM[-][- -][++]

Debian Based[-][- -][++]

Code Snippet
apt-get install vim

mReschke personal Setup[-][- -][++]

Permanent with vimrc[-][- -][++]

Add the options to /etc/vim/vimrc (at the very bottom add:)

Code Snippet

set tabstop=4
set ts=4
set sw=4
"expandtab sets tabs to spaces
"set expandtab
set nowrap
syntax enable
set autoindent
set foldmethod=manual
let php_folding = 1
set ignorecase
set nu! "Line Numbers
set guioptions+=b "Bottom Scroll Bar for gVim
set mouse=a

Misc Commands in VIM[-][- -][++]

Code Snippet
:retab             Convert tabs to spaces (# spaces set by tabstop)

Usage[-][- -][++]

Folding[-][- -][++]

Code Snippet
zf#j  creates a fold from the cursor down  #  lines.
zf/string creates a fold from the cursor to string .
zj moves the cursor to the next fold.
zk moves the cursor to the previous fold.
za toggles fold (open/closed)
zo opens a fold at the cursor.
zO opens all folds at the cursor.
zm increases the foldlevel by one.
zM closes all open folds.
zr decreases the foldlevel by one.
zR decreases the foldlevel to zero -- all folds will be open.
zd deletes the fold at the cursor.
zE deletes all folds.
[z move to start of open fold.
]z move to end of open fold.

Viewports[-][- -][++]

Tabs[-][- -][++]

Sessions and Views[-][- -][++]

  1. http://www.adp-gmbh.ch/vim/short.html
    Code Snippet
    I use :mksession! vim to save my current tab/viewpoint sessions
    Load with vim -S sessionfile
    

Cheat Sheets[-][- -][++]

  1. http://www.catswhocode.com/blog/100-vim-commands-every-programmer-should-know
  2. http://www.tuxfiles.org/linuxhelp/vimcheat.html
Code Snippet
gt         switch tabs
:tabe      open blank new tab
:tab ball  put all open files in tabs
:Sex       (or just :S I think) split window and show file manager
:e .       show file manager in current directory

:sp  will split the Vim window horizontally. Can be written out entirely as  :split
 can use :sp filename
:vsp will split the Vim window vertically. Can be written out as :vsplit

Ctrl-w Ctrl-w moves between Vim viewports.

Ctrl-w j moves one viewport down.

Ctrl-w k moves one viewport up.

Ctrl-w h moves one viewport to the left.

Ctrl-w l moves one viewport to the right.

Ctrl-w = tells Vim to resize viewports to be of equal size.

Ctrl-w - reduce active viewport by one line.

Ctrl-w + increase active viewport by one line.

Ctrl-w q will close the active window.

Ctrl-w r will rotate windows to the right.

Ctrl-w R will rotate windows to the left.

:%s/searchthis/replacewiththis/g

:noh (removes your last search highlights)

/ (just hit / to search for something)

:w (write changes)

:wq (write changes and quit)

:q! (quit without writing changes)

Errors[-][- -][++]

Error: Sorry, this command is not available in this version
Solution: Install the full version, with your package manager just install vim (apt-get install vim)