summaryrefslogtreecommitdiff
path: root/.vimrc
blob: c1dd3e8ce7d4606494a792355068e51c122eb48a (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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
""""""""""
" DEFAULTS
""""""""""
set nocompatible
filetype plugin indent on

""""""""""""""
" RELOAD VIMRC
""""""""""""""
nmap <F5> :source ~/.vimrc<cr>

""""""""""""""""""""
" BACKUP DIRECTORIES
""""""""""""""""""""

set undodir=~/.vim/.undo//
set backupdir=~/.vim/.backup//
set directory=~/.vim/.swap//

""""""""""""""""
" USER INTERFACE
""""""""""""""""

" Line numbers on by default
set number

" Show command as it is being inserted
set showcmd

" Provide 3 lines of context regardless of cursor position
set so=3

" Enhanced tab completion menu
set wildmenu

" Show where I am in the file
set ruler

" Ignore case for searches
set ignorecase
" unless query contains uppercase chars
set smartcase 

" Watch your searches complete in real time
set incsearch

" Highlight search matches throughout after query is entered (plus Ctrl-q to kill)
set hlsearch
nnoremap <C-q> :noh<CR>

" Ensure magic is on for regex
set magic

" Open splits to the right and below
set splitright
set splitbelow

" Never hide the status line
set laststatus=2

" Change the title of VIM windows
set title

" Create a leader key because I ran out of modifiers
" Backslash is perhaps good? Modifier-like placement
let mapleader='\'

" Instant recognition of escape key (fuck <Esc> sequences)
set noesckeys

" Timeout length for map leader keys
"set timeoutlen=200 ttimeoutlen=200

"""""""""
" BUFFERS
"""""""""

" make it easy to swap buffers at a glance
nmap <Leader>b :buffers<CR>:b

" do not demand buffers be saved on switching
set hidden

"""""""""""""""
" COLOR/STYLING
"""""""""""""""

" Enable syntax highlighting
syntax enable

" Color scheme settings
set background=dark
if &t_Co == 256 || has('gui_running')
    colorscheme diokai
else
    colorscheme desert
endif

" The greatest font ever
set guifont=Inconsolata\ 13

" Disable many bells and whistles on the GUI
" -m(enu), -t(oolbar),
" -r and -L are scrollbars
" on right and left sides
set go-=m
set go-=T
set go-=r
set go-=L 

" Size the gvim instance sanely
if has("gui_running")
    set lines=24 columns=80
endif

"""""""""""""""""
" TABBING OPTIONS
"""""""""""""""""
" Convert tab chars into spaces
set expandtab

" Don't add indents when they already exist
set smarttab

" Four spaces to an indent
set shiftwidth=4
set tabstop=4

" HTML uses two spaces instead
autocmd FileType html setlocal shiftwidth=2 tabstop=2

" Newline every 80 chars
"set textwidth=80

set ai        " Auto indent
set nosi      " Dumb indent
set wrap      " Wrap long lines to fit on screen
set linebreak " Do not break up words when wrapping

""""""""
" MOTION
""""""""

" Navigate up/down through longlines instead of passing through them
map j gj
map k gk

" Reduce keystrokes when moving between splits
nnoremap <C-h> <C-W>h
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap <C-l> <C-W>l

" Reduce keystrokes when relocating splits
nnoremap <leader>H <C-W>H
nnoremap <leader>J <C-W>J
nnoremap <leader>K <C-W>K
nnoremap <leader>L <C-W>L

" Reduce keystrokes when resizing splits
nnoremap <leader>h <C-W><
nnoremap <leader>j <C-W>+
nnoremap <leader>k <C-W>-
nnoremap <leader>l <C-W>>

nnoremap <leader>= <C-W>=
nnoremap <leader><bar> <C-W><bar>
nnoremap <leader>_ <C-W>_

" Reduce keystrokes when moving between tabs
nnoremap <leader>a gT
nnoremap <leader>d gt
nnoremap <leader>q :-tabmove<cr>
nnoremap <leader>w :tablast<cr>
nnoremap <leader>e :+tabmove<cr>

""""""""""""""""""""
" THOUGHT MANAGEMENT
""""""""""""""""""""
nnoremap <leader>f :w !diff % -<CR>
nnoremap <leader>t :w !colordiff -y % - \| less -R<CR>

""""""""
" BOTTOM
""""""""

noh