-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
155 lines (140 loc) · 3.94 KB
/
init.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
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
" ---------- Plugins
" Installing VIM-PLUG
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Uncomment and then install these using :PlugInstall
call plug#begin()
" Plug 'sbdchd/neoformat' " Format code
" Plug 'lambdalisue/suda.vim' " Easily write sudo file
" Plug 'neoclide/coc.nvim' " vs code like extensions for coding https://github.com/neoclide/coc.nvim
" Plug 'pseewald/vim-anyfold' " Fold Code, enable the config at the bottom of .vimrc config file
call plug#end()
" ---------- Set options
" Sets number on left
set number
" Sets relative number on left
set relativenumber
" Highlight all searches done
set hlsearch
" Indent automatically
set smartindent
" Indentation width in spaces
set tabstop=4
" Use actual spaces instead of tabs
set expandtab
" Autoindentation width in spaces
set shiftwidth=4
" Set clipboard as global
set clipboard+=unnamedplus
" Colorscheme
colorscheme pablo
" Automatically write when opening another file
set autowrite
" No word wrapping
set nowrap
" Show line and column at bottom right
set ruler
" Set history size for commands, (default is 50)
set history=1000
" Ignore case sensitve search
set ignorecase smartcase
" Indendation
set autoindent smarttab expandtab
set list
set listchars=tab:▸\ ,trail:•,extends:»,precedes:«,nbsp:¬
set scrolloff=8 sidescrolloff=5
" leader key timeout time
set ttimeout ttimeoutlen=1 timeoutlen=500
" prevent creation of swap files
set noswapfile nowritebackup nobackup
" Wild menu triggered by tab
set wildmenu wildmode=list:full
set wildignore=*.o,*.obj,tmp,.git,node_modules,bower_components,.DS_Store,build
" show last entered command at bottom
set showcmd
" Show cursor line
set cursorline
" Height of popup menu
set pumheight=20
" Display bottom line (for status messages)
set display+=lastline
" Split display position
set splitright splitbelow
" Disable vim fold
set nofoldenable
" Cursor support
set mouse=a
" ---------- Mappings
" Space bar is the leader key
let mapleader = " "
" ----- Normal mode
" --- Writing and quiting ease
noremap <Leader>ww :w<CR>
noremap <Leader>ws :SudaWrite<CR>
noremap <Leader>wa :wa<CR>
noremap <Leader>wq :wq<CR>
noremap <Leader>qq :q!<CR>
noremap <Leader>Q :q!<CR>
noremap <Leader>qa :qa!<CR>
" --- Options toggling
noremap <Leader>nw :set nowrap!<CR>
noremap <Leader>nc :set cursorline!<CR>
noremap <Leader>h :set hlsearch!
" --- Replacing text using regex
noremap <Leader>r :s///g
noremap <Leader><S-R> :%s///g
noremap <Leader>ya :norm mmggVGy'm<CR>
" --- Doom emacs like writing
" noremap <Leader>ba :w! backup<CR> " create a backup
noremap <Leader>bd :q!<CR>
noremap <Leader>bs :w<CR>
" --- Tabs
nnoremap <Leader>t :tabe ./
nnoremap <C-h> :tabprevious<CR>
nnoremap <C-l> :tabnext<CR>
nnoremap <C-right> :tabprevious<CR>
nnoremap <C-left> :tabnext<CR>
" Config file
nnoremap <Leader>T :tabe ~/.vimrc <CR>
" --- Other mappings
" plugins installation shortcut
noremap <Leader>pi :PlugInstall<CR>
" list files here
noremap <Leader>l :!ll<CR>
" Toggle fold
noremap <Tab> za
" Toggle unfold
noremap <S-Tab> zi
noremap k gk
noremap j gj
map <F8> :Neoformat <cr>
map <F7> :!mkdir
map <F6> :!touch
noremap <Leader><Leader> :norm mzI#<ESC>'z<CR>
" ----- Insert mode
map Q <Nop>
map K <Nop>
" --- Centering whenever possible
map n nzz
map } }zz
map { {zz
map G Gzz
map g; g;zz
" easy and quick escape
inoremap jk <Esc>
" ctrl + backspace in vim
inoremap <C-H> <C-W>
" ----- Commands
command! Q q
command! Qa qa
command! W w
command! Wa wa
" ---------------- vim-anyfold config
" filetype plugin indent on " required
" syntax on " required
" autocmd Filetype * AnyFoldActivate " activate for all filetypes
" set foldlevel=0 " close all folds by default
" set foldlevel=99 " open all folds by default