-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
161 lines (125 loc) · 4.4 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
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim " set the runtime path to include Vundle
let path='$HOME/.vim/bundle'
" === Plugins
call vundle#begin('$HOME/.vim/bundle')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'itchyny/lightline.vim'
Plugin 'itchyny/vim-gitbranch'
Plugin 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plugin 'terryma/vim-multiple-cursors'
Plugin 'zhou13/vim-easyescape'
Plugin 'kien/ctrlp.vim'
call vundle#end()
filetype plugin indent on " re-enable filetype functionality
" Color scheme
syntax enable
set background=dark
colorscheme edge
" === Pluging Configuration
" -> Lightline
set laststatus=2
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'gitbranch#name',
\ },
\ }
" -> Easy Escape
let g:easyescape_chars = { "j": 1, "k": 1 }
let g:easyescape_timeout = 100
cnoremap jk <ESC>
cnoremap kj <ESC>
" -> CtrlP
" Use with Silver Searcher
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" " ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
" === Auto Commands
autocmd VimEnter * NERDTree " Start NERDTree on startup
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree")
\ && b:NERDTree.isTabTree()) | q | endif " Close NERDTree explore after last window closes
" === Settings
let mapleader = "," " Set `<leader>` key
set cursorline " Highlight the current line
set colorcolumn=80 " Show vertical line @80
set number " Show line numbers
set noshowmode " Disable showing mode (e.g. INSERT) because lightline pluging already does
set nowrap " Don't wrap code
set linebreak " Wrap lines at convenient points
set tabstop=2 "
set shiftwidth=2 "
set expandtab "
set undofile " Undo changes even after a file as been closed then reopened
set undodir=~/.vim/undodir
let &t_SI = "\e[5 q" " Blinking vertical cursor
let &t_EI = "\e[5 q" " Blinding vertical cursor
let NERDTreeMinimalUI = 1 " NERDTree Minimal UI
let NERDTreeDirArrows = 1 " NERDTREE Directional Arrows
let NERDTreeShowHidden = 1 " Show hidden files
" === Mappings
" Window navigation
nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>l
nnoremap <C-S-tab> :tabprevious<CR>
nnoremap <C-tab> :tabnext<CR>
nnoremap <C-t> :tabnew<CR>
inoremap <C-S-tab> <Esc>:tabprevious<CR>i
inoremap <C-tab> <Esc>:tabnext<CR>i
inoremap <C-t> <Esc>:tabnew<CR>
" Undo / Redo
nnoremap <C-Z> u
nnoremap <C-Y> <C-R>
inoremap <C-Z> <C-O>u
inoremap <C-Y> <C-O><C-R>
" Delete Lines
nnoremap x "_x
nnoremap d "_d
nnoremap D "_D
vnoremap d "_d
nnoremap <leader>d ""d
nnoremap <leader>D ""D
vnoremap <leader>d ""d
" Move lines up/down
nnoremap <C-j> :m .+1<CR>==
nnoremap <C-k> :m .-2<CR>==
inoremap <C-j> <Esc>:m .+1<CR>==gi
inoremap <C-k> <Esc>:m .-2<CR>==gi
vnoremap <C-j> :m '>+1<CR>gv=gv
vnoremap <C-k> :m '<-2<CR>gv=gv
" Grep word under cursor
nnoremap <Leader>g :grep! "\b<C-R><C-W>\b"<CR>:cw<CR><CR>
" === Search
set hlsearch
set incsearch
nnoremap <C-f> <ESC>:set hls! hls?<cr>
inoremap <C-f> <C-o>:set hls! hls?<cr>
vnoremap <C-f> <ESC>:set hls! hls?<cr> <bar> gv
" Enable mouse selection
set mouse=a
nnoremap <silent> <2-LeftMouse> :let @/='\V\<'.escape(expand('<cword>'), '\').'\>'<cr>:set hls<cr>:CountWord<cr>
" Define a function to count the number of words
fun! CountWordFunction()
try
let l:win_view = winsaveview()
let l:old_query = getreg('/')
let var = expand("<cword>")
exec "%s/" . var . "//gn"
finally
call winrestview(l:win_view)
call setreg('/', l:old_query)
endtry
endfun
command! -nargs=0 CountWord :call CountWordFunction()