-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic.vim
127 lines (103 loc) · 3.42 KB
/
basic.vim
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
" This config file is compatible with Vim and can be used as
" source ~/.config/nvim/basic.vim
" form ~/.vimrc
set nocompatible
" Map Leader key
let g:mapleader="\<Space>" " <Leader>
let g:maplocalleader="\\" " <LocalLeader>
syntax on
filetype plugin indent on
let c_minlines=500 " number of lines that vim goes backwards for syntax highlight
"set cursorline " highlight the line under the cursor
set list " show trailing spaces and tabs
set modeline " check vim configuration in file
set number " show line number
set relativenumber " relative line number at the left view edge
set scrolloff=5 " показывать всегда 5 строк до и после курсора
set wrap linebreak breakat=\s " wrap long lines
set timeoutlen=1500 " timeout for key chain
" This is the persistent undo feature of vim :help undo-persistent
if exists("+undofile")
set undofile
if !has('nvim')
if has('unix')
let undoDirPath = $HOME . '/.vim/undo'
else
let undoDirPath = $HOME .'\vimfiles\undo'
endif
if !isdirectory(undoDirPath)
call mkdir(undoDirPath, 'p')
endif
exe 'set undodir=' . undoDirPath
endif
endif
" setting shell to bash to make all work again when started from fish
"set shell=/bin/bash
" moving indentation
vnoremap < <gv
vnoremap > >gv
" Move selected up/down
vnoremap <C-Up> :m '<-2<CR>gv=gv
vnoremap <C-Down> :m '>+1<CR>gv=gv
" removing trailing spaces
autocmd FileType c,cpp,python,ruby,java,lua,vim,cmake,json,javascript,typescript,css,scss,sass,html,svg autocmd BufWritePre <buffer> :%s/\s\+$//e
" highlight 80 column
autocmd FileType c,cpp,python,ruby,java,lua setlocal colorcolumn=81
" tab size
autocmd FileType vim,lua,c,cpp,cmake,json,yaml,javascript,typescript,css,scss,sass,html,svg,htmldjango setlocal shiftwidth=2 tabstop=2
autocmd FileType fish,sh,rust,python,dockerfile,sql,toml,markdown setlocal shiftwidth=4 tabstop=4
" expand tabs
autocmd FileType c,cpp,vim,lua,htmldjango,rust,python,json,javascript,typescript,css,scss,sass,html,svg setlocal expandtab
" folding
"set foldmethod=indent
"autocmd FileType rust,c,cpp,json,javascript,typescript,css,scss,sass,html,svg setlocal foldmethod=syntax
"autocmd FileType python,yaml setlocal foldmethod=indent
" highlight search
set hlsearch
nnoremap <silent> <Esc>/ :nohlsearch<CR>
" live search while typing
set incsearch
" buffers
noremap <A-PageDown> :bnext<CR>
noremap <A-PageUp> :bprevious<CR>
noremap <leader><Tab> :b#<CR>
noremap <C-q> :bp<BAR> bd #<CR>
noremap <C-s> :w<CR>
" splits
nnoremap <A-Up> <C-w>k
nnoremap <A-Down> <C-w>j
nnoremap <A-Left> <C-w>h
nnoremap <A-Right> <C-w>l
nnoremap <A-S-Up> <C-w><S-k>
nnoremap <A-S-Down> <C-w><S-j>
nnoremap <A-S-Left> <C-w><S-h>
nnoremap <A-S-Right> <C-w><S-l>
nnoremap <silent> <C-S-Up> :resize +2<CR>
nnoremap <silent> <C-S-Down> :resize -2<CR>
nnoremap <silent> <C-S-Right> :vertical resize +5<CR>
nnoremap <silent> <C-S-Left> :vertical resize -5<CR>
" switch tabs
noremap <A-1> 1gt
noremap <A-2> 2gt
noremap <A-3> 3gt
noremap <A-4> 4gt
noremap <A-5> 5gt
noremap <A-6> 6gt
" quickfix
noremap <Leader>q :copen<CR>
noremap [q :cnext<CR>
noremap ]q :cprevious<CR>
" Saving Files that Require Root Permission with sudo
cmap w!! %!sudo tee > /dev/null %
" undo and history
set history=500
set undolevels=1000
" Easier increment/decrement
" nnoremap + <C-a>
" nnoremap - <C-x>
" autoformatting
set formatoptions=jcrqln21
" enable mouse
set mouse=nvh
" More space for messages
set cmdheight=2