-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
172 lines (142 loc) · 5.42 KB
/
vimrc
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
" This file is UTF-8 =========================================================
scriptencoding utf-8
set encoding=utf-8
" Tabs =======================================================================
" default indentation: 4 spaces
set ts=4 sts=4 sw=4 expandtab
" Read .jy files as python.
au BufNewFile,BufRead *.jy set filetype=python
" Only do this part when compiled with support for autocommands
if has("autocmd")
" Enable file type detection
filetype on
autocmd FileType vim setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
autocmd FileType yaml set local ts=2 sts=2 sw=2 expandtab
" House style
autocmd FileType html setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType javascript setlocal ts=4 sts=4 sw=4 noexpandtab
" On save strip trailing whitespace
autocmd BufWritePre *.py,*.js :call <SID>StripTrailingWhitespaces()
endif
" Pathogen ===================================================================
execute pathogen#infect()
filetype plugin on
filetype plugin indent on
let mapleader=","
syntax enable " Switch on syntax highlighting.
call togglebg#map("<F5>") " F5 wil toggle background. Useful for presenting.
" Font and colors ============================================================
if has('gui_running')
" Set dark Solarized.
set background=dark
colorscheme solarized
set guioptions=ctm
set guifont=DejaVu_Sans_Mono_for_Powerline:h11
else
colorscheme default
endif
" Layout =====================================================================
set t_ts=]1; " For iTerm set tab title
set t_fs= " For iTerm set tab title
set title " For iTerm set tab title
set rnu " Relative line numbering
set number " And show the line number of current line
set laststatus=2 " Use the vim-airline bar all the time.
let g:airline_powerline_fonts = 1 " Use default powerline font mappings
" Searching ==================================================================
set ignorecase " Ignore case when searching.
set smartcase " Don't ignore case when CAPS in search
set incsearch " Incremental realtime search (VSlick style)
set hlsearch " Highlight search
" Turn off the search highlighting with ,/
nmap <silent> ,/ :nohlsearch<CR>
" Window navigation ==========================================================
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" Monaco true type: http://www.gringod.com/wp-upload/MONACO.TTF
" set gfn=Monaco:h11 " Disabled for powerline
set lines=100
set columns=100
" Syntastic ==================================================================
" Available from here: https://github.com/vim-syntastic/syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 1
" Use my local pylintrc file
let g:syntastic_python_pylint_args = '--rcfile=~/.pylintrc'
" ============================================================================
" Shortcuts for opening new files ============================================
" See vimcast 14
map <leader>ew :e <C-R>=expand("%:p:h")."/"<CR>
map <leader>es :sp <C-R>=expand("%:p:h")."/"<CR>
map <leader>ev :vsp <C-R>=expand("%:p:h")."/"<CR>
map <leader>et :tabe <C-R>=expand("%:p:h")."/"<CR>
" ============================================================================
set nobackup
set noswapfile "Re enable this if I need to recover from vim crashes.
"set backupdir=/private/tmp
"set dir=/private/tmp
set hidden " Allow creation of hidden buffers w/o warning.
set backspace=indent,eol,start " Allow backspacing over everything in insert mode.
set wildignore=*.swp,*.pyc
set showmatch " Flash the closing bracket when writing ({[
set undolevels=1000
set history=1000
"set visualbell
set noerrorbells
set belloff=all " Stops annoying bells in gvim on windows
" Keys i keep accidentally hitting!
nmap <F1> <nop>
map <F1> <Esc>
imap <F1> <Esc>
nmap <F1> <Esc>
" Edit config file
nmap <silent> <leader>ec :tabe $MYVIMRC<CR>
nmap <silent> <leader>sc :so $MYVIMRC<CR>
" Toggle whitespace hints with ,l
nmap <leader>l :set list!<CR>
set listchars=tab:▸\ ,space:·,eol:¬ " Textmate whitespace chars.
" Windows copy paste.
" CTRL-X is Cut
vnoremap <C-x> "+x
" CTRL-C is Copy
vnoremap <C-c> "+y
" SHIFT-Insert is Paste
map <S-Insert> "+gp
" Chrome like tab control in Windows.
map <C-PageUp> :tabprevious<CR>
map <C-PageDown> :tabnext<CR>
" Hard mode. Disallow arrow keys
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
" force root privaleges
cmap w!! w !sudo tee % >/dev/null
" Python IDE.
let Tlist_Ctags_Cmd='/usr/local/bin/ctags'
"map T :TaskList<CR>
"map P :TlistToggle<CR>
autocmd FileType python set omnifunc=pythoncomplete#Complete
" Trailing Whitespace ========================================================
" Map to ,s
nnoremap <silent> <leader>s :call <SID>StripTrailingWhitespaces()<CR>
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the replacement:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position.
let @/=_s
call cursor(l, c)
endfunction