Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
GNU/Linux kernel 2.6, Slackware.
VIM - Vi IMproved 7.1
Huge version without GUI.
Hi:
When I quit an editing sesion vim creates a backup file with the same name as that of the edited file but with a '~' appended. I would like the name for the backup file to be the following: same base name as that of the edited file and edited file extension replaced by 'bak'. Example:
Input file//////////////backup file after editing
----------//////////////-------------------------
foo.txt/////////////////foo.txt~
foo.txt/////////////////foo.bak
The first line corresponds to what vim now does. The second one is what I want vim to do. If someone could give me a hint I would greatly appreciate it. Regards,
Are you sure it does that? IME, it only creates the backup for the duration of the edit session, then removes it on successful exit or quit.
The only time I've seen the file still there afterwards is if I've crashed out of the editor for some reason... that's how it recovers your prev session.
Any editor does that. Nano does it Kate does it gedit does it. They all create a copy of your file ending with ~. It is a temporary backup of your last session.
Not any editor. dbEdit under MS-DOS replaces the extension with .bak as the name of the backup file. And this backup is permanent, not temporary. And I want vim to behave, in this respect, as dbEdit.
Not any editor. dbEdit under MS-DOS replaces the extension with .bak as the name of the backup file. And this backup is permanent, not temporary. And I want vim to behave, in this respect, as dbEdit.
Thanks for your replies.
This is not MS-DOS. Things do act differently. I have not seen a Linux Editor that doesn't add ~ at the end of the session files. If you want an editor that works like dbEdit, then use dbEdit. Unfortunately in Linux the convention is to end the file with ~ and not .bak. MS-DOS requires a file extention, Linux does not. I don't think you will find a native Linux editor that will save those files as .bak, but best of luck to you in your search.
Thanks a lot. Then, unfortunately, I'm doomed to have three files coexisting. Even worst: if I order windows/dos to delete all *~ it seems not to see them. It lists them when I issue the dir command but 'del *~' does nothing. Well. Good bye and best wishes.
You could use:
:set backupext="bak"
maybe you need to use
:set backupext=".bak"
There are other options about the backup files, such as whether a new file is created or the old one renamed which might be important if editing from a share.
See
:help backupext
for the extension info
:help backup
for the other information about the backup files.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.