X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=.vimrc;h=4bb96bc4ba1914ff8461dd3f50d67f58d5a8911d;hb=26a977f44877d9dead5e1f6e0374b4501688e145;hp=25658e1a0ab51ff3ca81b9c173da3f4b2468d7ec;hpb=1a259ef3810bfc08c50378b4e648fb0a4dc83385;p=dotfiles.git diff --git a/.vimrc b/.vimrc index 25658e1..4bb96bc 100644 --- a/.vimrc +++ b/.vimrc @@ -87,7 +87,9 @@ set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\ -\ [%{$USER}@%{h " 9 using the mouse -set mouse=ar " Use mouse in all modes, plus hit-return +if has('mouse') + set mouse=ar " Use mouse in all modes, plus hit-return +endif " 12 messages and info @@ -183,15 +185,16 @@ set fileencodings=ucs-bom,us-ascii,utf-8,koi8-r,cp1251,cp866,latin1 " ' - number of files for which the marks are remembered; " " and < - maximum number of lines saved for a register; " s - maximum size of an item in Kbytes. +set viminfo=!,h,'50 if version < 603 - set viminfo=!,h,'50,\"1000 + set viminfo+=\"1000 else - set viminfo=!,h,'50,<1000,s10 + set viminfo+=<1000,s10 endif " c - convert viminfo to the current encoding; if has("iconv") - set viminfo^=c + set viminfo+=c endif " Removable media paths @@ -276,29 +279,59 @@ else endif endif - " Automatically set paste mode in Vim when pasting in bracketed paste mode - " https://coderwall.com/p/if9mda/automatically-set-paste-mode-in-vim-when-pasting-in-insert-mode - function! WrapForTmux(s) - if !exists('$TMUX') - return a:s - endif - - let tmux_start = "\Ptmux;" - let tmux_end = "\\\" + " Bracketed paste mode + " https://github.com/ConradIrwin/vim-bracketed-paste/blob/master/plugin/bracketed-paste.vim + let &t_ti .= "\[?2004h" + let &t_te = "\e[?2004l" . &t_te - return tmux_start . substitute(a:s, "\", "\\", 'g') . tmux_end + function! XTermPasteBegin(ret) + set pastetoggle= + set paste + return a:ret endfunction - let &t_SI .= WrapForTmux("\[?2004h") - let &t_EI .= WrapForTmux("\[?2004l") + execute "set =\[200~" + execute "set =\[201~" + map XTermPasteBegin("i") + imap XTermPasteBegin("") + vmap XTermPasteBegin("c") + cmap + cmap + + "https://coderwall.com/p/if9mda/automatically-set-paste-mode-in-vim-when-pasting-in-insert-mode + " https://ttssh2.osdn.jp/manual/en/usage/tips/vim.html + function! WrapForScreenTmux(s) + if (&term =~ "screen") + let scr_start = "\P" + let scr_end = "\\\" + + return scr_start . a:s . scr_end + endif - function! XTermPasteBegin() - set pastetoggle=[201~ - set paste - return "" + if exists('$TMUX') + let tmux_start = "\Ptmux;" + let tmux_end = "\\\" + + return tmux_start . substitute(a:s, "\", "\\", 'g') . tmux_end + endif + + return a:s endfunction - inoremap [200~ XTermPasteBegin() + " https://vim.fandom.com/wiki/Change_cursor_shape_in_different_modes + let &t_EI.=WrapForScreenTmux("\e[2 q") "EI = NORMAL mode (ELSE) + let &t_SI.=WrapForScreenTmux("\e[6 q") "SI = INSERT mode + if v:version >= 800 + let &t_SR.=WrapForScreenTmux("\e[4 q") "SR = REPLACE mode + endif + + "Cursor settings: + " 1 -> blinking block + " 2 -> solid block + " 3 -> blinking underscore + " 4 -> solid underscore + " 5 -> blinking vertical bar + " 6 -> solid vertical bar endif " Multiline comments often confuse vim syntax highlighting - these maps @@ -570,6 +603,9 @@ function! SlowTerm() set nowildmenu set wildmode=list:longest set viminfo=!,h,'10,<100,s5 + if has("iconv") + set viminfo+=c + endif syntax off highlight NonText cterm=NONE ctermfg=NONE endfunction @@ -606,6 +642,7 @@ if executable('chmod') echoerr 'Error running chmod: ' . v:shell_error endif checktime + autocmd! FileChangedShell endfunction function! _BufChangedCB() autocmd! FileChangedShell @@ -613,6 +650,15 @@ if executable('chmod') command! ToggleXbit if executable(expand("%:p")) | call SetExecutableBit(0) | else | call SetExecutableBit(1) | endif endif +function! Code() + setlocal expandtab tabstop=8 softtabstop=4 shiftwidth=4 +endfunction +command! Code call Code() + +function! Text() + setlocal expandtab tabstop=8 softtabstop=3 shiftwidth=3 +endfunction +command! Text call Text() " ---------- " From http://slobin.pp.ru/vim/_vimrc.html @@ -726,6 +772,15 @@ if has("spell") endif endfunction autocmd BufReadPost * call SetupSpell() + + function! SaveSpell() + if expand('%') == expand('~/.vim/spell/en.ascii.add') + mkspell! -ascii % + else + mkspell! % + endif + endfunction + autocmd BufWritePost ~/.vim/spell/*.add call SaveSpell() endif