]> git.phdru.name Git - dotfiles.git/blobdiff - .vimrc
.gitconfig: Add transfer.fsckObjects but not enable it
[dotfiles.git] / .vimrc
diff --git a/.vimrc b/.vimrc
index 852d3cb21fb0abe5c8ae7a1a37c151f762295f09..4b7fdf81137662374cecbae71c9456d9deda1816 100644 (file)
--- a/.vimrc
+++ b/.vimrc
@@ -125,11 +125,17 @@ endif
 
 " 20 the swap file
 
+let myUndoDir = expand('~/tmp/vim/undo')
+if !isdirectory(myUndoDir)
+    " Create dirs
+    call mkdir(myUndoDir, 'p')
+endif
+
 " list of directories for the swap file; remove . (the current directory)
 if has("win32")
-   set directory=$TEMP//,c:/tmp//,c:/temp//
+   set directory=~/tmp/vim//,$TEMP//,c:/tmp//,c:/temp//
 else
-   set directory=~/tmp//,/var/tmp//,/tmp//
+   set directory=~/tmp/vim//,~/tmp//,/var/tmp//,/tmp//
 endif
 " if a directory ends in two path separators "//"
 " or "\\", the swap file name will be built from the complete path to
@@ -144,6 +150,12 @@ set wildignore+=*.py[co] " Ignore these patterns when completing file names
 set wildmenu      " command-line completion shows a list of matches
 set wildmode=longest,list:longest,full " Bash-vim completion behavior
 
+" Keep undo history across sessions by storing it in a file
+if has('persistent_undo')
+    let &undodir = myUndoDir
+    set undofile
+endif
+
 " 22 executing external commands
 
 if has("filterpipe")
@@ -250,6 +262,30 @@ else
          let &t_fs = "\007"
       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 = "\<Esc>Ptmux;"
+     let tmux_end = "\<Esc>\\"
+
+     return tmux_start . substitute(a:s, "\<Esc>", "\<Esc>\<Esc>", 'g') . tmux_end
+   endfunction
+
+   let &t_SI .= WrapForTmux("\<Esc>[?2004h")
+   let &t_EI .= WrapForTmux("\<Esc>[?2004l")
+
+   function! XTermPasteBegin()
+     set pastetoggle=<Esc>[201~
+     set paste
+     return ""
+   endfunction
+
+   inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
 endif
 
 " Multiline comments often confuse vim syntax highlighting - these maps