Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 351 lines (274 sloc) 9.47 KB
set runtimepath+=~/.vim/localfiles/
source ~/.vim/bundles.vim
" Vim settings {{{
syntax enable " Turn on syntax highlighting.
runtime macros/matchit.vim " Load the matchit plugin.
set showcmd " Display incomplete commands.
set showmode " Display the mode you're in.
set backspace=indent,eol,start " Intuitive backspacing.
set nofoldenable
set hidden " Handle multiple buffers better.
set wildmenu " Enhanced command line completion.
set wildmode=list:longest " Complete files like a shell.
set ignorecase " Case-insensitive searching.
set smartcase " But case-sensitive if expression contains a capital letter.
set number " Show line numbers.
set ruler " Show cursor position.
set incsearch " Highlight matches as you type.
set hlsearch " Highlight matches.
set nowrap " Turn on line wrapping.
set scrolloff=7 " Show lines of context around the cursor.
set winwidth=80
set listchars=tab:▸\ ,eol:¬,trail:.
set title " Set the terminal's title
set visualbell " No beeping.
set equalalways
set noswapfile
set nobackup " Don't make a backup before overwriting a file.
set nowritebackup " And again.
set directory=$HOME/.vim/tmp//,. " Keep swap files in one location
set autoindent
set expandtab
set laststatus=2 " Show the status line all the time
set pastetoggle=<F2>
let mapleader = ","
nnoremap \ ,
set showmatch
set encoding=utf-8
set fileencoding=utf-8
set spelllang=en_GB.UTF-8
set guioptions=
set cursorline
set shiftwidth=2
set tabstop=2
set softtabstop=2
set smarttab
syntax on
augroup BgHighlight
autocmd WinEnter * set cursorline
autocmd WinLeave * set nocursorline
augroup END
set background=dark
colorscheme solarized
" }}}
" Statusline {{{
set statusline=%f " Path.
set statusline+=%m " Modified flag.
set statusline+=%r " Readonly flag.
set statusline+=%w " Preview window flag.
set statusline+=\ " Space.
set statusline+=%#redbar# " Highlight the following as a warning.
set statusline+=%* " Reset highlighting.
set statusline+=%= " Right align.
" File format, encoding and type. Ex: "(unix/utf-8/python)"
set statusline+=(
set statusline+=%{&ff} " Format (unix/DOS).
set statusline+=/
set statusline+=%{strlen(&fenc)?&fenc:&enc} " Encoding (utf-8).
set statusline+=/
set statusline+=%{&ft} " Type (python).
set statusline+=)
" Line and column position and counts.
set laststatus=2
" }}}
" Keymappings {{{
" up and down is up and down
nnoremap j gj
nnoremap k gk
nnoremap <leader>a :Ack
inoremap jk <esc>
" Emacs Heresy
inoremap <C-a> <esc>I
inoremap <C-e> <esc>A
cmap w!! w !sudo tee % >/dev/null
nnoremap <leader>w <C-w>v<C-w>l
nnoremap <C-h> <C-w>h
nnoremap <C-k> <C-w>k
nnoremap <C-j> <C-w>j
nnoremap <C-l> <C-w>l
nnoremap H 0
nnoremap L $
noremap <space> /
noremap <c-space> ?
nnoremap <leader><space> :noh<cr>
" map ; :
" noremap ;; ;
nnoremap <silent> <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr>
nnoremap <silent> <leader>eb <C-w><C-v><C-l>:e $HOME/.vim/bundles.vim<cr>
nnoremap <silent> <leader>et <C-w><C-v><C-l>:e $HOME/.temp.vim<CR>
nnoremap <silent> <leader>sv :so $MYVIMRC<cr>
" Edit files in the same folder as the current one.
noremap <leader>ew :e <C-R>=expand("%:p:h") . "/" <CR>
noremap <leader>es :sp <C-R>=expand("%:p:h") . "/" <CR>
nnoremap <C-Up> ddkP
nnoremap <C-Down> ddp
vnoremap <C-Up> xkP`[V`]
vnoremap <C-Down> xp`[V`]
noremap <D-[> <<
noremap <D-]> >>
vnoremap <D-[> <gv
vnoremap <D-]> >gv
nnoremap <leader>n :lnext<CR>
nnoremap <leader>N :lrewind<CR>
" keep selection after in/outdent
vnoremap < <gv
vnoremap > >gv
"Insert a semicolon at the end of a line
nnoremap <leader>sc mqA;<esc>`q
"Insert spaces after commas
nnoremap <leader>z :s/\v([^ ]),([^ ])/\1, \2/g<cr>
" Edit alternative file
nnoremap <leader><leader> <C-^>
" }}}
" Filetypes {{{
" Automatic fold settings for specific files. Uncomment to use.
augroup file_settings
autocmd FileType ruby setlocal foldmethod=syntax smarttab shiftwidth=2 tabstop=2 softtabstop=4
autocmd FileType css setlocal foldmethod=indent shiftwidth=2 tabstop=2
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 textwidth=79 go+=b autoindent softtabstop=4
autocmd FileType python autocmd BufWritePre <buffer> :%s/\s\+$//e
autocmd FileType python call GrepMap("<F5>",
\"pep8 --repeat",
\"PEP8 correct")
autocmd FileType python call GrepMap("<F6>",
\'pylint --reports=n --output-format=parseable --generated-members=objects,DoesNotExist -d C0111 -d C0301',
\'\%f:\%l: [\%t\%*[^]]] \%m,\%f:\%l: [\%t] \%m',
\'Pylint Correct')
autocmd FileType python call GrepMap(",R",
\'./ jtest 2>&1 && echo',
\'File \%f, line \%l, in \%m',
\'Tests run ok')
au BufRead,BufNewFile {Gemfile,Rakefile,Vagrantfile,Thorfile,} set ft=ruby
au BufNewFile,BufRead *.json set ft=javascript
au BufRead,BufNewFile *.json set filetype=json foldmethod=syntax
au FileType json command -range=% -nargs=* Tidy <line1>,<line2>! json_xs -f json -t json-pretty
au BufRead,BufNewFile *.go set filetype=go
augroup END
" }}}
" Command T {{{
"nnoremap <leader>t :CommandT<CR>
"nnoremap <leader>bb :CommandTBuffer<CR>
"let g:CommandTMatchWindowAtTop=1 " show window at top
"let g:CommandTMaxHeight=20
"if has("gui_macvim")
"macmenu &File.New\ Tab key=<nop>
"map <D-t> :CommandT<CR>
" }}}
" Tlist {{{
nnoremap <leader>l :TlistToggle<CR>
let Tlist_Use_Right_Window = 1
let Tlist_Show_One_File = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_Use_SingleClick = 1
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Close_On_Select = 1
let tlist_objc_settings = 'ObjectiveC;i:interface;c:class;m:method;p:property;I:implementation'
" }}}
" NERDTree ------ {{{
let g:NERDTreeIgnore=['\.pyc$','\~$']
let g:NERDTreeChDirMode=2
augroup nerdtree
au VimEnter * NERDTree
au VimEnter * wincmd p
augroup END
autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft()
"" Close all open buffers on entering a window if the only
"" " buffer that's left is the NERDTree buffer
function! s:CloseIfOnlyNerdTreeLeft()
if exists("t:NERDTreeBufName")
if bufwinnr(t:NERDTreeBufName) != -1
if winnr("$") == 1
" }}}
" Vimscript ---------------------- {{{
augroup filetype_vim
au FileType vim setlocal foldmethod=marker foldenable
augroup END
" }}}
" EasyMotion ------------------- {{{
"let g:EasyMotion_mapping_w = '<Leader>m'
"let g:EasyMotion_mapping_W = '<Leader>M'
"let g:EasyMotion_mapping_t = '<Leader>d'
"let g:EasyMotion_mapping_b = '<Leader>b'
" }}}
" Gist-vim --- {{{
if has("mac")
let g:gist_clip_command = 'pbcopy'
elseif has("unix")
let g:gist_clip_command = 'xclip -selection clipboard'
let g:gist_detect_filetype = 1
let g:gist_open_browser_after_post = 1
" }}}
" {{{ Mouse and terminal
if &term =~ "xterm-256color""
set t_Co=256
set t_SI = "\<Esc>]12;purple\x7"
set t_EI = "\<Esc>]12;blue\x7"
if has('mouse')
set mouse=a
augroup mouse_settings
autocmd VimEnter * set ttymouse=xterm2
autocmd FocusGained * set ttymouse=xterm2
autocmd BufEnter * set ttymouse=xterm2
augroup END
" }}}
" {{{ Airline
let g:airline_theme="solarized"
let g:airline_left_sep = ""
let g:airline_right_sep = ""
" }}}
" Ctags {{{
nnoremap <f5> :call system('ctags --tag-relative -Rf "'.b:git_dir.'/tags"')<CR>
autocmd BufWritePost *
\ if exists('b:git_dir') |
\ call system('ctags --tag-relative -R -f "'.b:git_dir.'/tags" &') |
\ endif
" }}}
" Unite.vim {{{
let g:unite_source_history_yank_enable = 1
call unite#filters#matcher_default#use(['matcher_fuzzy'])
nnoremap <leader>f :<C-u>Unite -no-split -buffer-name=files -start-insert git_cached<cr>
nnoremap <leader>g :<C-u>Unite -no-split -buffer-name=files git_modified<cr>
nnoremap <leader>m :<C-u>Unite -no-split -buffer-name=files git_untracked<cr>
" nnoremap <leader>f :<C-u>Unite -no-split -buffer-name=files -start-insert file<cr>
nnoremap <leader>r :<C-u>Unite -no-split -buffer-name=mru -start-insert file_mru<cr>
nnoremap <leader>e :<C-u>Unite -no-split -buffer-name=buffer buffer<cr>
" Custom mappings for the unite buffer
autocmd FileType unite call s:unite_settings()
function! s:unite_settings()
" Enable navigation with control-j and control-k in insert mode
imap <buffer> <C-j> <Plug>(unite_select_next_line)
imap <buffer> <C-k> <Plug>(unite_select_previous_line)
" }}}
" Syntactic {{{
let g:syntastic_python_checkers = ['pylint', 'pep8']
let g:syntastic_aggregate_errors = 1
let g:syntastic_python_pylint_args = '--rcfile='.$HOME.'/.pylintrc'
let g:syntastic_check_on_open = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_enable_signs = 1
" }}}
" Smooth-scroll {{{
noremap <silent> <c-u> :call smooth_scroll#up(&scroll, 0, 2)<CR>
noremap <silent> <c-d> :call smooth_scroll#down(&scroll, 0, 2)<CR>
noremap <silent> <c-b> :call smooth_scroll#up(&scroll*2, 0, 4)<CR>
noremap <silent> <c-f> :call smooth_scroll#down(&scroll*2, 0, 4)<CR>
" }}}
so $HOME/.temp.vim
so $HOME/.local.vim