-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
172 lines (122 loc) · 3.55 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
""" General settings """
" fuck vi! long life vim!
set nocompatible
" use filetype plugins
filetype plugin on
filetype plugin indent on
" color!
syntax on
"" Adapted from https://vim.fandom.com/wiki/Highlight_unwanted_spaces
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
colorscheme dracula
match ExtraWhitespace /\t\+$/
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\t\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\t\+\%#\@<!$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\t\+$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" lines and cols in status line
set ruler
" always show status line
set laststatus=2
" line numbers
set number
" show a line under the cursor
set cursorline
" show current mode in status line
set showmode
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" number of commandline history and undo lines
set history=1000
set undolevels=1000
" do incremental searching
set incsearch
" highlight search
set hlsearch
" highlight mode for hlsearch
"set hl=l:Incsearch
"ignore case when searching
set ignorecase
" ignore case if search pattern is all lowercase, case-sensitive otherwise
set smartcase
" don't wrap lines if they are too large
set nowrap
" enable auto-indenting
set autoindent
set copyindent
" tab width spaces
set shiftwidth=4
set softtabstop=4
set tabstop=8
set shiftround
set expandtab
" number of lines to show above and below the cursor
set scrolloff=4
" toggle paste mode
set pastetoggle=<F3>
" use mouse in normal mode
" set mouse=n
" ability to open up to 50 files
set tabpagemax=50
" ignore files and folders from listings
set wildignore+=.git/*,.svn/*,.hg/*,_darcs/*,build/*,dist/*,*.o,*.so,*.pyc,node_modules/
" save OS for later checks
let os = substitute(system('uname'), "\n", "", "")
" viminfo options: http://vimdoc.sourceforge.net/htmldoc/usr_21.html#21.3
set viminfo='100,<50,s10,h,!
rviminfo
" position cursor one character after the real content: http://vimdoc.sourceforge.net/htmldoc/options.html#'virtualedit
set virtualedit=onemore
" allow to switch buffers even without saving
set hidden
" nicer autocompletion for command menu
set wildmenu
""" Custom key settings """
" <leader> key
let mapleader = ","
" no more arrows!
" map <up> <nop>
" map <down> <nop>
" map <left> <nop>
" map <right> <nop>
" move across splits with Ctrl and arrows
nnoremap <C-left> <C-w>h
nnoremap <C-down> <C-w>j
nnoremap <C-up> <C-w>k
nnoremap <C-right> <C-w>l
" new empty buffer
nmap <leader>n :enew<CR>
" next buffer
nmap <C-l> :bnext<CR>
" previous buffer
nmap <C-h> :bprevious<CR>
" close buffer and jump to previous one (aka, close tab)
nmap <leader>bq :bp <BAR> bd #<CR>
" list buffers
nmap <leader>bl :Unite buffer<CR>
" clear highlighted search
nmap <silent><leader>l :nohlsearch<CR>
" open current directory
map <silent><leader>o :op .<CR>
" toggle line numbers
map <silent><F2> :set invnumber<CR>
" open a new shell
" imap ss <Esc>:sh<CR>
" use jj same as ESC
imap jj <Esc>
" standard cut/copy/paste keys
vmap <C-c> "+yi
vmap <C-x> "+c
vmap <C-v> c<ESC>"+p
imap <C-v> <ESC>"+pa
" save file with sudo if not opened as root
command W :execute ':silent w !sudo tee % > /dev/null' | :edit!
command Wq :execute ':W' | :q
command WQ :Wq
""" Misc options """
" remember where we stopped editing a file
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif