From daf00944091b8611cfa4a377faf23188532be74e Mon Sep 17 00:00:00 2001 From: bretello Date: Wed, 9 Dec 2020 01:54:42 +0100 Subject: [PATCH] vim: add persistent undo --- ansible/playbooks/setup.yml | 10 +++++++++- vim/vimrc | 15 +++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ansible/playbooks/setup.yml b/ansible/playbooks/setup.yml index f70c7fb..d8f7886 100644 --- a/ansible/playbooks/setup.yml +++ b/ansible/playbooks/setup.yml @@ -60,9 +60,17 @@ "ackrc": "~/.ackrc" "vim/vimrc": "~/.vimrc" "pdbrc.py": "~/.pdbrc.py" - # "ipython": "~/.ipython" # FIXME: ipython config is more complex + # "ipython": "~/.ipython" # FIXME: ipython config is more complex "ansible.cfg": "~/.ansible.cfg" + - name: check undodir_migration + stat: path=${HOME}/.vim_runtime/temp_dirs/undodir + register: undodir + + - name: vim undodir migration + command: mv ${HOME}/.vim_runtime/temp_dirs/undodir ${HOME}/.vim/undo + when: undodir.stat.exists + - name: git config facts community.general.git_config: name: "include.path" diff --git a/vim/vimrc b/vim/vimrc index 990ed6f..4f9e14c 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -29,11 +29,16 @@ set lazyredraw set ignorecase smartcase " ignore case on search but be smart about it set hlsearch "highlight search results (using *) -set shiftwidth=4 tabstop=4 +set expandtab shiftwidth=4 tabstop=4 "always use spaces + autocmd FileType yaml,yml setlocal shiftwidth=2 softtabstop=2 expandtab au BufRead,BufNewFile */playbooks/*.yml set filetype=yaml.ansible -au BufRead,BufNewFile rules.v[46] set filetype=iptables +au BufRead,BufNewFile rules.v[46] setlocal filetype=iptables +if has('persistent_undo') + set undodir=$HOME/.vim/undo + set undofile +endif " Return to last edit position when opening files (from amix's vimrc) au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif @@ -49,12 +54,6 @@ cnoremap cnoremap cnoremap -try - set undodir=~/.vim/temp_dirs/undodir - set undofile -catch -endtry - source $DOTFILES/vim/plugins_config.vim source $DOTFILES/vim/shortcuts.vim source $DOTFILES/vim/functions.vim