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
1answer
23 views

Permit closing window with unsaved changes using vim setting

I wrote a plugin that executes a slow shell script and asynchronously shows the stdout in a popup (split) window. When I try to close my session while the popup is open, I get the message Save ...
1
vote
1answer
51 views

Is it possible to have vim run a command every time save `:w` is invoked?

I am editting typescript now, and I'd like to be able to have it so, whenever :w is invoked, the shell runs tsc compiling my new save. This beats having to !tsc every time. Does something like this ...
0
votes
1answer
23 views

I want to save my typescript file, and immediately run tsc myfile.ts from inside vim. What is the best way to accomplish this?

I am building a daemon, and nodemon currently monitors a file called server.js, which is compiled from the file I am working on, server.ts In order to compile server.ts, after saving with :w, I need ...
0
votes
0answers
25 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?
1
vote
1answer
70 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
33 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 ...
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 ...
2
votes
1answer
40 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; ...
0
votes
2answers
80 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
106 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 ...
1
vote
1answer
64 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/...
1
vote
1answer
88 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
312 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 ...
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 ...
1
vote
1answer
42 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
101 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
513 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 ...
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
281 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
49 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
34 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 ...
0
votes
1answer
118 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....
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 ...
3
votes
2answers
104 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 ...
3
votes
1answer
376 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 ...
1
vote
2answers
594 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 ...
8
votes
3answers
845 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 ...
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
1answer
1k 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 ...
2
votes
0answers
44 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
227 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
57 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 ...
1
vote
2answers
256 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 ...
3
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
329 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 ?
0
votes
0answers
885 views

How I configure Vim for use with netrw?

I recently started to use netrw as a file manager next to my editing session. But I had a coupe of issues with it. First of all netrw reads unhidden buffers from the disk every time. Which made me ...
4
votes
1answer
584 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 ...
4
votes
1answer
663 views

How to auto save file when moving between split?

I'd like to automatically save buffer after moving into another split. If you're interested why I'm interested in that read section below. I've started using vim and then neovim not so long ago, so ...
3
votes
1answer
86 views

How to make :wa overwrite externally-changed files?

I've noticed that when I have several files open in Vim, and one of the files has been changed by an external program, :wa doesn't actually try to write into that file. OTOH, going to that file and ...
11
votes
2answers
359 views

How to make sure no changes are made to a file

Is there anyway I could make sure a file is locked so that I cant make any changes to it. Is there a command for locking / unlocking a file in vim. Some times i would like a file to be in readonly ...
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?
4
votes
1answer
359 views

MacVim doesn't redraw screen properly [closed]

Sometimes when I do something like saving, opening another file or another tab, the screen isn't changing states properly. At first I thought it was just my computer being slow, but then I noticed ...
11
votes
2answers
677 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. ...
38
votes
2answers
23k 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 ...
4
votes
1answer
213 views

Save/Quit Unprivileged File With Sudo

I found the following command, which saves the current file with sudo, meaning you can open a file you don't have write access to (as long as you do have read access), in the amazing Ultimate vimrc by ...
8
votes
3answers
386 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/...