-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc.vim
More file actions
179 lines (138 loc) · 4.99 KB
/
Copy pathvimrc.vim
File metadata and controls
179 lines (138 loc) · 4.99 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
if !exists('g:loaded_plug')
so ~/.vim/autoload/plug.vim
endif
"vim-plug plugins
so ~/.vim/plugins.vim
"plugins-setup
so ~/.vim/plugins-setup.vim
"Source local settings if any.
if filereadable(glob("~/.vim/local-setup.vim"))
source ~/.vim/local-setup.vim
endif
set nocompatible " Use Vim settings, rather than Vi settings.
" Allow backspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
" Set central backup and swap file locations.
if isdirectory($HOME . '/.vim/.backup') == 0
:silent !mkdir -m 700 -p ~/.vim/.backup > /dev/null 2>&1
endif
set backupdir=~/.vim/.backup//
if isdirectory($HOME . '/.vim/.swp') == 0
:silent !mkdir -m 700 -p ~/.vim/.swp > /dev/null 2>&1
endif
set directory=~/.vim/.swp//
set nowrap " Don't wrap lines at the edge of the screen
set ruler " show the cursor position in lower right corner all the time
set number " Show line numbers
set history=50 " keep 50 lines of command line history
set showcmd " display incomplete commands
set incsearch " do incremental searching
set cursorline " Highlight the current line
set hlsearch
set autoread " Automatically update files if changed outside of Vim
set showmatch
set shiftwidth=4 tabstop=4 expandtab
set smarttab " Treat shiftwidth spaces as a 'virtual tab' on empty lines.
" i.e. one backspace press will remove shiftwidth spaces and
" one tab press will insert shiftwidth spaces
set shiftround " Round shift operators '>' and '<' to a multiple of shiftwidth
set wildmenu " Show the completion menu
set wildmode=list:longest "A list of completions will be shown and the command
"will be completed to the longest common command.
set spell spelllang=en_us " Enable spell checking.
set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<
set list
set relativenumber
if has('gui_running')
set guioptions-=T "remove toolbar
set guioptions-=m "remove menu bar
endif
filetype plugin indent on
syntax on
" Colorscheme options
set background=dark
if !has ('nvim') " is vim
" See ':h xterm-true-color' for the details.
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
set termguicolors
colorscheme selenized
noremap <leader>n :set relativenumber!<CR>
augroup vimrc
autocmd!
"Remove WS when a buffer is written
autocmd BufWritePre * :%s/\s\+$//e
" Treat WAF wscript as a python file
autocmd BufNewFile,BufRead wscript* set filetype=python
" Udev rules
autocmd FileType hog set filetype=udevrules
augroup END
"Nerdtree mapping
nnoremap <silent> <F11> :NERDTreeToggle<CR>
nnoremap <silent> <C-F11> :NERDTreeFind<CR>
map <leader>tl :TlistToggle<CR>
map <F12> :buffers<BAR>
\let i = input("Buffer number: ")<BAR>
\execute "buffer " . i<CR>
map <C-p> :Files<CR>
" Copy current file path into + register (system paste buffer)
map <leader>cp :let @+ = expand("%:p")<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs, windows and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Close the current buffer
map <leader>bd :Bclose<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
" LEADER MAPPINGS
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Reload our .vimrc
nmap <leader>~ :source ~/.vimrc<CR>:redraw!<CR>:echo "~/.vimrc reloaded!"<CR>
" Shortcut to rapidly toggle `set list`
nmap <leader>l :set list!<CR>
" leader f to search for filename under cursor using fzf
nnoremap <leader>f <Esc>:call fzf#vim#files('', {'options':'--query='.fzf#shellescape(expand('<cfile>:t'))})<CR>
" leader o to open directory of the current file.
nnoremap <leader>o <Esc>:exec "e " . expand('%:p:h')<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remap VIM 0 to first non-blank character
map 0 ^
" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
nnoremap <M-j> mz:m+<cr>`z
nnoremap <M-k> mz:m-2<cr>`z
inoremap <A-j> <Esc>:m .+1<CR>==gi
inoremap <A-k> <Esc>:m .-2<CR>==gi
vnoremap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vnoremap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Don't close window, when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction