-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path_vimrc
189 lines (155 loc) · 4.83 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
syntax on
set clipboard=unnamed
let mapleader = " "
set encoding=utf-8
set fileencoding=utf-8
set termencoding=utf-8
set noerrorbells
set nu
set rnu
set linespace=3
set tabstop=2 softtabstop=2
set shiftwidth=2
set smartindent
set noswapfile
set incsearch
set so=4
nnoremap <leader>h :wincmd h<CR>
nnoremap <leader>j :wincmd j<CR>
nnoremap <leader>k :wincmd k<CR>
nnoremap <leader>l :wincmd l<CR>
nnoremap <leader>u :NERDTreeToggle<CR>
nnoremap <leader>pv :wincmd v<bar> :Ex <bar> :vertical resize 30<CR>
nnoremap <Leader>+ :vertical resize +5<CR>
nnoremap <Leader>- :vertical resize -5<CR>
nnoremap <Leader>rp :resize 100<CR>
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" Use alt + hjkl to resize windows
nnoremap <M-j> :resize -2<CR>
nnoremap <M-k> :resize +2<CR>
nnoremap <M-h> :vertical resize -2<CR>
nnoremap <M-l> :vertical resize +2<CR>
" I hate escape more than anything else
inoremap fd <Esc>
inoremap df <Esc>
" delay
set timeoutlen=200
" TAB in general mode will move to text buffer
nnoremap <TAB> :bnext<CR>
" SHIFT-TAB will go back
nnoremap <S-TAB> :bprevious<CR>
" Alternate way to save
nnoremap <C-s> :w<CR>
" save in insert mode
:imap <c-s> <Esc>:w<CR>a
" copy ctrl-c
:map <C-c> y
" paste in insert mode
imap <C-v> <C-r>+
" Alternate way to quit
nnoremap <C-Q> :wq!<CR>
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" Better window 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
" Mapping to reload configuration
map <leader>so :source $HOME\_vimrc<CR>
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h16
" set guioptions-=m "menu bar
set guioptions-=T "toolbar
set guioptions-=r "scrollbar
" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" Colorscheme
Plug 'morhetz/gruvbox'
" startify
Plug 'mhinz/vim-startify'
" vim surround
Plug 'tpope/vim-surround'
" vim commentary
Plug 'tpope/vim-commentary'
" highlighted yank
Plug 'machakann/vim-highlightedyank'
" vim airline
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
" Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Initialize plugin system
call plug#end()
colorscheme gruvbox
map y <Plug>(highlightedyank)
let g:highlightedyank_highlight_duration = 300
" enable tabline
let g:airline#extensions#tabline#enabled = 1
" enable powerline fonts
let g:airline_powerline_fonts = 1
" you can also choose which path formatter airline uses.
let g:airline#extensions#tabline#formatter = 'unique_tail'
" We don't need to see things like -- INSERT -- anymore
set noshowmode
if has("gui_running")
function! ScreenFilename()
if has("gui_running")
if has('amiga')
return "s:.vimsize"
elseif has('win32')
return $HOME.'\_vimsize'
else
return $HOME.'/.vimsize'
endif
endfunction
function! ScreenRestore()
" Restore window size (columns and lines) and position
" from values stored in vimsize file.
" Must set font first so columns and lines are based on font size.
let f = ScreenFilename()
if has("gui_running") && g:screen_size_restore_pos && filereadable(f)
let vim_instance = (g:screen_size_by_vim_instance==1?(v:servername):'GVIM')
for line in readfile(f)
let sizepos = split(line)
if len(sizepos) == 5 && sizepos[0] == vim_instance
silent! execute "set columns=".sizepos[1]." lines=".sizepos[2]
silent! execute "winpos ".sizepos[3]." ".sizepos[4]
return
endif
endfor
endif
endfunction
function! ScreenSave()
" Save window size and position.
if has("gui_running") && g:screen_size_restore_pos
let vim_instance = (g:screen_size_by_vim_instance==1?(v:servername):'GVIM')
let data = vim_instance . ' ' . &columns . ' ' . &lines . ' ' .
\ (getwinposx()<0?0:getwinposx()) . ' ' .
\ (getwinposy()<0?0:getwinposy())
let f = ScreenFilename()
if filereadable(f)
let lines = readfile(f)
call filter(lines, "v:val !~ '^" . vim_instance . "\\>'")
call add(lines, data)
else
let lines = [data]
endif
call writefile(lines, f)
endif
endfunction
if !exists('g:screen_size_restore_pos')
let g:screen_size_restore_pos = 1
endif
if !exists('g:screen_size_by_vim_instance')
let g:screen_size_by_vim_instance = 1
endif
autocmd VimEnter * if g:screen_size_restore_pos == 1 | call ScreenRestore() | endif
autocmd VimLeavePre * if g:screen_size_restore_pos == 1 | call ScreenSave() | endif
endif