Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

1
vote
1answer
38 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
44 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
39 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 ...
2
votes
1answer
68 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 ...
4
votes
1answer
260 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
35 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
79 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
132 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
34 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
113 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
39 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
28 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
72 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
2answers
776 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
93 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
118 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 ...
0
votes
2answers
325 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 ...
7
votes
3answers
368 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 ...
4
votes
1answer
2k 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
489 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 ...
0
votes
0answers
20 views

Enabling warning on external file change in neovim [duplicate]

In Vim, the default behaviour is to warn when some external changes happened on the file currently edited. In Neovim, no similar message seems to arise by default. How do you turn that on explicitly?
2
votes
0answers
33 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
50 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
158 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
46 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 ...
0
votes
0answers
123 views

“E17: … is a directory” when saving buffers with ':wa'

I've got a bunch of buffers open, I use :e and :Ex to open more buffers. When I try to save everything I modified I normally do :wa. This worked on vim on ubuntu 14.04, but not on ubuntu 16.04 (vim 7....
1
vote
2answers
125 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 ...
1
vote
2answers
600 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
262 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
548 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
448 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 ...
5
votes
1answer
393 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 ...
2
votes
1answer
48 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
355 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
2k 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?
5
votes
1answer
279 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
600 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. ...
29
votes
2answers
13k 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
146 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 ...
6
votes
2answers
273 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/...
1
vote
1answer
105 views

How to mark a buffer as intentionally temporary (i.e. not to be saved)?

I wrote this line into my .vimrc today: nnoremap <leader>rtp :below new \| execute append(0, &runtimepath) \| s/,/\r/ <CR> to display my runtimepath in a new buffer with one path per ...
2
votes
1answer
439 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 ...
0
votes
1answer
295 views

Why is :w command so slow for a relatively small file? [closed]

I have a file with 30000 lines (3MB), when I use :w vim editor hangs for several seconds, but when I use pure vim/vi it takes only a moment to save the changes. Why do I get this effect? What could ...
5
votes
1answer
356 views

Why can't I execute write command on all buffers with :bufdo?

I have multiple buffers open, some currently visible, some not. I know I can write all of them with :wa. However, I am curious, why :bufdo w does not work. When I try it in a buffer with unsaved ...
1
vote
0answers
30 views

Keep buffer current without manual refresh? [duplicate]

Sometimes I'll edit a file I'm working on in another editor (don't ask) but it will be open in vim or vice versa. With vim I need to :e to force a refresh of the file. However in my other editors the ...
5
votes
2answers
380 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 ...
3
votes
1answer
629 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 ...
3
votes
0answers
39 views

How to create intermediate directories with :w automatically? [duplicate]

It happens that you want to save a file in a subdirectory that does not exist yet, as in :w ~/customers/one-met-today/note.txt when the directory one-met-today/ does not exist. In the shell, that ...
5
votes
1answer
336 views

Run bash command on writing a file with a particular extension?

I want to run a bash command on writing a .less file, saving it and generating the corresponding .css file with the same name and in the same directory. I do have the bash command which generates the ....
5
votes
2answers
550 views

How to write a file automatically after every change?

Something that helps in text editing and proofreading is that for Insert mode, I have set an IMAP: :imap zz ^[:w^M and when I type zz I return to command mode and also write the current buffer. This ...