-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.vim
More file actions
247 lines (183 loc) · 6.18 KB
/
Copy pathbasic.vim
File metadata and controls
247 lines (183 loc) · 6.18 KB
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
"""""""""""""""""""""""""""""""""""""""""
" Author:
" Fionn O'Connor
"
"""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""
" - Functional
""""""""""""""""""""""""""""""""""""""""""
syntax enable " syntax highlighting
set path+=** " recursively search sub-dirs
set expandtab " tabs to spaces
set shiftwidth=4 " 4 spaces per tab
set tabstop=4 " tabs in file use 4 spaces
set mouse=a " mouse usable in all modes
set autoread " auto read file when changed while open
set history=1000 " command history
set hidden " allows switching between unsaved buffers
set scrolloff=10 " set 10 lines to the edge of screen
set sidescrolloff=5
set visualbell " visual cue instead of audio on error
set report=0 " show all substitutions
set foldcolumn=3 " level of folds in sidebar
"""""""""""""""""""""""""""""""""""""""""
" - Swaps, Backups, Undo
""""""""""""""""""""""""""""""""""""""""""
" no backups
set nobackup
" setup swap
if !isdirectory($HOME."/.vim/swap")
call mkdir($HOME."/.vim/swap", "p")
endif
" // after each means files will have full paths (seperator subbed for %)
set directory=~/.vim/swap//
" setup persistent undos
if has("persistent_undo")
if !isdirectory($HOME."/.vim/undo")
call mkdir($HOME."/.vim/undo", "p")
endif
set undodir=~/.vim/undo
set undofile
endif
"""""""""""""""""""""""""""""""""""""""""
" - Visual
""""""""""""""""""""""""""""""""""""""""""
set showmatch " show matching brackets
set mat=2 " tenths of a second to blink on bracket
set cursorline " highlight current line
set showcmd " show incomplete commands
set number " show line numbers
set relativenumber " show relative to current line
set numberwidth=5 " wider number column (to cater for gitgutter)
set showbreak="+++" " long line wrap delimiter
set autoindent " match indentation of prev line
set smartindent " dependent on filetype
set ruler " show (line, col) at bottom
" visual menu for auto-complete
set wildmenu
set wildignore=*.o,*.obj,*.bak,*.sw*,*.pyc,*.class
" better splits
set splitbelow
set splitright
set equalalways
set lazyredraw " only redraw window after macro is finished (performance)
" line break next word after 150 chars
set linebreak
set textwidth=150
" Colours
set t_CO=256
if !isdirectory($HOME."/.vim/colors")
call mkdir($HOME."/.vim/colors", "p")
endif
try
colorscheme atom-dark-256
catch
colorscheme desert
endtry
"""""""""""""""""""""""""""""""""""""""""
" - Search
""""""""""""""""""""""""""""""""""""""""""
set incsearch " incremental search
set hlsearch " highlight all matches
set ignorecase " ignore case on search..
set smartcase " ..but case sensitive if one letter is upper case
set laststatus=2 " always status bar
set backspace=indent,eol,start " make backspace behave normally
let g:netrw_list_hide = '^\.[^\.],'
let g:netrw_list_hide .= '\.pyc$,'
let g:netrw_list_hide .= '\.class$,'
"""""""""""""""""""""""""""""""""""""""""
" - Status Line
""""""""""""""""""""""""""""""""""""""""""
" Override default to blank
set statusline=
set statusline+=%2*\ %f\ %m\ %r%* " Show filename/path
set statusline+=%3*%=%* " Set right-side status info after this line
set statusline+=%4*%l/%L:%v%* " Set <line number>/<total
set statusline+=%5*\ %* " Set ending space
set shm=atI " Cut long messages
"""""""""""""""""""""""""""""""""""""""""
" - Key Mappings
""""""""""""""""""""""""""""""""""""""""""
" easier exit from insert
imap jk <Esc>
" yank to end of line
nnoremap Y y$
" too common a mistake [:W == :w]
command! W w
" fix page up and down
map <PageUp> <C-U>
map <PageDown> <C-D>
" for navigating wrapped lines
nmap j gj
nmap k gk
" easier start/end of line
nnoremap H ^
nnoremap L $
" autocomplete menu navigation
imap <C-J> <C-N>
imap <C-K> <C-P>
" netrw
nmap - :Explore<CR>
" Default leader is \, but space is better
nnoremap <SPACE> <Nop>
let mapleader=' '
" un-highlight searches
nmap <Leader><Leader> :nohlsearch<cr>
" paste from system clipboard
nmap <Leader>p "+p
" quick edit config files
nmap <Leader>ev :e $MYVIMRC<cr>
nmap <Leader>ep :e $HOME/.vim/plugins.vim<cr>
" save as sudo if read-only
noremap <leader>w :w !sudo tee % > /dev/null
" buffers
nnoremap <silent> <Leader>h :bp<CR>
nnoremap <Leader>l :bn<CR>
" close current buffer
nmap <Leader>q :bp <BAR> bd #<CR>
" list all open buffers, waiting for input to change
nnoremap <leader>b :ls<CR> :b<space>
" tabs
nmap <Leader>t :tab new<CR>
nmap <Leader>c :tab close<CR>
" create splits
nmap <Leader>s :split<cr>
nmap <Leader>v :vsplit<cr>
" easier split navigation
nmap <C-H> <C-W>h
nmap <C-L> <C-W>l
nmap <C-J> <C-W>j
nmap <C-K> <C-W>k
" resize splits with Alt+<ARROW>
nmap <silent> <A-Up> <C-W>+
nmap <silent> <A-Down> <C-w>-
nmap <silent> <A-Left> <C-w><
nmap <silent> <A-Right> <C-w>>
" indenting in visual mode, go back to visual mode on same selection
vnoremap > >gv
" easy visual mode macros
vmap @ :normal @
" replay last macro instead of Ex Mode
nnoremap Q @@
" s deletes to black hole register
nnoremap s "_d
nnoremap ss "_dd
nnoremap S "_D
"""""""""""""""""""""""""""""""""""""""""
" - Auto-Commands
""""""""""""""""""""""""""""""""""""""""""
" auto source Vimrc and reload airline on save
augroup autosourcing
autocmd!
autocmd BufWritePost $MYVIMRC source $MYVIMRC
augroup END
" Return to last edit position when opening files
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
"Remember info about open buffers on close
set viminfo^=%
" Remove trailing whitespace on save
autocmd BufWritePre * :%s/\s\+$//e