3 ms·
> Are there editors that actually overwrite the original file, instead of creating a new file? Yeah, I've been bitten by this before. I use vim though! Does ":
by erinaceousjones 6y ago
> Are there editors that actually overwrite the original file, instead of creating a new file?
Yeah, I've been bitten by this before. I use vim though! Does ":w" have different behaviour to ":wq"?
I'm pretty certain I've encountered this using fairly featureful IDEs too, as I primarily use the JetBrains suite for dev now.
This could all be compounded by me editing stuff on NFS mounts though...
- alpaca128 6y ago> Does ":w" have different behaviour to ":wq"? Or does ":w" have a different behaviour than ":up"(save file if changed) in this context? My guess would be that both just reuse the same functionality(why be inconsistent for no reason?). But regardless it's good to know this edge case can occur - trying to find the cause otherwise and reproducing the problem would be a nightmare, even if the behaviour was consistent across editors. EDIT: I tested using 'ls -li' to look at the file's inode, and while ":w", ":wq" as well as ":up" always result in a new file it seems that multiple changes can cause the inode to go back to a previously used number. So maybe this issue can occur with every editor if the file is saved multiple times.
- hiasen 6y ago> it seems that multiple changes can cause the inode to go >back to a previously used number. So maybe this issue can >occur with every editor if the file is saved multiple times. I doubt that a inode reuse can make this happen, since the inode will not be reused while bash keeps the file open.