vim: tidy
This commit is contained in:
130
vimrc
130
vimrc
@@ -1,23 +1,9 @@
|
|||||||
" Adapted from Dan's .vimrc, and Sven Gucke's vimrc.forall - Paul
|
|
||||||
|
|
||||||
if empty(glob('~/.vim/autoload/plug.vim'))
|
if empty(glob('~/.vim/autoload/plug.vim'))
|
||||||
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
||||||
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||||
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
|
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"if has("unix") || has("gui_macvim")
|
|
||||||
" let s:uname = system("uname -s")
|
|
||||||
" if s:uname == "Darwin" || has("gui_macvim")
|
|
||||||
" echom "Remapping Escape"
|
|
||||||
" "make jj do esc"
|
|
||||||
" inoremap § <Esc>
|
|
||||||
|
|
||||||
" "make esc do nothing"
|
|
||||||
" inoremap <Esc> <Nop>
|
|
||||||
" endif
|
|
||||||
"endif
|
|
||||||
|
|
||||||
call plug#begin('~/.vim/plugged')
|
call plug#begin('~/.vim/plugged')
|
||||||
Plug 'junegunn/vim-easy-align/'
|
Plug 'junegunn/vim-easy-align/'
|
||||||
|
|
||||||
@@ -66,7 +52,7 @@ call plug#begin('~/.vim/plugged')
|
|||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
let mapleader = ' '
|
let mapleader = ' '
|
||||||
let maplocalleader = ' '
|
let maplocalleader = ','
|
||||||
|
|
||||||
" Edit another file in the same directory as the current file. Uses expression
|
" Edit another file in the same directory as the current file. Uses expression
|
||||||
" to extract path from current file's path (thanks to Douglas Potts)
|
" to extract path from current file's path (thanks to Douglas Potts)
|
||||||
@@ -95,8 +81,8 @@ nnoremap <leader>wl viwu
|
|||||||
nnoremap <C-U> viwU
|
nnoremap <C-U> viwU
|
||||||
nnoremap <C-L> viwu
|
nnoremap <C-L> viwu
|
||||||
|
|
||||||
nmap <c-s-down> ddp
|
nnoremap <c-s-up> dd2kp
|
||||||
nmap <c-s-up> dd2jp
|
nnoremap <c-s-down> ddp
|
||||||
|
|
||||||
nnoremap <leader>q :Bdelete<CR>
|
nnoremap <leader>q :Bdelete<CR>
|
||||||
|
|
||||||
@@ -106,8 +92,14 @@ nnoremap Q @@
|
|||||||
" Close all folds
|
" Close all folds
|
||||||
nnoremap c- zM
|
nnoremap c- zM
|
||||||
|
|
||||||
" nmap <leader>cw y/ <CR>
|
nnoremap <leader>cw y/ <CR>
|
||||||
nmap <leader>wp 0v$gq
|
nnoremap <leader>wp 0v$gq
|
||||||
|
|
||||||
|
inoremap jk <esc>
|
||||||
|
" inoremap <esc> <nop>
|
||||||
|
|
||||||
|
color desert
|
||||||
|
" colorscheme dracula
|
||||||
|
|
||||||
set ignorecase smartcase
|
set ignorecase smartcase
|
||||||
set incsearch
|
set incsearch
|
||||||
@@ -116,18 +108,7 @@ set complete=.,b,u,]
|
|||||||
|
|
||||||
set wildignore+=deps/*,node_modules/*,*.sw?
|
set wildignore+=deps/*,node_modules/*,*.sw?
|
||||||
|
|
||||||
" color desert
|
|
||||||
colorscheme dracula
|
|
||||||
" if has("AirlineTheme")
|
|
||||||
" if has("gui_running")
|
|
||||||
" let g:airline_theme="papercolor"
|
|
||||||
" endif
|
|
||||||
" endif
|
|
||||||
|
|
||||||
" enable syntax highlighting if it is supported
|
|
||||||
if has("syntax")
|
|
||||||
syntax on
|
syntax on
|
||||||
endif
|
|
||||||
|
|
||||||
" Turn off the beeping ('cause it's annoying)
|
" Turn off the beeping ('cause it's annoying)
|
||||||
set noerrorbells
|
set noerrorbells
|
||||||
@@ -200,21 +181,34 @@ augroup END
|
|||||||
" Apply the muttrc colouring to mutt setup files:
|
" Apply the muttrc colouring to mutt setup files:
|
||||||
au BufNewFile,BufRead .mutt.* set ft=muttrc
|
au BufNewFile,BufRead .mutt.* set ft=muttrc
|
||||||
|
|
||||||
augroup filetype_elixir
|
augroup filetype elixir
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufRead * imap ii IO.inspect(
|
autocmd BufRead * imap ii IO.inspect(
|
||||||
" autocmd BufRead * imap ip IO.puts(
|
" autocmd BufRead * imap ip IO.puts(
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
augroup filetype_vue
|
augroup filetype vue
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufRead * imap cll console.log()<Esc>==f(a
|
autocmd BufRead,BufNewFile *.vue inoremap cll console.log()<left>
|
||||||
|
call TabSize(2)
|
||||||
|
iabbrev template <template><cr><tab><div><cr></div><cr></template
|
||||||
|
iabbrev script <script><cr>export default {<cr>name: ""<cr>};<cr></script
|
||||||
|
iabbrev style <style scoped><cr></style
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
augroup filetype_javascript
|
augroup filetype javascript
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufRead,BufNewFile * imap cll console.log()<Esc>==f(a
|
autocmd BufRead,BufNewFile *.js inoremap cll console.log()<left>
|
||||||
call TabSize(2)
|
call TabSize(2)
|
||||||
|
" inoremap <localleader>\li logger.info("
|
||||||
|
" inoremap <localleader>\cli <esc>3cwlogger.info("i
|
||||||
|
iabbrev <buffer> iff if()<left>
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
augroup filetype make
|
||||||
|
autocmd!
|
||||||
|
call TabSize(8)
|
||||||
|
set noexpandtab
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Automatic typo fixing
|
" Automatic typo fixing
|
||||||
@@ -223,8 +217,6 @@ iab compomemt component
|
|||||||
" Disable the command 'K' (keyword lookup)
|
" Disable the command 'K' (keyword lookup)
|
||||||
" map K <NUL>
|
" map K <NUL>
|
||||||
|
|
||||||
" Insert file
|
|
||||||
map <C-K>e :read
|
|
||||||
" List current buffers
|
" List current buffers
|
||||||
map <C-L> :buffers<CR>
|
map <C-L> :buffers<CR>
|
||||||
" Reformat selected text; normal mode only so we don't accidentally wrap a
|
" Reformat selected text; normal mode only so we don't accidentally wrap a
|
||||||
@@ -263,8 +255,6 @@ nnoremap <leader>wfw :set winfixwidth
|
|||||||
" Fix the height of the window
|
" Fix the height of the window
|
||||||
nnoremap <leader>wfh :set winfixheight
|
nnoremap <leader>wfh :set winfixheight
|
||||||
|
|
||||||
nnoremap <leader>qw /\s<CR>i"<ESC>?\s<CR>i"<ESC>
|
|
||||||
|
|
||||||
" map <C-Up> :wincmd k<CR>
|
" map <C-Up> :wincmd k<CR>
|
||||||
" map <C-Down> :wincmd j<CR>
|
" map <C-Down> :wincmd j<CR>
|
||||||
|
|
||||||
@@ -275,6 +265,7 @@ map <C-CR> @a
|
|||||||
|
|
||||||
" Set swapsync to 'nothing' - potentially more data loss (no forced write to disk
|
" Set swapsync to 'nothing' - potentially more data loss (no forced write to disk
|
||||||
" on swap write), but makes writes faster. I'm willing to take the chance. :-)
|
" on swap write), but makes writes faster. I'm willing to take the chance. :-)
|
||||||
|
" Not supported on Neovim.
|
||||||
if !has("nvim")
|
if !has("nvim")
|
||||||
set sws=
|
set sws=
|
||||||
endif
|
endif
|
||||||
@@ -295,16 +286,18 @@ noremap <C-G> 2<C-G>
|
|||||||
" VIM - Editing and updating the vimrc:
|
" VIM - Editing and updating the vimrc:
|
||||||
" As I often make changes to this file I use these commands
|
" As I often make changes to this file I use these commands
|
||||||
" to start editing it and also update it:
|
" to start editing it and also update it:
|
||||||
if has("unix")
|
" Redundant - replaced by $MYVIMRC
|
||||||
let vimrc='~/.vimrc'
|
" if has("unix")
|
||||||
else
|
" let vimrc='~/.vimrc'
|
||||||
" ie: if has("dos16") || has("dos32") || has("win32")
|
" else
|
||||||
let vimrc='$VIM\_vimrc'
|
" " ie: if has("dos16") || has("dos32") || has("win32")
|
||||||
endif
|
" let vimrc='$VIM\_vimrc'
|
||||||
|
" endif
|
||||||
|
|
||||||
" Re-source and edit vimrc, respectively
|
" Re-source and edit vimrc, respectively
|
||||||
nn ,u :source <C-R>=vimrc<CR><CR>
|
nnoremap ,u :source <C-R>=vimrc<CR><CR>
|
||||||
nn ,v :edit <C-R>=vimrc<CR><CR>
|
" nnoremap ,v :edit <C-R>=vimrc<CR><CR>
|
||||||
|
nnoremap ,v :vsplit $MYVIMRC<CR>
|
||||||
|
|
||||||
nn ,s :mks! Session.vim<CR>
|
nn ,s :mks! Session.vim<CR>
|
||||||
|
|
||||||
@@ -357,33 +350,16 @@ set ruler
|
|||||||
" set nohlsearch
|
" set nohlsearch
|
||||||
|
|
||||||
" Return makes a new line at the cursor without entering insert mode
|
" Return makes a new line at the cursor without entering insert mode
|
||||||
map <CR> i<CR><ESC>
|
nmap <CR> i<CR><ESC>
|
||||||
|
|
||||||
" Cut text down to size (C-J does not pre-join the lines)
|
" Cut text down to size (C-J does not pre-join the lines)
|
||||||
map <C-J> 74\|bi<CR><ESC>
|
map <C-J> 74\|bi<CR><ESC>
|
||||||
map <C-S-J> J74\|bi<CR><ESC>
|
map <C-S-J> J74\|bi<CR><ESC>
|
||||||
|
|
||||||
" <Tab> and <S-Tab> indent and unindent code
|
|
||||||
map <Tab> :><CR>
|
|
||||||
map <S-Tab> :<<CR>
|
|
||||||
map <C-S-Tab> :<<CR><DOWN>
|
|
||||||
|
|
||||||
" get man page of current function or open current URL in netscape
|
|
||||||
map <F1> :!man <cword><CR>
|
|
||||||
"map <S-F1> ?[ \t'"()<>{}[\]]<CR>ly/[ \t'"()<>{}[\]]<CR>:!gnome-moz-remote --newwin <C-R>"<CR>
|
|
||||||
|
|
||||||
" Use fzf to find files
|
" Use fzf to find files
|
||||||
map <F2> :Files<CR>
|
|
||||||
map <C-P> :Files<CR>
|
map <C-P> :Files<CR>
|
||||||
map <C-O> :Files <C-R>=expand("%:p:h")<CR>
|
map <C-O> :Files <C-R>=expand("%:p:h")<CR>
|
||||||
|
|
||||||
nnoremap <silent> <leader>m :FZFMru<CR>
|
nnoremap <silent> <leader>m :FZFMru<CR>
|
||||||
|
|
||||||
map <F3> :Ag <C-R>=expand("<cword>")<CR><CR>
|
|
||||||
nnoremap <leader>f :Ag <C-R>=expand("<cword>")<CR><CR>
|
|
||||||
|
|
||||||
" use F4 to bring up NERDTree
|
|
||||||
map <F4> :NERDTree<CR>
|
|
||||||
nnoremap <leader>n :NERDTreeToggle<cr>
|
nnoremap <leader>n :NERDTreeToggle<cr>
|
||||||
|
|
||||||
" Use F6 to swap buffers
|
" Use F6 to swap buffers
|
||||||
@@ -396,23 +372,10 @@ nnoremap <leader>ss :syntax sync fromstart<CR>
|
|||||||
|
|
||||||
nnoremap <leader>t :TagbarToggle<CR>
|
nnoremap <leader>t :TagbarToggle<CR>
|
||||||
|
|
||||||
" repeat the last command on the next line (F12 is Again on Sun keyboards)
|
|
||||||
map <F12> j.
|
|
||||||
|
|
||||||
" use Print Screen to print the current file
|
|
||||||
map <F22> :!a2ps %<CR>
|
|
||||||
|
|
||||||
" date functions
|
" date functions
|
||||||
map ,dn i<CR><CR><ESC>k!!date +'\%d/\%m/\%y'<CR>kJJ
|
nnoremap ,dn i<CR><CR><ESC>k!!date +'\%d/\%m/\%y'<CR>kJJ
|
||||||
map ,dw i<CR><CR><ESC>k!!date +'\%V'<CR>kJJ
|
nnoremap ,dw i<CR><CR><ESC>k!!date +'\%V'<CR>kJJ
|
||||||
|
|
||||||
" (double) quote up the word under the cursor
|
|
||||||
map ` bi"<ESC>wwhi"<ESC>
|
|
||||||
|
|
||||||
" use GNU make (gnu_make is a script to perform builds with GNU make
|
|
||||||
" and filter results into GNU format error report)
|
|
||||||
" :set mp=gnu_make
|
|
||||||
" :set mp=make
|
|
||||||
|
|
||||||
" xterm title magic
|
" xterm title magic
|
||||||
if "$TERM" != "dumb"
|
if "$TERM" != "dumb"
|
||||||
@@ -470,7 +433,6 @@ function! ToggleWindowHorizontalVerticalSplit()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
nnoremap <silent> <leader>wst :call ToggleWindowHorizontalVerticalSplit()<cr>
|
nnoremap <silent> <leader>wst :call ToggleWindowHorizontalVerticalSplit()<cr>
|
||||||
" inoremap <lt>/ </<C-x><C-o><Esc>==gi
|
|
||||||
|
|
||||||
" COC configuration
|
" COC configuration
|
||||||
if version >= 800
|
if version >= 800
|
||||||
@@ -604,6 +566,7 @@ if version >= 800
|
|||||||
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
|
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" <Tab> and <S-Tab> indent and unindent code
|
||||||
nmap <Tab> :><CR>
|
nmap <Tab> :><CR>
|
||||||
vmap <Tab> :><CR>
|
vmap <Tab> :><CR>
|
||||||
nnoremap <leader>f :Ag <C-R>=expand("<cword>")<CR><CR>
|
nnoremap <leader>f :Ag <C-R>=expand("<cword>")<CR><CR>
|
||||||
@@ -614,9 +577,6 @@ nmap <silent> tF :TestFile<CR>
|
|||||||
nmap <silent> tS :TestSuite<CR>
|
nmap <silent> tS :TestSuite<CR>
|
||||||
nmap <silent> tL :TestLast<CR>
|
nmap <silent> tL :TestLast<CR>
|
||||||
nmap <silent> tG :TestVisit<CR>d
|
nmap <silent> tG :TestVisit<CR>d
|
||||||
" nmap <C-M> :<CR>
|
|
||||||
" nmap <C-M> :Make<CR>
|
|
||||||
" nmap <C-S-M> :Make!<CR>
|
|
||||||
|
|
||||||
" Opening with the default program
|
" Opening with the default program
|
||||||
if has('macunix')
|
if has('macunix')
|
||||||
@@ -633,6 +593,8 @@ elseif has('unix')
|
|||||||
nnoremap gH :!xdg-open %:p:h<CR>
|
nnoremap gH :!xdg-open %:p:h<CR>
|
||||||
" Open in Browser
|
" Open in Browser
|
||||||
nnoremap gB :!xdg-open %<CR>
|
nnoremap gB :!xdg-open %<CR>
|
||||||
|
else
|
||||||
|
echom "Don't know how to open on this platform."
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Markdown folding
|
" Markdown folding
|
||||||
|
|||||||
Reference in New Issue
Block a user