|
i set my backup and swap directories to
~\vimfiles\data\swap ~\vimfiles\data\backup however at my work i very often have to edit two different revisions of the same project, meaning that quite often i have vim open two files in different directories with the same name. because of the my setting for backup and swap files this causes them to store in the same location under the same name. does anybody know of a way of giving unique names to the swap files and backup files. example: \home\myFirstProject\file.c \home\mySecondProject\file.c vim will store ~\vimfiles\data\swap\file.c.swp ~\vimfiles\data\backup\~file.c.swp for both projects. what i want is ~\vimfiles\data\swap\uniqueNameForMyFirstPeojctfile.c.swp ~\vimfiles\data\swap\uniqueNameForMySecondPeojctfile.c.swp ~\vimfiles\data\backup\~uniqueNameForMyFirstPeojctfile.c.swp ~\vimfiles\data\backup\~uniqueNameForMySecondPeojctfile.c.swp any help is appreciated -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
On Aug 12, 9:17 am, cyboman <[hidden email]> wrote: > i set my backup and swap directories to ... What you ask can be done with autocommands, but maybe it would be simpler to use (from :help 'dir'): - For Unix and Win32, if a directory ends in two path separators "//" or "\\", the swap file name will be built from the complete path to the file with all path separators substituted to percent '%' signs. Regards, John -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
In reply to this post by cyboman
On 2011-08-11, cyboman wrote:
> i set my backup and swap directories to > > ~\vimfiles\data\swap > ~\vimfiles\data\backup > > however at my work i very often have to edit two different revisions > of the same project, meaning that quite often i have vim open two > files in different directories with the same name. because of the my > setting for backup and swap files this causes them to store in the > same location under the same name. does anybody know of a way of > giving unique names to the swap files and backup files. > > example: > > \home\myFirstProject\file.c > \home\mySecondProject\file.c > > vim will store > ~\vimfiles\data\swap\file.c.swp > ~\vimfiles\data\backup\~file.c.swp > > for both projects. > > what i want is > > ~\vimfiles\data\swap\uniqueNameForMyFirstPeojctfile.c.swp > ~\vimfiles\data\swap\uniqueNameForMySecondPeojctfile.c.swp > ~\vimfiles\data\backup\~uniqueNameForMyFirstPeojctfile.c.swp > ~\vimfiles\data\backup\~uniqueNameForMySecondPeojctfile.c.swp > > any help is appreciated For swap files it's easy: just put two slashes at the end of each directory name in the 'directory' option, e.g., set directory=~/tmp/vimswap//,$TMP//,$TEMP// That will generate a unique name for each swap file based on the full path name of the original file. See :help 'directory' Unfortunately the same feature does not exist yet for backup files. It's still an item in the todo list, but at least it's in the "known bugs and current work" section, so maybe it's coming soon. In the mean time, you may want to turn off the 'backup' option and create your own backups using a BufRead autocommand or one of the backup plugins. Regards, Gary -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
On Aug 12, 9:49 am, Gary Johnson <[hidden email]> wrote:
> In the mean time, you may want to turn off the 'backup' option and > create your own backups using a BufRead autocommand ... Or use the BufWritePost event to rename the backup that has just been created. I sometimes do that to put a time stamp in the backup file name, so that all such backup files are kept indefinitely. (I've been persuaded that that using a version control system, checking in on every save, is a better way to do the same thing, but haven't got around to it.) Maybe (minimally tested): function! ProjBackup() let bup = globpath(&backupdir, expand('%:t') . &bex) if bup != "" let this = expand('%:p:h') if this =~? 'myFirstProject' let add = 'uniqueNameForMyFirstPeojct' elseif this =~? 'mySecondProject' let add = 'uniqueNameForMySecondPeojct' else " use last directory let add = substitute(this,'.*[/\\]','',"") endif let newname = substitute(bup,'[\\/]\ze[^\\/]\+$','&' . add, '') if rename(bup, newname) echoerr "failed rename of backup " . bup . " to " . newname endif endif endfunction augroup ProjBackup au! BufWritePost * call ProjBackup() augroup END HTH, and regards, John -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
In reply to this post by Gary Johnson-4
On Aug 11, 5:49 pm, Gary Johnson <[hidden email]> wrote: > On 2011-08-11, cyboman wrote: > > i set my backup and swap directories to > > > ~\vimfiles\data\swap > > ~\vimfiles\data\backup > > > however at my work i very often have to edit two different revisions > > of the same project, meaning that quite often i have vim open two > > files in different directories with the same name. because of the my > > setting for backup and swap files this causes them to store in the > > same location under the same name. does anybody know of a way of > > giving unique names to the swap files and backup files. > > > example: > > > \home\myFirstProject\file.c > > \home\mySecondProject\file.c > > > vim will store > > ~\vimfiles\data\swap\file.c.swp > > ~\vimfiles\data\backup\~file.c.swp > > > for both projects. > > > what i want is > > > ~\vimfiles\data\swap\uniqueNameForMyFirstPeojctfile.c.swp > > ~\vimfiles\data\swap\uniqueNameForMySecondPeojctfile.c.swp > > ~\vimfiles\data\backup\~uniqueNameForMyFirstPeojctfile.c.swp > > ~\vimfiles\data\backup\~uniqueNameForMySecondPeojctfile.c.swp > > > any help is appreciated > > For swap files it's easy: just put two slashes at the end of each > directory name in the 'directory' option, e.g., > > set directory=~/tmp/vimswap//,$TMP//,$TEMP// > > That will generate a unique name for each swap file based on the > full path name of the original file. See > > :help 'directory' > > Unfortunately the same feature does not exist yet for backup > files. It's still an item in the todo list, but at least it's in > the "known bugs and current work" section, so maybe it's coming > soon. > > In the mean time, you may want to turn off the 'backup' option and > create your own backups using a BufRead autocommand or one of the > backup plugins. > > Regards, > Gary thanks for the help everyone. i'll wait till the full feature for the backup will be implemented but will use the swap file with a full name feature. -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
In reply to this post by Gary Johnson-4
On Thu, August 11, 2011 11:49 pm, Gary Johnson wrote:
> Unfortunately the same feature does not exist yet for backup > files. It's still an item in the todo list, but at least it's in > the "known bugs and current work" section, so maybe it's coming > soon. I made the patch last year. I think, when Bram comes around that far in the todo list, it might be integrated. Depending how far down it is in the todo list, this may take forever. regards, Christian -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
| Powered by Nabble | Edit this page |
