set nocompatible "Don't have to try to be compatible with old vi """""""" "" Plugin Loading with Pathogen """"""""""""""""""""""""""""""""""""""""""""""""""" call pathogen#infect() """""""" "" Start Up """"""""""""""""""""""""""""""""""""""""""""""""""" function! StartUp() if 0 == argc() NERDTree end endfunction autocmd VimEnter * call StartUp() """""""" "" General Behaviours """"""""""""""""""""""""""""""""""""""""""""""""""" set autoread "Read a file if it's changed from outside of vim set splitbelow "New splits appear below current window instead of above set ttyfast "Smooth movement " Enable filetype specific features filetype plugin on filetype indent on "if version >= 700 " set mouse=a "mouse support for 7.x, but don't use this if we use screen " because it has no effect, and then just becomes annoying for copy/paste "endif " Source the vimrc file after saving it autocmd! bufwritepost .vimrc source $MYVIMRC " Remember last location in file " Only do this part when compiled with support for autocommands if has("autocmd") augroup redhat " In text files, always limit the width of text to 78 characters autocmd BufRead *.txt set tw=78 " When editing a file, always jump to the last cursor position autocmd BufReadPost * \ if line("'\"") > 0 && line ("'\"") <= line("$") | \ exe "normal! g'\"" | \ endif augroup END endif """""""" "" Formatting """""""""""""""""""""""""""""""""""""""""""""""""""""" set tabstop=4 "actual tab press distance set shiftwidth=4 "for autoindent set softtabstop=4 " let backspace delete indent set expandtab "change to single spaces set autoindent "use last line to set next indent set smartindent "guess harder, based on C-like language set wrap lbr "wrap long lines of text set backspace=eol,start,indent "backspace over everything """""""" "" UI - Colours """""""""""""""""""""""""""""""""""""""""""""""""""""" syntax enable set t_Co=16 set background=dark colorscheme solarized hi Folded ctermfg=darkred "set colour for folded lines if version >= 730 set colorcolumn=80 endif """""""" "" UI - Numbering """""""""""""""""""""""""""""""""""""""""""""""""""""""" set number "show line numbers set ruler "show row,col count in status line set laststatus=2 "always show a status line if version >= 730 set relativenumber "current line always 0 (requires 7.3 and up) endif """""""" "" UI - Code Folding """""""""""""""""""""""""""""""""""""""""""""""""""""""" set foldmethod=indent set foldlevel=5 set foldtext=MyFoldText() function! MyFoldText() let line = getline(v:foldstart) let indent = indent(v:foldstart) let indentOnly = strpart(line, 0, indent-1) let linecount = v:foldend+1 - v:foldstart let plural = "" if linecount != 1 let plural = "s" endif let foldtext = '+'.indentOnly.'... ('.linecount.' More lines)' return foldtext endfunction """""""" "" UI - Search """""""""""""""""""""""""""""""""""""""""""""""""""""""" set hlsearch "make searches highlighted set incsearch "vim will search as you type! set ignorecase "ignore case for searches set smartcase " well, unless a user puts in uppercase search characters set magic "enables wildcard searching """""""" "" Key Remaps and Shortcuts """""""""""""""""""""""""""""""""""""""""""""""""""""""" let mapleader = "," "Leader key lets you make more kinds of shortcuts! " More convenient escape imap ii imap II " Add extra lines up and down map j ok map k Oj """""""" "" Key Remaps - Movement and Windows """""""""""""""""""""""""""""""""""""""""""""""""""""""" " Smart way to move btw. windows map j map k map h map l " window resizing noremap + 10+ noremap - 10- " mapping to make movements operate on 1 screen line in wrap mode function! ScreenMovement(movement) if &wrap return "g" . a:movement else return a:movement endif endfunction onoremap j ScreenMovement("j") onoremap k ScreenMovement("k") onoremap 0 ScreenMovement("0") onoremap ^ ScreenMovement("^") onoremap $ ScreenMovement("$") nnoremap j ScreenMovement("j") nnoremap k ScreenMovement("k") nnoremap 0 ScreenMovement("0") nnoremap ^ ScreenMovement("^") """""""" "" Plugin options """""""""""""""""""""""""""""""""""""""""""""""""""""""" " let g:NERDTreeQuitOnOpen = 1 let g:SuperTabDefaultCompletionType = "context"