VIM

From wiki.kungfootek.net
Jump to: navigation, search


Working with Windows in Vim

This section shamelessly borrowed from Benjamin Kuperman

 :e filename      - edit another file
 :split filename  - split window and load another file
 ctrl-w up arrow  - move cursor up a window
 ctrl-w ctrl-w    - move cursor to another window (cycle)
 ctrl-w_          - maximize current window
 ctrl-w=          - make all equal size
 10 ctrl-w+       - increase window size by 10 lines
 :vsplit file     - vertical split
 :sview file      - same as split, but readonly
 :hide            - close current window
 :only            - keep only this window open
 :ls              - show current buffers1
 :b 2             - open buffer #2 in this window

Sudo from VIM

Getting root permissions while inside VIM

Sometimes you want to write to a read only file without losing your work or saving to a temporary file.

:w !sudo tee <FileName>

Change default TAB keystroke to 4 spaces

If you're doing any Programming in Python you definitely want to add this to your .vimrc.

set smartindent
set tabstop=4
set shiftwidth=4
set expandtab


Default Editor

Add this to your .bashrc

export VISUAL=vim

Reload your bash settings.

source ~/.bashrc

Dark background

Brighten the commented text in VIM!

If you have permission ( Not just access ) to make changes to the root environment:

 echo "set background=dark" >> /etc/vimrc

If you don't control root and only have access to your home folder :

 echo "set background=dark" >> ~/.vimrc

Vim Cheat Sheet

Vim cheat sheet for programmers screen.png