aboutsummaryrefslogtreecommitdiffstats
path: root/vim/.vimrc
blob: ad1e908bc8d2ff22a87fd68a280b3c8ecf85936d (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
execute pathogen#infect()

""" DEFAULT VIM SETTINGS

let mapleader=" "

syntax on
filetype plugin indent on

" Set colorscheme when the terminal has 256 color support
if &t_Co == 256
	colorscheme Benokai
endif

" 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

" 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>

""" PLUGIN SPECIFIC SETTINGS

" 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

" vim: set ts=8 sw=8 tw=78 noet :