aboutsummaryrefslogtreecommitdiffstats
path: root/vim/.vimrc
blob: cde36c14397fb2b1142b318dbc04a0880fc9134c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
silent! execute pathogen#infect()

""" DEFAULT VIM SETTINGS

" Reload vimrc on save
augroup reload_vimrc " {
    autocmd!
    autocmd BufWritePost $MYVIMRC source $MYVIMRC
augroup END " }

let mapleader=" "

syntax on
filetype plugin indent on

" Set colorscheme when the terminal has 256 color support
try
    if (&t_Co == 256) && match($TERM, "256color") >= 0
        colorscheme Benokai
    else
        throw "nocolor"
    endif
catch
    colorscheme desert
endtry

" Some vim settings
set number
set relativenumber
set hlsearch
set list
set modeline
set background=dark
set foldmethod=indent
set listchars=trail:·,tab:▸\ ,eolset scrolloff=1
set backspace=indent,eol,start
set cursorline

" Disable ex mode
nnoremap Q <Nop>

" Save as sudo
cnoremap w!! w !sudo tee > /dev/null %

" Switch windows with <C-W>[direction]
noremap <C-J> <C-W>j
noremap <C-K> <C-W>k
noremap <C-H> <C-W>h
noremap <C-L> <C-W>l

" Never use the arrow keys
noremap  <Up> ""
noremap! <Up> <Esc>
noremap  <Down> ""
noremap! <Down> <Esc>
noremap  <Left> ""
noremap! <Left> <Esc>
noremap  <Right> ""
noremap! <Right> <Esc>

" Append modeline when pressing <leader> ml
function! AppendModeline()
    let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :",
        \ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no')
    let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
    call append(line("$"), l:modeline)
endfunction
nnoremap <silent> <Leader>ml :call AppendModeline()<CR>

" NeoVIM specifics
if has('nvim')
    nmap <BS> <C-W>h
    tnoremap <Esc> <C-\><C-n>
endif

""" PLUGIN SPECIFIC SETTINGS

if exists("g:loaded_pathogen")

    " NERDTree:
    " Open NERDTree when no file is specified
    autocmd StdinReadPre * let s:std_in=1
    autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
    autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif

    " Airline:
    " On arch linux install the following:
    " otf-powerline-symbols-git
    " powerline-fonts-git
    let g:airline_powerline_fonts = 1
    if !exists('g:airline_symbols')
        let g:airline_symbols = {}
    endif
    let g:airline_symbols.space = "\ua0"
    set laststatus=2

endif

" vim: set ts=4 sw=4 tw=4 et :