-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
165 lines (131 loc) · 3.49 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
"""""""""""""""""""""""""""""""""""""""""""""""""""
" General
"""""""""""""""""""""""""""""""""""""""""""""""""""
" Set history
set history=700
" This isn't vi
set nocompatible
" Enable filetype plugins
filetype plugin on
filetype indent on
" Auto-update when a file is externally changed
set autoread
" Extra key combos!
let mapleader = ","
let g:mapleader = ","
" Faster saving
nmap <leader>w :w<cr>
nmap <leader>a :wa<bar>qa<cr>
" Backspace acts sensibly
set backspace=indent,eol,start
set whichwrap+=<,>,h,l
"""""""""""""""""""""""""""""""""""""""""""""""""""
" Visual differences
"""""""""""""""""""""""""""""""""""""""""""""""""""
" Syntax Highlighting
syntax on
" Line Numbers
set number
" Show current position
set ruler
" Visible tabs and trailing whitespace
set listchars=tab:\|=,trail:~,extends:>,precedes:<
set list
" No annoying bells
set noerrorbells
set novisualbell
set t_vb=
" Shorter timeoutlen
set tm=500
" I will probably never not use a dark, 256-color terminal
" Gotta get that statusline, yo
set laststatus=2
" Highlight matching braces
set showmatch
" See where the cursor is
set cursorline
"""""""""""""""""""""""""""""""""""""""""""""""""""
" Behavior
"""""""""""""""""""""""""""""""""""""""""""""""""""
" Be sensible about cases when searching
set ignorecase
set smartcase
set incsearch
" Allow me to click if I'm in an X server
set mouse=a
" All my code is in git anyways
set nobackup
set nowb
set noswapfile
"""""""""""""""""""""""""""""""""""""""""""""""""""
" Indents and lines
"""""""""""""""""""""""""""""""""""""""""""""""""""
" Autoindent them
set autoindent
" All I want for Christmas is spaces
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
" Configure softwrap
set wrap
set linebreak
set nolist
set textwidth=0
set wrapmargin=0
"""""""""""""""""""""""""""""""""""""""""""""""""""
" Extra commands
"""""""""""""""""""""""""""""""""""""""""""""""""""
" Fumble-finger saving
command! W w
command! Wq wq
command! WQ wq
command! Q q
command! Wa wa
command! WA wa
" Who wants to move their pinkies?
" map ; : " uncomment if you don't use f
inoremap jk <Esc>
" Map 0 to go to the first non-blank character
map 0 ^
" Treat long lines as broken lines so you can move in them
map j gj
map k gk
" s and S work like i and a, but for a single character at a time (like r)
function! RepeatChar(char, count)
return repeat(a:char, a:count)
endfunction
nnoremap s :<C-U>exec "normal i".RepeatChar(nr2char(getchar()), v:count1)<CR>
nnoremap S :<C-U>exec "normal a".RepeatChar(nr2char(getchar()), v:count1)<CR>
" Move between windows a little easier
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Tab management
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tx :tabclose<cr>
" Open a new tab with current buffer's path
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/<cr>
" Set cwd to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
" Remember info about open buffers on close...
set viminfo^=%
" ...so we can return to last edit position when opening files
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! G`\"" |
\ endif
" Kill trailing whitespace
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
map <leader>kw :call DeleteTrailingWS()<cr>
" Kill the Windows ^M if the encodings are screwy
map <leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" Toggle printing whitespace
nnoremap <leader>l :set list!<CR>
nnoremap <leader>n :set nonumber!<CR>