Questions tagged [save]

Writing files to a persistent storage medium (usually a hard drive or SSD). In Vi, this is done with the :write command.

Filter by
Sorted by
Tagged with
6
votes
2answers
650 views

How do I run a command on creation of a new file?

I'm aiming to make scripts I write in a certain directory (or of a certain extension) automatically executable on creation. I can do this whenever a file is written to, using the following autocmd: ...
26
votes
2answers
2k views

How to save a file for which I have no write permissions?

Sometimes it happens that I open a file and make some modifications as my own user, without noticing or "forgetting" to noticing the [read-only] warning in the status line (ie. some random /etc config ...
35
votes
5answers
6k views

How do I save a file in a directory that does not yet exist?

Suppose I start Vim to edit a new file in a directory that is not yet created: vim nonExisitingDirectory/newFile.txt Vim will happily show me an empty buffer and I can start writing my new file. But ...
11
votes
2answers
660 views

Is there any vim plugin that implement hot exit feature from sublime text

Hot exit is one of killer features of Sublime Text editor. It allows to close editor at any point of time without worrying about modifications in opened files - it just closes without any question. ...
9
votes
2answers
564 views

Is there a way to alias `:w'` to `:w`, to avoid creating files named '?

Occasionally, my pinky will graze the ' key while reaching for enter, resulting in :w'<Enter>. I've tried: cabbrev w' :w cabbrev w\' :w cabbrev "w'" :w None of them work. Is there a way to ...
7
votes
2answers
752 views

How can I have vim automatically notify me when a file that I am editing changes?

I have a situation where sometimes my friend and I are working in the same file at the same time. Vim will tell me if the file has changed when I try to overwrite it. Can I have vim notify me as ...
1
vote
1answer
259 views

How to avoid “file has changed” warning when writing buffer?

I am using system() to change a buffer's file. I apply the same change to the buffer itself. I can't just reload the buffer because there are other unsaved changes. When I come to write the buffer, ...
35
votes
4answers
30k views

How can I rename the file I'm editing?

Is it possible to rename the file I'm editing from within Vim? Currently what I do is exit Vim, rename the file and open from Vim again.
9
votes
3answers
4k views

Don't add new line at the end of a file

Vim always adds a new line at the end of my files when saving, and it is causing errors in my PHP scripts. How can I make vim not add this new line on save?
15
votes
3answers
9k views

How to make vim automatically add a newline to the end of a file?

Vim normally writes <EOL> for the last line only when there was one in the original file. How to make vim to write a new line at the end of a file all the time (when the file is not binary and ...
10
votes
1answer
436 views

How can I stop Vim from writing a file without throwing an error?

I'm trying to improve the code from this answer to ask for confirmation before creating the missing directory, this is what I write: function! CreateDirectoryAskConfirmation(path) if !isdirectory(...
6
votes
2answers
487 views

No Vim, I don't want to save changes to a directory

I frequently use :e. to navigate folders and open files in gVim. But later, when I try to close the session with a :qall, I am asked by vim whether or not I want to save changes to the folder(s) I ...