70 lines
1.6 KiB
VimL
70 lines
1.6 KiB
VimL
set tabstop=3
|
|
set shiftwidth=3
|
|
set expandtab
|
|
set mouse=a
|
|
set number
|
|
set lazyredraw
|
|
set wildmenu
|
|
set showmatch
|
|
set hlsearch
|
|
set incsearch
|
|
set foldenable
|
|
set foldlevelstart=10
|
|
set foldnestmax=10
|
|
set foldmethod=indent
|
|
set autoindent
|
|
|
|
" leader to comma
|
|
let mapleader=","
|
|
|
|
" move between tabs
|
|
nmap L :tabn<CR>
|
|
nmap H :tabp<CR>
|
|
|
|
" move vertically in wrapped lines
|
|
nnoremap j gj
|
|
nnoremap k gk
|
|
|
|
" (clear highlight in search)
|
|
nnoremap <leader><space> :nohlsearch<CR>
|
|
" fold/unfold
|
|
nnoremap <space> za
|
|
|
|
" move to beginning/end of line. Remap old ones
|
|
nnoremap B ^
|
|
nnoremap E $
|
|
nnoremap $ <nop>
|
|
nnoremap ^ <nop>
|
|
|
|
" edit vimrc and load vimrc bindings
|
|
nnoremap <leader>ev :tabnew $MYVIMRC<CR>
|
|
nnoremap <leader>sv :source $MYVIMRC<CR>
|
|
|
|
" save session. Open next time with vim -S
|
|
nnoremap <leader>s :mksession<CR>
|
|
|
|
" jk is escape. Caseful if actually need to type jk. Type j and then let timer timeout
|
|
inoremap jk <esc>
|
|
|
|
" arrow between line changes
|
|
set whichwrap+=<,>,h,l
|
|
|
|
" formatting code
|
|
if has ('python')
|
|
map <C-K> :pyf /usr/share/vim/addons/syntax/clang-format-12.py<cr>
|
|
imap <C-K> <c-o>:pyf /usr/share/vim/addons/syntax/clang-format-12.py<cr>
|
|
elseif has ('python3')
|
|
map <C-K> :py3f /usr/share/vim/addons/syntax/clang-format-12.py<cr>
|
|
imap <C-K> <c-o>:py3f /usr/share/vim/addons/syntax/clang-format-12.py<cr>
|
|
endif
|
|
|
|
function! Formatonsave()
|
|
let l:formatdiff = 1
|
|
if has ('python')
|
|
pyf /usr/share/vim/addons/syntax/clang-format-12.py
|
|
elseif has ('python3')
|
|
py3f /usr/share/vim/addons/syntax/clang-format-12.py
|
|
endif
|
|
endfunction
|
|
autocmd BufWritePre *.h,*.c,*.cpp call Formatonsave()
|