-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
202 lines (156 loc) · 4.05 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
" Sanity
set nocompatible
" Dark mode
set bg=dark
" Disable modeline settings at the top of the file
set nomodeline
" File encoding
set encoding=utf-8
" Syntax highlighting
syntax enable
" Show current command while typing
set showcmd
" Turn off mode info because it's in the statusline
set noshowmode
" Show next lines while scrolling
set scrolloff=4
" Show next columns while scrolling
set sidescrolloff=4
" Show line numbers
set number
" Show line numbers relative to the current line
set relativenumber
" Set current line number colors and style
hi CursorLineNr cterm=bold ctermfg=magenta ctermbg=black
" Always show status line at the bottom, even if you have only one window open
set laststatus=2
" Backspace over anything
set backspace=indent,eol,start
" Search is not case-sensitive if all characters in the string are lowercase
set ignorecase
set smartcase
" Enable searching as you type
set incsearch
" Highlight during searching
set hlsearch
" Show search match count
set shortmess-=S
" Set leader key
let mapleader=','
" Stop highlighting search
nnoremap <silent> <leader><space> :noh<CR>
" Unbind Ex mode
nmap Q <Nop>
" Disable audible bell
set noerrorbells visualbell t_vb=
" Show hidden characters
set list
set listchars=tab:\|·,trail:·,extends:>,precedes:<,nbsp:·
" Better line wrapping
set showbreak=¬\
set breakindent
" Disable arrows in normal mode
nnoremap <Left> <Nop>
nnoremap <Right> <Nop>
nnoremap <Up> <Nop>
nnoremap <Down> <Nop>
" Disable arrows in visual mode
vnoremap <Left> <Nop>
vnoremap <Right> <Nop>
vnoremap <Up> <Nop>
vnoremap <Down> <Nop>
" Buffer navigation
noremap <leader>z :bp<CR>
noremap <leader>x :bn<CR>
noremap <leader>c :bd<CR>
" Window navigation
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
" QoL
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
filetype plugin indent on
" Make tabs appear like 4 spaces
set tabstop=4
" Set indent size to 4 spaces
set shiftwidth=4
" Default settings, just to make sure
set softtabstop=0
" Insert 4 spaces on pressing tab
set expandtab
" Vimscript indentation rules
autocmd FileType vim setlocal shiftwidth=2 tabstop=2
" Ruby indentation rules
autocmd FileType ruby setlocal shiftwidth=2 tabstop=2
" JavaScript indentation rules
autocmd FileType javascript setlocal shiftwidth=2 tabstop=2
let g:fullmodename = {
\ 'n' : 'NORMAL',
\ 'v' : 'VISUAL',
\ 'V' : 'V-LINE',
\ '' : 'V-BLOCK',
\ 'i' : 'INSERT',
\ 'R' : 'REPLACE',
\ 'c' : 'COMMAND'
\}
let g:modecolor = {
\ 'n' : '%1*',
\ 'v' : '%2*',
\ 'V' : '%2*',
\ '' : '%2*',
\ 'i' : '%3*',
\ 'R' : '%4*',
\ 'c' : '%5*'
\}
" Normal
hi User1 ctermbg=black ctermfg=white
" Visual
hi User2 ctermbg=black ctermfg=darkyellow
" Insert
hi User3 ctermbg=black ctermfg=blue
" Replace
hi User4 ctermbg=black ctermfg=magenta
" Command & Search
hi User5 ctermbg=black ctermfg=green
" Filepath
hi User6 ctermbg=black ctermfg=white
" Filetype
hi User8 ctermbg=black ctermfg=gray
" Filler
hi User9 ctermbg=black ctermfg=white
function! StatuslineMode()
return g:modecolor[mode()] . ' ' . g:fullmodename[mode()] . ' %9*'
endfunction
function! StatuslineFilepath()
if win_getid() != g:statusline_winid
return ''
endif
let filepath = expand('%:t') !=# '' ? ( len(expand('%:p')) > 40 ? expand('%:t') : expand('%:p') ) : '[No Name]'
return '%6* ' . filepath . ' %9*'
endfunction
function! StatuslineModified()
if win_getid() != g:statusline_winid
return ''
endif
return &modifiable ? ( &modified ? '%#error# + %9*' : '' ) : '%#error# / %9*'
endfunction
function! StatuslineFiletype()
return '%8*%y%9*'
endfunction
function! StatuslinePosition()
return ' %l:%c %P/%L '
endfunction
function! Statusline()
return StatuslineMode() . ' ' . StatuslineFilepath() . ' ' . StatuslineModified() . '%=' . ' ' . StatuslineFiletype() . ' ' . StatuslinePosition()
endfunction
set statusline=%!Statusline()