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.
126
questions
0
votes
1
answer
63
views
Can't use `:wqa` with open terminal buffers
I have next problem: When I use :term buffers the :wqa command produces error:
Which is quite expected because terminal buffers isn't writable. BUT the :wa and :q separatly work.
This is strange.
To ...
0
votes
1
answer
302
views
Prevent message when writing buffer
Whenever I write a file in Neovim, I get a message like this:
"config/nvim/lua/config/keymaps.lua" 55L, 2256B
Sometimes, this can cause a press ENTER or type command to continue message to ...
2
votes
2
answers
478
views
"Update" all of the unsaved buffers at vim
Is there a counterpart for the wall command at vim. I currently have an event handler for focus lost, so as whenever i switch to another window, vim would automatically write all of the buffers ...
5
votes
2
answers
1k
views
How to force quit if input was stdin?
I have
q mapped to :qenter
Q mapped to <esc>:qa!enter
which means
quit, unless something needs to be saved
just quit
My meanings for these keys clashes with vim's idea that stdin needs to be ...
0
votes
1
answer
33
views
How do I create key mappings for Windows and/or nano Shortcuts?
Having used text editors (mainly Notepad/++) and some IDEs on MS Windows, I've become familiar with their Alt and Ctrl shortcuts to the point that I use them automatically. Having used nano on a GNU/...
18
votes
3
answers
8k
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.
0
votes
0
answers
37
views
Neovim tries to run vale through a Autocommand
Whenever I save a .txt file it I get the error:
Error detected while processing BufWritePost Autocommands for "*":
Error running vale: ENOENT: no such file or directory
I have tried using :...
1
vote
1
answer
57
views
How can I edit a file in real-time?
I would like to edit a file using Neovim and have changes saved in real-time (changes should be written to the file as I am typing), which will be displayed by an OBS plugin. Is this possible?
59
votes
7
answers
25k
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 ...
6
votes
3
answers
1k
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 ...
11
votes
2
answers
6k
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 ...
0
votes
1
answer
67
views
How can I make Vim ssd friendlier?
When I append a line to an existing file with Vim,
Vim will unlink that file and create a new one on :w,
although that is unnecessary.
Vim even does the same with ~/.viminfo every time...
I found it ...
0
votes
2
answers
54
views
:updateall command to update all files
There's a :w and a :wall command but there's only an update command, there isn't a :updateall command.
Why isn't there one and how would you implement it in vimscript and lua ?
0
votes
0
answers
74
views
Neovim deleting lines on write
Something really odd is happening randomly when I save changes to a file in Neovim.
Often if I press esc:wEnter quickly, hundreds of lines are deleted from the end of the file. So far I have only seen ...
1
vote
2
answers
46
views
Make ":w" command throw an error on filenames starting with a colon ":"
From time to time I accidentally create files with names like ":w" or ":q". This happens when instead of writing :wq I type :w:q and sometimes, for some reason, even :w:w or :w :w. ...
0
votes
1
answer
126
views
Auto update a buffer opend in a split when it changed?
I'm writing TypeScript and there is a command npx tsc --watch that will (over)write to an output file every time the source file is changed. I open one split for each of these files. But when I save ...
66
votes
2
answers
56k
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 ...
13
votes
4
answers
11k
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 ...
1
vote
1
answer
681
views
Lost my small project, can I get it back?
I am a new vim user and currently using neovim on Linux. I my whole project which I had written in one file (only 1 day of work).
There are two ways I could've lost it:
I saved the file but ...
45
votes
10
answers
20k
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
3
answers
356
views
How to save a file for which I have no write permissions on Windows
I would like to edit files like C:\Widows\System32\Drivers\etc\hosts that need administrative privilege to be modified.
How can save the file on Windows if Vim has not been starter with administrator ...
4
votes
1
answer
256
views
How to explain ++opt in :[range]w[rite] [++opt] !{cmd}?
Get manual with help:
help :w_c:
:[range]w[rite] [++opt] !{cmd}
Execute {cmd} with [range] lines as standard input
(note the space in front of the '!'). {cmd} is
...
-1
votes
1
answer
62
views
how to disable the new popup file-picker on :w
If I try to write a file under a new name, instead of being able to edit an existing name provided by file-completion, I get a pop-up that only lets me select an existing one.
I saw a description of ...
0
votes
1
answer
92
views
Are there quicker methods for Closing Files?
In nano, I like that I can just hit ctrl x to exit a file I'm editing without saving it. I also like that I can type ctrl o to save a file.
I've completed the vim trainer and am trying to like vim. ...
0
votes
0
answers
37
views
Cursor get stuck at the statusline bar when saving a .tex file (probably due to vimtex)
To preface this, I'm relatively new to vim, and I'm using Windows Subsytsem for Linux, and the Windows Terminal if this makes any difference.
So whenever I'm editing a .tex file and want to save, ...
0
votes
2
answers
139
views
Running shell command (Rmarkdown::render) every save
I am trying to autogenerate an output every time I save the file with :update or with :w. This is what I got so far:
augroup renderRmd | au!
autocmd BufWritePost *.rmd !'Rscript -e "rmarkdown:...
18
votes
3
answers
6k
views
How can I copy the current file and start editing the copy instead of the current file?
Say I'm editing file foo. I want to copy/write what I have in the buffer to bar and change the buffer to be editing bar instead of foo. I can achieve this with:
:w bar
:e bar
But that has a few ...
20
votes
3
answers
7k
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 ...
9
votes
4
answers
7k
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 ...
5
votes
2
answers
1k
views
Is there a way to write a file and skip the autocmd on write?
My .vimrc has,
autocmd FileType rust autocmd BufWritePre <buffer> call LanguageClient#textDocument_formatting_sync()
This works great, unless my LanguageClient crashes. Then I can't write the ...
0
votes
0
answers
82
views
Why isn't vim recovering the most recent save
I'm having some graphical issues with my setup that means I sometimes need to restart my machine having not saved a file which is currently being edited in vim. However, the saved file which vim ...
0
votes
0
answers
155
views
Auto-save file on keypress
How can I automatically :w save a file after each keypress?
Devs who have used editors like PHPStorm know this is particularly handy so I was looking for a way to achieve the same with vim.
0
votes
0
answers
51
views
nvi: how to define a new command to write using sudo
In Vim, I can define the following command for writing a file using sudo:
command! W :execute ':silent w !sudo tee % > /dev/null' | :edit!
How do I define a similar command in nvi for saving using ...
2
votes
1
answer
121
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, ...
25
votes
4
answers
17k
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
1
answer
588
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 ...
1
vote
1
answer
1k
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
0
answers
57
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
1
answer
920
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
1
answer
209
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 ...
71
votes
6
answers
106k
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.
2
votes
2
answers
372
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?
6
votes
2
answers
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 ...
5
votes
1
answer
555
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
2
answers
70
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.
1
vote
0
answers
63
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 (...
8
votes
3
answers
2k
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 ...
3
votes
1
answer
103
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
1
answer
369
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 ...
1
vote
1
answer
349
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
...