-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
98 lines (77 loc) · 2.48 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim configuration "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use included defaults
unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set background for colors
set background=dark
" Set true colour support
set termguicolors
" Don't lose undo history when changing buffers
set hidden
" Tab space settings
set autoindent
set smartindent
set smarttab
set tabstop=4
set shiftwidth=4
set expandtab
set softtabstop=4
" Show line numbers
set number
set relativenumber
" Visual warnings instead of audio
set visualbell
" Reload file after external changes
set autoread
set autowrite
" Search settings
set ignorecase
set smartcase
set showmatch
" Textwrapping
set wrap
set textwidth=80
let &showbreak='↪ '
set linebreak
" Save file when vim loses focus or change to another buffer
autocmd BufLeave,FocusLost * silent! wall
" System clipboard functionality
set clipboard+=unnamed
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Functions "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Automatically remove trailing whitespaces
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
autocmd BufWritePre * call TrimWhiteSpace()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maps "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Map Space to leader
map <Space> <Leader>
" Remap escape
inoremap jj <ESC>
" Reload config in vim
nnoremap <Leader>r :so $MYVIMRC<CR>
" Faster buffer switching
nnoremap J :bprevious<CR>
nnoremap K :bnext<CR>
" Better vertical movement with linewrappings
nnoremap j gj
nnoremap k gk
" Y yanks to end of line
map Y y$
" Enter newlines without entering insert mode
nnoremap <silent> zj o<Esc>k
nnoremap <silent> zk O<Esc>j
" Scroll faster through command history
cnoremap <c-n> <down>
cnoremap <c-p> <up>
" Stamp words - Change word with (paste) value from register
nnoremap S diw"0P