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
0
votes
0answers
22 views

How to clang-format the current buffer on save?

Whats the best way to clang-format a C/C++/GLSL a buffer on save, that does nothing in the case there is no clang-format file found for a project?
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?
0
votes
1answer
116 views

How to save the source code of a PDF file after opening it in Vim?

I am detecting malwares in PDF files for which I need their source codes too. I want to save the source code in some text file so that I can write a code to scan through all of them to detect patterns....
1
vote
1answer
67 views

Write several files all of which have been changed since read [duplicate]

I opened several files in vim and then switched git branches. I want to save the versions I have open to the new git branch, for all of them, without having to silence the WARNING: The file has ...
1
vote
0answers
31 views

Automatically saving on FocusLost sometimes stops working for a gvim window

In my ~/.vimrc I have at the moment: autocmd BufLeave,FocusLost * nested silent! wall Which most of the time works as I would like, however sometimes it seems saving simply stops working (for a ...
6
votes
2answers
660 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: ...
3
votes
3answers
2k views

How to bypass “The file has been changed since reading it”?

When I try to save a file I get the attached error almost every time. I haven't opened or modified the file in different editor. This is for Elixir files, and the code get compiled. Not sure if that ...
6
votes
1answer
2k views

Vim Error for Git Commit Message

When using vim as my default editor, I (occasionally) accidentally pull up search (e.g. via /wq instead of :wq). Once I do, I escape out of search, and then exit correctly via :wq. However, when that ...
8
votes
3answers
378 views

Preserve creation time stamp after modification

I want to modify files with vim without changing the creation time stamps. The docs doesn't seem to mention anything about such possibility. I'd like to achieve this without turning off the swap/...
2
votes
3answers
734 views

How to show all unsaved files opened in vim?

I'm not sure if I should ask this problem on vim or on Linux/Ubuntu forum. The thing is, I opened multiple terminals on my desktop, and several of them opened various of *.txt files. Not all of them ...
5
votes
2answers
48 views

Show time after saving a file

After saving a file in Vim, I get the message at the bottom of the screen "fileName" 92L, 3554C written. Is there a way to show the time in this message?
2
votes
0answers
37 views

Why does renaming with :saveas not open the new named file in the current buffer? [closed]

When editing a file named oldFile, with the command :saveas newFileName I expected vim to save the current buffer under the new named file (i.e. newFileName) and set the filename of the current buffer ...
13
votes
2answers
2k views

Does Vim autosave?

From :help swap-file: Updating the swapfile The swap file is updated after typing 200 characters or when you have not typed anything for four seconds. This only happens if the buffer was ...
30
votes
7answers
8k views

Is it possible to make Vim auto-save files?

Some word processors and text editors auto-save the files we're editing from time to time, which is very convenient for surviving from nasty crashes, etc. Is there a way to make Vim auto-save our ...
2
votes
1answer
32 views

Automatically save a file that has been previously saved

I am new to vim and was wondering if there is a way for files that have already been manually saved to be automatically saved (every few seconds). I currently make a lot of new files (for testing ...
0
votes
0answers
14 views

How to diagnose configuration---:w doesn't always work [duplicate]

I've somehow introduced a problem in my Vim configuration and I don't know how to track down where the problem is. Sometimes (most times) when I do :w then the buffer is not actually written; ...
12
votes
4answers
6k views

How do I edit crontab files with Vim (I get the error: 'temp file must be edited in place')

How do I edit crontab files in FreeBSD? $ crontab -e # ... I do my thing in vim & :wq "crontab.9ZcXiFaawt" 6L, 203C written crontab: temp file must be edited in place Exit 1 Using EDITOR=nvi ...
0
votes
2answers
77 views

Vim rewrite whole file on save?

I opened a large file, didn't make a modification, and pressed :w. Then Vim was frozen for a while. Was it simply rewriting the whole file? Is it possible to make it understand that there was no ...
0
votes
1answer
93 views

How to get writefile() to pay attention to &nofixeol?

I want to write the contents of a buffer with writefile(). However I do not want to use binary mode because I suspect it has (undocumented) side effects. My question concerns noeol files, i.e. files ...
38
votes
2answers
22k views

What are the differences between :wq<cr> :x<cr> and ZZ when exiting vim?

Vi and Vim, as all of you know, have many synonyms. There are three ways I know of to save the file and exit Vim and Vi. These are :wq <cr>, :x <cr> and ZZ. I have heard that these are ...
1
vote
1answer
476 views

How to write a value or variable into a file using only vimscript?

This question is very basic, but somehow absurdly difficult to find an answer for, because everything you find explains how to save the buffer, and I'm not interested in making new buffers or saving ...
1
vote
1answer
63 views

Can capitalized marks be saved in session INSTEAD of viminfo?

Marks are saved in .viminfo I would like to have separate marks saved per session. Is there an easy setting to make this switch? I know I could write some vimscript to save my session marks ...
2
votes
0answers
49 views

How long can a file be non-existent when I'm saving it in vim

When I'm using vim to edit files in a django application that is running in developer mode I sometimes encounter this crash coming from the auto-reload utility: File "/home/zefciu/.virtualenvs/15five/...
8
votes
6answers
4k views

How do I save a read-only file in Vim for Windows?

I have looked for this a lot already and every answer is about Vim in Linux. Is there a way to save a read-only file right from Vim in Windows?
8
votes
3answers
773 views

Write selected area to file

I'd like to write a visually selected area to a file. For example: prefix [sample text more text] suffix [] is the selected block which should be taken, resulting in a new file containing: sample ...
1
vote
1answer
80 views

Saving .swp/.un~ files to subdirectories

Is there any way to save these files to automatically created subdirs? Google gave me no answers. The reason is simple- I work on several computers which I keep synced via git, so having these files ...
3
votes
1answer
290 views

Suppress/bypass “file has changed” errors when editing cifs/Samba files

I have really two questions, sides of the same coin: 1) How exactly does vim evaluate whether the buffer is different from a file in order to determine the error WARNING: The file has been changed ...
0
votes
1answer
96 views

How to remap :w to :up?

I have a file-watcher system which triggers some compilations upon time-stamp changes in the source file I am editing. I have the obsessive habit of using :w quite a few times during my editing ...
1
vote
1answer
41 views

How to run shell commands on file without saving?

For example, if I want to run tidy on a file r! tidy % But I have to save the file beforehand. Is there any way around this?
0
votes
1answer
36 views

Discover which other user(s) are accessing a file

Every time I vim open, I get the standard warning about another user, swap file already exists, abort/quit/.., etc. I've been trying for at least 2 hours, and I'm sure I don't have the file open ...
1
vote
1answer
267 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, ...
1
vote
1answer
48 views

How to write a buffer which isn't the current to a temp file?

I would like to write a buffer which isn't the current buffer to a temp file. I have found two ways to do this: (assuming buffer 42 is the one to be written) Either use writefile(): call writefile(...
0
votes
1answer
33 views

How do I add word count to output message on successful write?

After I write a file with :w! I see in the ruler the following output message text in the ruler or status line: "FILE_NAME" 192L, 9357C written What is this output message text called in the help ...
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 ...
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 ...
3
votes
2answers
103 views

How to save a specific file in a different buffer?

Suppose I have several files open each in a different active buffer. Is there a way to save a specific file in a different buffer without first switching to it? An example of this occurring is if I ...
2
votes
1answer
975 views

set backupcopy=yes doesn't still writes the file twice

I'm trying to understand and eventually fix the following behavior: when I save a file using VIM, it triggers the change/write event twice. I'm using Ubuntu 16.10, and I created an empty .vimrc file ...
3
votes
1answer
351 views

How can I open a temporary file so that I don't get E37: No write since last change?

I have a script which performs some action and then pipes the stdout to Neovim so that I can look at it with syntax highlighting and do all the other nice things I can do with vim. However, as this ...
6
votes
2answers
492 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 ...
1
vote
2answers
583 views

What is the difference between :file and :saveas

Both :file and :saveas seem to change the name of the buffer without writing. What's the difference between them? Also, in scratch buffers, :saveas seems to cause an error while :file does not. I ...
5
votes
1answer
3k views

Why is vim save so slow?

When I save a file in Vim using :update or :w, Vim's entire UI blocks for about a second while it does something mysterious that (as a side effect) writes the buffer being edited to disk. This takes ...
2
votes
0answers
43 views

Persisting unsaved changes to untitled buffers in a session [duplicate]

Sublime Text has a killer feature I'd really like to get working in Vim. It's pretty much the only reason why I can't drop it in favor of Vim yet. The feature is that Sublime remembers unsaved ...
1
vote
1answer
58 views

Understanding File Saving Behavior in Windows

I'm a beginner at Vim. I have downloaded the latest version of Vim on my Windows 7 system. I attempted to open and save an existing .txt file after making a minor change and got some interesting ...
1
vote
3answers
221 views

How do you disable saving in vim unless you quit as well?

You are probably wondering what I could possibly need this for? Well, my program will sometimes deal with erroneous strings that need to be manually fixed. So what I do, is I create a process which ...
2
votes
0answers
56 views

What generates .pz~ backup files from .py files?

I've been doing edit-save-run-bugfix-repeat on a Python test script, using vim as my editor. My directory now looks like this: -rwxrwxr-x 1 james james 458 Nov 29 23:02 test.pr~* -rwxrwxr-x 1 james ...
4
votes
1answer
1k views

Why does `set nocompatible` result in vim saving extra, all-numeric temporary files?

I've narrowed down a bug in a program I'm working on to (surprisingly) some vim behavior! The program contains a file watcher. When I write a file with vim -u NONE and all the default settings, the ...
4
votes
1answer
580 views

How to write each line into separate file?

I'd like to write content of the file into separate files each for each line. For example: Lorem ipsum dolor sit amet consectetur adipiscing elit I'd like to write 1st line into line1.txt, 2nd ...
1
vote
2answers
246 views

vim :wq! on file with read-only permissions after escaping loading loses information in that file

I have a large file, about 1.5 Gb. When opening the file in vim, I typically will ctrl-c escape the buffering so I don't have to wait for the whole file to load. For one particular file, it was ...
2
votes
2answers
1k views

How to map a shortcut for saving the file

Can I set something like ctrl+s to save the file? I don't want to use :w every time.
1
vote
1answer
328 views

What does Command+s do in MacVim?

Is a Command+s shortcut on a MacVim equivalent to wa ? I know that a wa will save all the data being displayed in all the viewport. Will the Command+s shortcut do the same ?