| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- set nocompatible "Don't have to try to be compatible with old vi
- """"""""
- "" Plugin Loading with Pathogen
- """""""""""""""""""""""""""""""""""""""""""""""""""
- call pathogen#infect()
- """"""""
- "" Environment
- """""""""""""""""""""""""""""""""""""""""""""""""""
- " Determine what kind of machine we're on e.g. Linux, Darwin, Win(?)
- if has("unix")
- " remove the newline character from the uname command
- let s:uname = substitute(system("uname"), "\n", "", "")
- endif
- """"""""
- "" 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 splitright "New splits appear right of current window
- set ttyfast "Smooth movement
- " Persistent undo
- if has("persistent_undo")
- set undofile
- set undodir=~/.vimundo
- endif
- set ttymouse=xterm2
- if has("autocmd")
- " Enable filetype specific features
- filetype plugin indent on
- " Clear existing autocmd
- autocmd!
- " When editing a file, always jump to the last cursor position
- autocmd BufReadPost *
- \ if line("'\"") > 0 && line ("'\"") <= line("$") |
- \ exe "normal! g'\"" |
- \ endif
- autocmd WinEnter * setlocal cursorline
- autocmd WinLeave * setlocal nocursorline
- " Source the vimrc file after saving it
- autocmd bufwritepost .vimrc source $MYVIMRC
- " A way to specify startup actions
- autocmd VimEnter * call StartUp()
-
- " if the last window is NERDTree, then close Vim
- "autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
-
- else
- set autoindent on
- endif
- """"""""
- "" Start Up
- """""""""""""""""""""""""""""""""""""""""""""""""""
- function! StartUp()
- " Stuff in here will be called by autocmd below
- " example, start NERDTree if vim called with no arguments
- if 0 == argc()
- NERDTree
- end
- endfunction
- """"""""
- "" Tabs and Text Formatting
- """"""""""""""""""""""""""""""""""""""""""""""""""""""
- set expandtab " change to single spaces
- set tabstop=2 " actual tab press distance
- set shiftround " indent to nearest tabstops
- set shiftwidth=2 " amount to indent with > and <
- set smarttab " backspace tabs where appropriate even if spaces
- set softtabstop=2 " let backspace delete indent
- set wrap lbr " wrap long lines of text
- set backspace=eol,start,indent "backspace over everything
- set textwidth=80
- set colorcolumn=+1 " mark out the limits of the textwidth
- """"""""
- "" UI - Colours
- """"""""""""""""""""""""""""""""""""""""""""""""""""""
- syntax enable
- colorscheme solarized
- set t_Co=16
- set background=dark
- hi Folded ctermfg=darkred "set colour for folded lines
- """"""""
- "" UI - Numbering
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""
- set number "show line numbers
- set ruler "show row,col count in status line
- set rulerformat=%55(%{strftime('%a\ %b\ %e\ %I:%M\ %p')}\ %5l,%-6(%c%V%)\ %P%)
- set laststatus=2 "always show a status line
- "set relativenumber "current line always 0 (requires 7.3 and up)
- """"""""
- "" UI - Code Folding
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""
- set foldmethod=indent
- set foldlevel=10
- set foldtext=FoldText()
- """"""""
- "" 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!
- " Edit .vimrc
- map <leader>v :e $MYVIMRC<CR>
- " More convenient escape
- imap ii <Esc>
- imap II <Esc>
- " Add extra lines up and down
- nmap <leader>j o<Esc>k
- nmap <leader>k O<Esc>j
- nmap <silent> <leader>n :set number!<CR>
- nmap <silent> <leader>w :set wrap!<CR>
- " Toggle paste mode - no autoindenting of pasted material
- nmap <silent> <leader>p :set paste! paste?<CR>
- " Toggle visible whitespace characters
- nmap <silent> <leader>l :set list!<CR>
- " Toggle scrollbind for moving multiple splits in sync together
- nmap <silent> <leader>s :set scrollbind! scrollbind?<CR>
- " Toggle mouse support.
- nnoremap <leader>m :call ToggleMouse()<CR>
- " Toggle NERDTree instead of the normal dir browser... Doesn't seem to work yet
- nnoremap <silent> <leader>d :NERDTreeToggle<CR>
- " Toggle Commenting out lines with NERDCommenter
- nnoremap <silent> <leader>, :call NERDComment("n", "toggle")<CR>
- vnoremap <silent> <leader>, <ESC>:call NERDComment("x", "toggle")<CR>
- " Traverse undo tree with Gundo!
- nnoremap <leader>u :GundoToggle<CR>
- " Search under cursor with ack!
- nnoremap <leader>a :Ack <cword><CR>
- nnoremap <leader>A :Ack -a <cword><CR>
- vnoremap <leader>a :Ack <cword><CR>
- vnoremap <leader>A :Ack -a <cword><CR>
- """"""""
- "" Key Remaps - Movement and Windows
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""
- " jump to beginning and end of line easier
- nmap H ^
- nmap L $
- " Smart way to move between windows
- nmap <C-j> <C-W>j
- nmap <C-k> <C-W>k
- nmap <C-h> <C-W>h
- nmap <C-l> <C-W>l
- " mapping to make movements operate on 1 screen line in wrap mode
- onoremap <silent> <expr> j ScreenMovement("j")
- onoremap <silent> <expr> k ScreenMovement("k")
- onoremap <silent> <expr> 0 ScreenMovement("0")
- onoremap <silent> <expr> ^ ScreenMovement("^")
- onoremap <silent> <expr> $ ScreenMovement("$")
- nnoremap <silent> <expr> j ScreenMovement("j")
- nnoremap <silent> <expr> k ScreenMovement("k")
- nnoremap <silent> <expr> 0 ScreenMovement("0")
- nnoremap <silent> <expr> ^ ScreenMovement("^")
- nnoremap <silent> <expr> $ ScreenMovement("$")
- """"""""
- "" Plugin options
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""
- " let g:NERDTreeQuitOnOpen = 1
- " Having problems showing NERDTree arrows in OS X
- if s:uname == "Darwin"
- let g:NERDTreeDirArrows=0
- endif
- " let g:SuperTabDefaultCompletionType = 'context'
- """"""""
- "" Functions, the Givers of Power (in order of use)
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""
- function! FoldText()
- 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
- function! ToggleMouse()
- if &mouse == 'a'
- set mouse=
- echo "Mouse usage disabled"
- else
- set mouse=a
- echo "Mouse usage enabled"
- endif
- endfunction
- function! ScreenMovement(movement)
- if &wrap
- return "g" . a:movement
- else
- return a:movement
- endif
- endfunction
- " Colemak layout for INSERT mode only
- " Qwerty - qwertyuiopasdfghjkl;'zxcvbnm,./
- " Colemak - qwfpgjluy;arstdhneio'zxcvbkm,./
- "inoremap <silent> e f
- "inoremap <silent> r p
- "inoremap <silent> t g
- "inoremap <silent> y j
- "inoremap <silent> u l
- "inoremap <silent> i u
- "inoremap <silent> o y
- "inoremap <silent> p ;
- "inoremap <silent> s r
- "inoremap <silent> d s
- "inoremap <silent> f t
- "inoremap <silent> g d
- "inoremap <silent> j n
- "inoremap <silent> k e
- "inoremap <silent> l i
- "inoremap <silent> ; o
- "inoremap <silent> n k
- "inoremap <silent> E F
- "inoremap <silent> R P
- "inoremap <silent> T G
- "inoremap <silent> Y J
- "inoremap <silent> U L
- "inoremap <silent> I U
- "inoremap <silent> O Y
- "inoremap <silent> P :
- "inoremap <silent> S R
- "inoremap <silent> D S
- "inoremap <silent> F T
- "inoremap <silent> G D
- "inoremap <silent> J N
- "inoremap <silent> K E
- "inoremap <silent> L I
- "inoremap <silent> : O
- "inoremap <silent> N K
|