2

I've been doing edit-save-run-bugfix-repeat on a Python test script, using vim as my editor. My directory now looks like this:

-rwxrwxr-x 1 james james   458 Nov 29 23:02 test.pr~*
-rwxrwxr-x 1 james james   504 Nov 29 22:53 test.ps~*
-rwxrwxr-x 1 james james   485 Nov 29 22:51 test.pt~*
-rwxrwxr-x 1 james james   503 Nov 29 22:48 test.pu~*
-rwxrwxr-x 1 james james   504 Nov 29 22:48 test.pv~*
-rwxrwxr-x 1 james james   485 Nov 29 22:40 test.pw~*
-rwxrwxr-x 1 james james   262 Nov 29 22:36 test.px~*
-rwxrwxr-x 1 james james   456 Nov 29 23:04 test.py*
-rwxrwxr-x 1 james james    96 Nov 28 22:29 test.py~*
-rwxrwxr-x 1 james james   109 Nov 29 22:20 test.pz~*

I was only expecting to see test.py. I'm guessing it was vim that did this, as they appear to be backups of the file taken at various stages of editing. But why?

Edit: here is my .vimrc file:

" My Vim config file
" The directory setting is a comma separated list of directories where
" vim should place swapfiles. Each path is tried in order and the first
" one that doesn’t fail (because it doesn’t exist or for permissions
" reasons) is where vim will create swapfiles. By default on unix
" systems, it it set to “.,~/tmp,/var/tmp,/tmp” which means it first
" tries “.” or the same directory as the file being edited. By using ^=,
" we tell vim to prepend the given value to those already set (the
" defaults). This allows vim to fall back to other directories should
" the specified one fail for some reason (directory doesn’t exist or
" disk is full for example). The double slash at the end tells vim to
" form swap file names using the full path of the edited file, replacing
" / with %, avoiding name conflicts. See :help directory for more
" details.
set directory^=$HOME/.vim_swap//
set background=dark

set tw=120
au BufRead *.sh,*.py set tw=0
au BufRead *.txt set tw=80
syntax on
filetype on
filetype plugin on
filetype indent on
inoremap <F5> <C-R>=strftime("%Y-%m-%d %H:%M")<CR>
set hlsearch
set incsearch
set expandtab
set softtabstop=4
set shiftwidth=4
"highlight OverLength ctermbg=red ctermfg=white guibg=#592929
"match OverLength /\%81v.*/

"Tell vim to remember certain things when we exit
"  '10  :  marks will be remembered for up to 10 previously edited files
"  "100 :  will save up to 100 lines for each register
"  :20  :  up to 20 lines of command-line history will be remembered
"  %    :  saves and restores the buffer list
"  n... :  where to save the viminfo files
set viminfo='10,\"100,:20,%,n~/.viminfo
function! ResCur()
  if line("'\"") <= line("$")
    normal! g`"
    return 1
  endif
endfunction

augroup resCur
  autocmd!
  autocmd BufWinEnter * call ResCur()
augroup END

set cm=blowfish " default is zip; insecure.

migrated from unix.stackexchange.com Dec 8 '16 at 23:08

This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems.

  • That seems so strange. Will you show ~/.vimrc and the system-wide vim RC file, wherever it is on your system? – Christopher Nov 30 '16 at 22:20
  • Beats me. It "looks like" a bizarre combination of incremental backups (vim.wikia.com/wiki/Keep_incremental_backups_of_edited_files) and swap file names (unix.stackexchange.com/questions/326707/…), but the RC files don't seem to configure anything like that. Maybe there are more vim RC files getting processed. I can't wait to learn the answer to this question. – Christopher Dec 1 '16 at 15:23
  • This question is perfectly on topic and welcome to stay here. If you want to, I can migrate it to Vi and Vim where there is a higher concentration of vim experts. If you'd like that, leave me a comment. – terdon Dec 1 '16 at 17:24
  • @terdon. Yes please. – jl6 Dec 1 '16 at 20:55
  • 1
    Some output that might be useful: :scriptnames and :au BufWritePost and :au CursorHold – muru Dec 2 '16 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy