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
2
votes
1answer
19 views

Options readonly vs nowrite

Apologies if this is duplicate. I have searched and haven't found any related questions. What is the difference between the options readonly and nowrite? The reference manual says: readonly: If on, ...
0
votes
1answer
31 views

Automatically load & save folds of files - except for help files

My current solution to automatically load & save views of a file is the following: " automatically saves & loads folds when closing or opening a file set viewoptions-=options augroup ...
0
votes
1answer
39 views

Save all changed and unchanged buffers then exit

The command :wqa does not work with new files. For example, if you create some empty files and save them with :wqa, you will not find these files after you quit vim. They are not saved at all. The ...
2
votes
0answers
48 views

Why does Vim create ~ files? [duplicate]

Whenever I create a file, Vim also creates a .extension~ file. For example, when I create a main.cpp file, another one appears with main.cpp~. Is the .cpp~ file an older version of my .cpp file? Is ...
0
votes
1answer
30 views

How do I change the place where my vim files are stored?

Right now, all my vim files that I create are stored in C:\Users\dinosauce33 (My user). How do I change it so that all of my files that I create are stored in documents?
3
votes
1answer
120 views

Why is oldfiles not listing last edited file

I use vim in the following way: I open vim. Then I press i to start writing. Then I save the buffer and give the file a name by issuing the command :w some-file-name.txt Then I quit vim by :x Then ...
6
votes
2answers
1k views

Why can't I write to a file in the home directory?

I want to write to a file in the home directory, so I tried the following command: :call writefile(["foo"], "~/event.log", "a") But I got an error: E482: Can't create ...
4
votes
1answer
119 views

How can I write all named buffers?

I would like a command that saves every buffer that has a filename. :h :wall gives this: *:wa* *:wall* :wa[ll] Write all changed buffers. Buffers without a file ...
1
vote
0answers
19 views

Run `checktime` only if buffer contents are different to the file contents

Sometimes a checktime causes a prompt to reload, even if the reloading would not change the buffer. This can be demonstrated (neovim 0.5): Open file in vim1 (terminal 1) Open the same file in vim2 (...
1
vote
2answers
32 views

Print message if file is not written on :update

When I do :update, I'd like to print a message if the buffer was not written (because it wasn't changed). I get a message upon save, but would like a message if save didn't occur, also.
3
votes
1answer
77 views

0-length file from new :term buffer: vim -c “w! file”

I have a file mk.out that contains ANSI codes, which can be cleaned up by opening it in Vim and issuing: :term cat % " Interpret codes in new buffer :only " Close source buffer `mk.out`...
1
vote
1answer
61 views

Autosave and Nerdtree conflicts

I was trying to setup NeoVim to autosave each time a change is made. I used this command, which I wrote in ~/.config/nvim/init.vim: autocmd TextChanged, TextChangedI * silent write It works perfectly ...
0
votes
1answer
54 views

how to save current new buffer (opened with :new) to other location, outside of current working location

how to save current new buffer (opened with :new) to other location, outside of vim_data (which is default vim working location) my default vim working location in vimrc is set to ~/Desktop/vim_data ...
3
votes
1answer
79 views

Slow write/save speed for files on network

I noticed my VIM write/save file for a network path is quite slow. I found out VIM saves files with approximated speed of 20mbps (2.5MB/s). Network is 1Gb/s local area network so I believe the ...
1
vote
1answer
41 views

hex mode crashes after saving file

I have a a.out file from "hello world" in c: #include <stdio.h> #include <stdlib.h> int main(){ printf("hello world\n"); } Which I can see in hexdump (file a.out) ...
1
vote
1answer
69 views

How to make autowrite apply to :make but not to :buffer?

I have set autowrite so that :make automatically saved the file before running the build command. But now I'm increasingly using :buffer to switch between buffers, and have now noticed that it ...
3
votes
1answer
56 views

'endofline' option stays false after write operation

When one opens a file with an incomplete last line (File does not end with 0x0A / a new line character), the endofline option is set to false (:echo &endofline will print 0) and the [NOEOL] ...
7
votes
2answers
90 views

Possible to rename file and maintain undo?

Is there a way to rename/copy/move a file and maintain the vim persistent undo information? If I do :w new-file-name and then :e new-file-name I can't hit u to undo. Already at oldest change :-(
1
vote
1answer
222 views

How to properly hook an action on save in vim

I have a code linter (https://github.com/symplify/easy-coding-standard) that I can run manually from the command line, but which I'd like to run automatically in vim whenever I save a file that I've ...
3
votes
2answers
150 views

Vim not firing inotify events when writing file

Mentioned here as well: https://stackoverflow.com/questions/13312794/inotify-dont-treat-vim-editting-as-a-modification-event Really frustrating issue, how can I force vim to write the file? It ...
1
vote
1answer
80 views

BufLeave: Auto save split file not working

I usually keep *.in files open in split and edit them. I would like vim to autosave the *.in files whenever I switch between splits. Searching other answers I found BufLeave that suits my case. I ...
2
votes
2answers
209 views

How to save file with today's date?

I am trying to save a file with today's date as part of name. To save file, we can just do :w myFile. To get today's date, we can use strftime. Ex: :echo strftime("%F") " returns 2020-03-27. Now I ...
4
votes
1answer
230 views

Saving file from INSERT mode

I would like to save files without exiting the INSERT mode. Is it possible? How?
2
votes
1answer
145 views

Is there an autosave option for vi/nvi

My version is the following: :ve Version nvi-1.81.6nb5 (2009-08-11) The CSRG, University of California, Berkeley. Is it possible to save a file at regular intervals in vi/nvi? I know there is an "...
2
votes
0answers
44 views

How to profile save time

Sometimes it takes a really long time to save a file out. Saving the same file after various changes takes various amounts of time. It does not seem to be related to file size. I've disabled any ...
0
votes
1answer
59 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
244 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
152 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 ...
4
votes
1answer
1k 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?
0
votes
1answer
141 views

Write several files all of which have been changed since read

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
62 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
424 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
39 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
63 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
15 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
265 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
271 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
138 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
56 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
198 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
568 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 ...
8
votes
1answer
3k 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
2answers
120 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
167 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 ...
5
votes
1answer
1k 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
39 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
526 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
77 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
36 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 ...
5
votes
3answers
4k 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 ...