-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
174 lines (137 loc) · 5.54 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
set nocompatible
filetype off
call plug#begin('~/.vim/plugged')
Plug 'iCyMind/NeoSolarized'
Plug 'sheerun/vim-polyglot'
Plug 'tomtom/tcomment_vim'
Plug 'tpope/vim-surround'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" GIT Related
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
call plug#end()
" activate filetype detection now that plugins are loaded
filetype plugin on
" =============================================================================
" AUTOCMDs
" =============================================================================
autocmd BufWritePre * :%s/\s\+$//e
" =============================================================================
" PLUGIN SETTINGS
" =============================================================================
" GITGUTTER
let g:gitgutter_sign_added = '•'
let g:gitgutter_sign_modified = '•'
let g:gitgutter_sign_removed = '•'
let g:gitgutter_sign_removed_first_line = '•'
let g:gitgutter_sign_modified_removed = '•'
let g:gitgutter_override_sign_column_highlight = 1
" =============================================================================
" MAPPINGS
" =============================================================================
let mapleader = ','
" use jj to quickly escape to normal mode while typing <- AWESOME tip
inoremap jj <ESC>
" insert newline without entering insert mode
map <CR> o<Esc>k
" Don't use Ex mode, use Q for formatting
map Q gq
"make Y consistent with C and D
nnoremap Y y$
" Ctrl-N to disable search match highlight
nmap <silent> <C-N> :silent noh<CR>
" center display after searching
noremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#z
" easy split navigation
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Type <F1> follwed by a buffer number or name fragment to jump to it.
" Also replaces the annoying help button. Based on tip 821.
map <F1> :ls<CR>:b<Space>
map <F7> :setlocal spell! spell?<CR>
" =============================================================================
" CODE RELATED
" =============================================================================
noremap <silent> <Leader>cc :TComment<CR>
" =============================================================================
" FILE RELATED
" =============================================================================
set hidden
set fileformats=unix,dos,mac
set backspace=indent,eol,start
set history=1000
" When editing a file, always jump to the last known cursor position.
" Don't do it when the mark is in the first line, that is the default
" position when opening a file.
if has("autocmd")
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
endif
" ,e to fast finding files. just type beginning of a name and hit TAB
nmap <leader>e :e **/
" ,k to get the next location (compilation errors, grep etc)
nmap <leader>k :cn<CR>
" ,j to get the previous location (compilation errors, grep etc)
nmap <leader>j :cp<CR>
nnoremap <silent> <Leader>f :Files<CR>
nnoremap <silent> <Leader>fm :CtrlPMRU<CR>
" =============================================================================
" BUFFER RELATED
" =============================================================================
nnoremap <silent> <Leader>b :Buffers<CR> " cycle between buffer
nnoremap <silent> <Leader>bd :bdelete<CR> " (D)elete the current buffer
nnoremap <silent> <Leader>bu :bunload<CR> " (U)nload the current buffer
nnoremap <silent> <Leader>bl :b#<CR> " (L)ast buffer
" =============================================================================
" GIT RELATED
" =============================================================================
set diffopt+=vertical
nmap <Leader>gn <Plug>GitGutterNextHunk
nmap <Leader>gp <Plug>GitGutterPrevHunk
" =============================================================================
" APPEARANCE
" =============================================================================
set viminfo=""
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set list listchars=tab:→\ ,space:·,trail:·
set completeopt=menuone,preview
set hlsearch " Highlight search match
set incsearch " Incremental search
set ignorecase " Do case insensitive matching
set smartcase " do not ignore if search pattern has CAPS
set autoindent " automatically indent new line
set ts=4 " number of spaces in a tab
set sw=4 " number of spaces for indent
set et " expand tabs into spaces
" Check, if backup directory excists and create it
if !isdirectory($HOME.'/.vim/backup')
call mkdir($HOME.'/.vim/backup', 'p')
endif
set backupdir=~/.vim/backup/
set directory=~/.vim/backup/
set undodir=~/.vim/backup/
" =============================================================================
" COLORS
" =============================================================================
syntax enable " Enable syntax highlighting
set t_ZH=[3m " Fix to print italic comments
set t_ZR=[23m " Fix to print italic comments
let g:neosolarized_contrast="high"
let g:neosolarized_visibility="low"
let g:neosolarized_bold = 1
let g:neosolarized_underline = 1
let g:neosolarized_italic = 1
set termguicolors " Enable true color
set background=light " Use the light colorscheme
colorscheme NeoSolarized " Set colorscheme