Skip to content

Instantly share code, notes, and snippets.

@keybits
Forked from stungeye/vim.md
Created October 30, 2012 20:47
Show Gist options
  • Save keybits/3982924 to your computer and use it in GitHub Desktop.
Save keybits/3982924 to your computer and use it in GitHub Desktop.
Improving my VIM

Setting up Pathogen

cd ~
mkdir .vim
cd .vim 
git clone git://github.com/tpope/vim-pathogen.git

Setting up Solarized

First step for Ubuntu: Set Solarized as your console scheme.

Be sure to fix the dircolors. See bottom of gist.

Next:

cd ~\.vim
mkdir bundle
cd bundle
git clone git://github.com/altercation/vim-colors-solarized.git

Solarized for Putty

If you want the Solarized colour scheme to work from a Windows Putty connection:

Run this reg file. Edit the name of the session first.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\settlers]
"Colour0"="131,148,150"
"Colour1"="147,161,161"
"Colour2"="0,43,54"
"Colour3"="7,54,66"
"Colour4"="0,43,54"
"Colour5"="238,232,213"
"Colour6"="7,54,66"
"Colour7"="0,43,56"
"Colour8"="220,50,47"
"Colour9"="203,75,22"
"Colour10"="133,153,0"
"Colour11"="88,110,117"
"Colour12"="181,137,0"
"Colour13"="101,123,131"
"Colour14"="38,139,210"
"Colour15"="131,148,150"
"Colour16"="211,54,130"
"Colour17"="108,113,196"
"Colour18"="42,161,152"
"Colour19"="147,161,161"
"Colour20"="238,232,213"
"Colour21"="253,246,227"

Setting up NerdTree

cd ~\.vim\bundle
git clone git://github.com/scrooloose/nerdtree.git

Setting up NerdCommenter

cd ~\.vim\bundle
git clone git://github.com/scrooloose/nerdcommenter.git

Installing Snipmate plugin and collection of snips

cd ~\.vim\bundle
git clone git://github.com/tomtom/tlib_vim.git
git clone git://github.com/MarcWeber/vim-addon-mw-utils.git
git clone git://github.com/spf13/snipmate.vim.git

##Current .vimrc

set nocompatible
autocmd!
filetype off
runtime! autoload/pathogen.vim
silent! call pathogen#helptags()
silent! call pathogen#runtime_append_all_bundles()
filetype plugin indent on

scriptencoding utf-8
syntax enable

if has ('gui_running')
    if has('gui_gtk2')
        set guifont=Bitstream\ Vera\ Sans\ Mono\ 12
    else
        set guifont=Bitstream_Vera_Sans_Mono:h12
    end
    set guioptions-=T "Removes toolbar
else
    " Fix for ubuntu terminal
    " Had to also install solarized for Gnome terminal for this to work
    " http://www.webupd8.org/2011/04/solarized-must-have-color-paletter-for.html
    set t_Co=256
    " Uncomment the following line if you want to support terminal vim without special colour schemes.
    " let g:solarized_termcolors=256
endif

set background=dark
colorscheme solarized

set encoding=utf-8
set virtualedit=onemore "Allow for cursor beyond last char
set mouse=a     "Enable the mouse.
set nu          "Show line numbers
set showmatch   "Show matching parens/braces
set hlsearch    "Highlight search terms
set incsearch   "show search matches as you type
set ignorecase  "Case insensitive search
set smartcase   "Ignore case is search is all lower, otherwise don't.
set autoindent
set backspace=indent,eol,start
set shiftwidth=4
set expandtab
set tabstop=4
set softtabstop=4 
set visualbell
set nowrap

" Changed <leader> from \ to ,
let mapleader=','

"Yank until end of line
nnoremap Y y$  
"$ moves after the last character
nnoremap $ $l
"Change Working Directory to that of the current file
nmap <silent> <leader>cd :lcd %:h<CR>
"Visual mode shifting (does not exit visual mode)
vnoremap < <gv
vnoremap > >gv
"clear highlighted search
nmap <silent> <leader>/ :nohlsearch<CR>
"Yank and Past to OS clipboard with ,y and ,p
nmap <leader>y "+yy
nmap <leader>p "+p
" Edit the vimrc file
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
" Force me to use hjkl
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>

"NerdTree
map <C-e> :NERDTreeToggle<CR>
nmap <leader>nt :NERDTreeFind<CR>

" Easy window navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l

autocmd BufRead,BufNewFile *.haml setfiletype haml
autocmd BufRead,BufNewFile *.sass setfiletype sass
autocmd BufRead,BufNewFile *.php set ft=php.html "Allow HTML snippets from within PHP
autocmd FileType ruby,haml,sass setlocal tabstop=2 softtabstop=2 shiftwidth=2

HAML and SASS Support

http://github.com/tpope/vim-haml

Fixing the DIRCOLORS for the Ubuntu Terminal

Place the following in ~/.dircolors

# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
# Copyright (C) 1996, 1999-2010 Free Software Foundation, Inc.
# Copying and distribution of this file, with or without modification,
# are permitted provided the copyright notice and this notice are preserved.
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.
# Below, there should be one TERM entry for each termtype that is colorizable
TERM Eterm
TERM ansi
TERM color-xterm
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM cons25
TERM console
TERM cygwin
TERM dtterm
TERM eterm-color
TERM gnome
TERM gnome-256color
TERM jfbterm
TERM konsole
TERM kterm
TERM linux
TERM linux-c
TERM mach-color
TERM mlterm
TERM putty
TERM rxvt
TERM rxvt-256color
TERM rxvt-cygwin
TERM rxvt-cygwin-native
TERM rxvt-unicode
TERM rxvt-unicode256
TERM screen
TERM screen-256color
TERM screen-256color-bce
TERM screen-bce
TERM screen-w
TERM screen.linux
TERM vt100
TERM xterm
TERM xterm-16color
TERM xterm-256color
TERM xterm-88color
TERM xterm-color
TERM xterm-debian
# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white

## dircolors 256 COLOR SUPPORT (see here: http://www.mail-archive.com/bug-coreutils@gnu.org/msg11030.html)
# Text 256 color coding:
# 38;5;COLOR_NUMBER
# Background 256 color coding:
# 48;5;COLOR_NUMBER

NORMAL 00;38;5;244 # no color code at all
#FILE 00 # regular file: use no color at all
# RESET 0 # reset to "normal" color
DIR 00;38;5;33 # directory 01;34
LINK 01;38;5;33 # symbolic link. (If you set this to 'target' instead of a
 # numerical value, the color is as for the file pointed to.)
# MULTIHARDLINK 00 # regular file with more than one link
FIFO 48;5;230;38;5;136;01 # pipe
SOCK 48;5;230;38;5;136;01 # socket
DOOR 48;5;230;38;5;136;01 # door
BLK 48;5;230;38;5;244;01 # block device driver
CHR 48;5;230;38;5;244;01 # character device driver
ORPHAN 48;5;235;38;5;160 # symlink to nonexistent file, or non-stat'able file
SETUID 48;5;160;38;5;230 # file that is setuid (u+s)
SETGID 48;5;136;38;5;230 # file that is setgid (g+s)
# CAPABILITY 30;41 # file with capability
STICKY_OTHER_WRITABLE 48;5;64;38;5;230 # dir that is sticky and other-writable (+t,o+w)
OTHER_WRITABLE 48;5;235;38;5;33 # dir that is other-writable (o+w) and not sticky
STICKY 48;5;33;38;5;230 # dir with the sticky bit set (+t) and not other-writable
# This is for files with execute permission:
EXEC 01;38;5;64
# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')
# If you use DOS-style suffixes, you may want to uncomment the following:
#.cmd 01;32 # executables (bright green)
#.exe 01;32
#.com 01;32
#.btm 01;32
#.bat 01;32
# Or if you want to colorize scripts even if they do not have the
# executable bit actually set.
#.sh 01;32
#.csh 01;32

 # archives or compressed (violet + bold for compression)
.tar    00;38;5;61
.tgz    01;38;5;61
.arj    01;38;5;61
.taz    01;38;5;61
.lzh    01;38;5;61
.lzma   01;38;5;61
.tlz    01;38;5;61
.txz    01;38;5;61
.zip    01;38;5;61
.z      01;38;5;61
.Z      01;38;5;61
.dz     01;38;5;61
.gz     01;38;5;61
.lz     01;38;5;61
.xz     01;38;5;61
.bz2    01;38;5;61
.bz     01;38;5;61
.tbz    01;38;5;61
.tbz2   01;38;5;61
.tz     01;38;5;61
.deb    01;38;5;61
.rpm    01;38;5;61
.jar    01;38;5;61
.rar    01;38;5;61
.ace    01;38;5;61
.zoo    01;38;5;61
.cpio   01;38;5;61
.7z     01;38;5;61
.rz     01;38;5;61
.apk    01;38;5;61

# image formats (yellow)
.jpg    00;38;5;136
.JPG    00;38;5;136 #stupid but needed
.jpeg   00;38;5;136
.gif    00;38;5;136
.bmp    00;38;5;136
.pbm    00;38;5;136
.pgm    00;38;5;136
.ppm    00;38;5;136
.tga    00;38;5;136
.xbm    00;38;5;136
.xpm    00;38;5;136
.tif    00;38;5;136
.tiff   00;38;5;136
.png    00;38;5;136
.svg    00;38;5;136
.svgz   00;38;5;136
.mng    00;38;5;136
.pcx    00;38;5;136
.dl     00;38;5;136
.xcf    00;38;5;136
.xwd    00;38;5;136
.yuv    00;38;5;136
.cgm    00;38;5;136
.emf    00;38;5;136
.eps    00;38;5;136

# files of interest (base1 + bold)
.pdf    01;38;5;245
.tex    01;38;5;245
.rdf    01;38;5;245
.owl    01;38;5;245
.n3     01;38;5;245
.tt     01;38;5;245
.nt     01;38;5;245

# "unimportant" files as logs and backups (base01)
.log    00;38;5;240
.bak    00;38;5;240
.aux    00;38;5;240
.bbl    00;38;5;240
.blg    00;38;5;240

# audio formats (orange)
.aac    00;38;5;166
.au     00;38;5;166
.flac   00;38;5;166
.mid    00;38;5;166
.midi   00;38;5;166
.mka    00;38;5;166
.mp3    00;38;5;166
.mpc    00;38;5;166
.ogg    00;38;5;166
.ra     00;38;5;166
.wav    00;38;5;166
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
.axa    00;38;5;166
.oga    00;38;5;166
.spx    00;38;5;166
.xspf   00;38;5;166

# video formats (as audio + bold)
.mov    01;38;5;166
.mpg    01;38;5;166
.mpeg   01;38;5;166
.m2v    01;38;5;166
.mkv    01;38;5;166
.ogm    01;38;5;166
.mp4    01;38;5;166
.m4v    01;38;5;166
.mp4v   01;38;5;166
.vob    01;38;5;166
.qt     01;38;5;166
.nuv    01;38;5;166
.wmv    01;38;5;166
.asf    01;38;5;166
.rm     01;38;5;166
.rmvb   01;38;5;166
.flc    01;38;5;166
.avi    01;38;5;166
.fli    01;38;5;166
.flv    01;38;5;166
.gl     01;38;5;166
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
.axv 01;38;5;166
.anx 01;38;5;166
.ogv 01;38;5;166
.ogx 01;38;5;166

And then set up your .bashrc to use these colors:

eval $(dircolors -b $HOME/.dircolors)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment