3

I'm using the default file browser in Vim a lot. But the annoyance is that it's showing swap files, .orig, .php~ etc. Can I hide these files somehow?

On a related note, why doesn't Vim always return to the file browser when pushing Ctrl-6?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Olle Härstedt
  • 3,799
  • 1
  • 24
  • 57
  • possible duplicate of [How to change the folder path for swp files in Vim](http://stackoverflow.com/questions/1636297/how-to-change-the-folder-path-for-swp-files-in-vim) – the Tin Man Jan 09 '14 at 05:09

4 Answers4

9

Unless you want to move the swap and backup files to another (single) directory (as outlined in the answer of the Tin Man), you have to configure the built-in netrw plugin (which provides the file browser), as described in :help g:netrw_list_hide:

:let g:netrw_list_hide= '.*\.swp$,\~$,\.orig$'

Put this into your ~/.vimrc to make it permanent.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
6

Vim lets you define where your backup and swap files reside. It's pretty common to tell Vim to use either a local tmp directory (~/tmp), or a somewhere else semi-out-of-the-way.

You can define the location using the following commands in your $MYVIMRC file (typically ~/.vimrc). I use:

set backup                    " keep a backup file
set backupdir=~/.vim/_backups " store backups here
set directory=~/.vim/_swaps   " store swap files here

I've created _backups and _swaps in my ~/.vim directory.

Use h directory and h backupdir in Vim to read the documentation about the two settings.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
1

Most probably this files appears because Vim was closed before the buffer was written to its original file/location. Always enter :write or :update before quitting Vim.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
hawk
  • 5,409
  • 2
  • 23
  • 29
1

Instead of using Ctrl-^, try :Rex.

With netrw v151, :Rex can also return from the netrw browser to the last file being edited in that window, too.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
user21497
  • 1,061
  • 8
  • 9