-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc.symlink
203 lines (185 loc) · 6.53 KB
/
vimrc.symlink
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
203
" Load plumapleadergins
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'altercation/vim-colors-solarized'
Plug 'sjl/badwolf'
Plug 'christoomey/vim-tmux-navigator'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'scrooloose/nerdtree'
Plug 'editorconfig/editorconfig-vim'
Plug 'joshdick/onedark.vim'
" Better Whitespace {{{
Plug 'ntpeters/vim-better-whitespace'
autocmd FileType fugitive DisableWhitespace
let g:better_whitespace_enabled = 1
let g:better_whitespace_guicolor='LightYellow'
let g:better_whitespace_ctermcolor='LightYellow'
let g:strip_max_file_size = 0
let g:strip_whitelines_at_eof = 1
let g:strip_whitespace_confirm = 0
let g:strip_whitespace_on_save = 0
autocmd FileType javascript,c,cpp,java,html,ruby,yaml,python EnableStripWhitespaceOnSave
" }}}
call plug#end()
" Leader Shortcuts {{{
let mapleader = ','
let g:mapleader = ','
nnoremap <Leader>o :only<CR>
nnoremap <leader>ev :vsp $MYVIMRC<CR> " Edit vimrc
nnoremap <leader>ez :vsp ~/.zshrc<CR> " Edit zshrc
nnoremap <leader>sv :source $MYVIMRC<CR> " Source vimrc
nnoremap <leader><space> :noh<CR> " Turn off highlighting until the next search
nnoremap <leader>l :set list! list?<CR> " Toggle list mode
nnoremap <leader>n :call ToggleNumber()<CR> " Toggle line number
nnoremap <leader>1 :set number!<CR>
nnoremap <leader>d :NERDTreeToggle<CR> " Open/Close Nerdtree file manager
" surround word
nnoremap <leader>" ciw"<C-r>""<esc>
nnoremap <leader>' ciw'<C-r>"'<esc>
nnoremap <leader>{ ciw{<C-r>"}<esc>
nnoremap <leader>( ciw(<C-r>")<esc>
nnoremap <leader>[ ciw[<C-r>"]<esc>
nnoremap <leader>< ciw<<C-r>"><esc>
" surround selection
vnoremap <leader>" c"<C-r>""<esc>
vnoremap <leader>' c'<C-r>"'<esc>
vnoremap <leader>{ c{<C-r>"}<esc>
vnoremap <leader>( c(<C-r>")<esc>
vnoremap <leader>[ c[<C-r>"]<esc>
vnoremap <leader>< c<<C-r>"><esc>
nnoremap <Leader><Leader> <C-^> " <Leader><Leader> -- Open last buffer.
set pastetoggle=<Leader>t
" }}}
" Normal mode mappings {{{
nmap <S-tab> :bNext<cr> " For fast moving through buffers
" Faster switching between splits
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nnoremap <C-o> <C-w>o
" Prevent x and the delete key from overriding what's in the clipboard.
noremap x "_x
noremap X "_x
noremap <Del> "_x
" Prevent selecting and pasting from overwriting what you originally copied.
" xnoremap p pgvy
" }}}
" Visual mode mappings {{{
" move selected block up/down in visual mode
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
vnoremap < <gv
vnoremap > >gv
" greatest remap ever
" no overwrite paste
" xnoremap <leader>p "_dP
xnoremap p "_dP
" }}}
syntax enable " enable syntax processing
set nocompatible " Don't try to be vi compatible
scriptencoding utf-8
set encoding=utf-8
set backspace=indent,eol,start " Fix backspace key
set tabstop=2 " 2 space tab
set expandtab " use spaces for tabs
set softtabstop=2 " 2 space tab
set shiftwidth=2
set modelines=1
filetype indent on
filetype plugin on
set autoindent
" Undo / Swap
" set nobackup noswapfile nowritebackup undofile undodir=~/.vim/undo undolevels=99999
" set scrolloff=999
" UI Layout
set number " show line numbers
set highlight+=N:DiffText " make current line number stand out a little
set showcmd " show command in bottom bar
set cursorline " highlight current line
set wildmenu
set lazyredraw
set showmatch " higlight matching parenthesis
set listchars=eol:¶,trail:•,tab:▸\ showbreak=¬\
" Automation for numbering modes
" Automatically switch to absolute line numbers when in insert mode
" and relative numbers when in normal mode
autocmd InsertEnter * :set norelativenumber
autocmd InsertLeave * :set relativenumber
autocmd FocusLost * :set norelativenumber
autocmd FocusGained * :set relativenumber
" Searching
set ignorecase " ignore case when searching
set incsearch " search as characters are entered
set hlsearch " highlight all matches
" Status line
set laststatus=2 " Always show the status line - use 2 lines for the status bar
set statusline=
set statusline+=%#PmenuSel#
set statusline+=\ %f
set statusline+=%m
set statusline+=%=
set statusline+=\ %y
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
set statusline+=\[%{&fileformat}\]
set statusline+=\ %p%%
set statusline+=\ %l:%c
" Themes
" set t_Co=256
set background=dark
" manually install solarized theme
" put https://raw.github.com/altercation/vim-colors-solarized/master/colors/solarized.vim in ~/.vim/colors/
" curl -fLo ~/.vim/colors/solarized.vim --create-dirs https://raw.github.com/altercation/vim-colors-solarized/master/colors/solarized.vim
" let g:solarized_termcolors=256
" let g:solarized_termtrans=1
" silent! colorscheme solarized
" silent! colorscheme badwolf
silent! colorscheme onedark
let g:onedark_termcolors=256
let g:onedark_termtrans=256
" Filetype settings
autocmd FileType python setlocal omnifunc=python3complete#Complete
autocmd FileType yaml setlocal ai ts=2 sts=2 sw=2 expandtab number cursorcolumn omnifunc=syntaxcomplete#Complete
autocmd FileType yaml autocmd BufWritePre <buffer> %s/\s\+$//e " Automatically removing all trailing whitespace
" Custom Functions
function! ToggleNumber()
if(&relativenumber == 1)
set norelativenumber
set number
else
set relativenumber
endif
endfunc
function RemoveM()
%s/^M//
:endfunction
function RemoveWhiteSpace()
%s/^ \+ $// " replaces a line that starts and ends with white spaces
%s/^ $// " replaces a single white space that is alone on a line
%s/ \+$// " replaces the end of a line that finishes with trailing spaces
%s/ $// " replaces the end of a line that finishes with single white space
:endfunction
function! StripTrailingWhitespace()
normal mZ
let l:chars = col("$")
%s/\s\+$//e
if (line("'Z") != line(".")) || (l:chars != col("$"))
echo "Trailing whitespace stripped\n"
endif
normal `Z
endfunction
" Allow for per-machine overrides in ~/.vim/host/hostname and
" ~/.vim/vimrc.local.
let s:hostfile = $HOME . '/.vim/host/' . substitute(hostname(), "\\..*", '', '')
if filereadable(s:hostfile)
execute 'source ' . s:hostfile
endif
let s:vimrc_local = $HOME . '/.vim/.vimrc.local'
if filereadable(s:vimrc_local)
execute 'source ' . s:vimrc_local
endif