Questions tagged [quit]

Use this tag for questions about exiting vim.

Filter by
Sorted by
Tagged with
0 votes
0 answers
31 views

How can I stop Vim from quitting when the last buffer is a `:help` buffer?

I think there is an option that governs this behavior, but I cannot find it.
Futarimiti's user avatar
0 votes
0 answers
17 views

Is there a way to mark all buffers as "visited"? [duplicate]

I recognize that this is a very minor problem, but I thought I'd ask anyway. I mainly use Neovim, but to keep things simple, I'm going to be referring to and testing with vanilla Vim 9.0. The "...
Display name's user avatar
0 votes
1 answer
44 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 ...
Vladyslav Rehan's user avatar
-1 votes
2 answers
47 views

Prevent <c-w>q to quit Vim when there is only one window left

I wish to close windows and wipe out the associated buffers with <c-w>q but at the same time I want to prevent to quit Vim when there is only one window left. My attempt is as follows: ...
Barzi2001's user avatar
  • 440
1 vote
1 answer
76 views

Lowercase user-commands?

After years of torture, my trusty rusty keyboard is finally waning its power—it now seems to believe that I'm jitter-clicking whenever I press q. Before getting a new one, I would like to ask if there ...
Futarimiti's user avatar
0 votes
3 answers
37 views

Prevent: 'are you sure' popup on exit when closing the gVim window

Is there a setting that will allow you to just close the window without bothering with the save changes dialog when you exit? Do you have to attach it to an event that answers for you?
leeand00's user avatar
  • 3,437
0 votes
0 answers
119 views

Why do `wq!` and `q!` causing "E855 Autocommands caused command to abort" on any Python files?

Executing :q! and :wq! (of course :x as well) on any Python files causing "E855: Autocommands caused command to abort". However, :qa , :wqa (and of course :xa as well) don't caused the same ...
raisa_'s user avatar
  • 101
2 votes
1 answer
137 views

How to cancel quitting in a QuitPre autocmd

I want to write an autocmd that prompts the user when the user tries to quit Vim. Based on the user's response, Vim should either quit, or cancel the quit. Is this possible using QuitPre? If not, how ...
Flux's user avatar
  • 991
5 votes
1 answer
2k views

How do I quit vi/Vim/NeoVim?

I opened vi myfile.txt (or vim myfile.txt, or nvim myfile.txt) to use vi/Vim/NeoVim to edit a file. Now that it is open, how do I quit? If I open vim with no file, the intro screen says :type :q<...
0 votes
0 answers
382 views

Detect how vim was quit in autocommand

I have an autocommand on ExitPre like this: autocmd ExitPre * call PromptSaveSession() I'd like to avoid prompting to save the session if vim was forcefully exited, e.g. ':q!' or ':qa!'. Is there a ...
Big McLargeHuge's user avatar
1 vote
4 answers
495 views

Vim: how to make :q shut up about unvisited files?

When Vim is invoked on multiple files from the command line, then if any of those files have not been visited with :next or via buffer switching, the :q command pointlessly warns about the situation ...
Kaz's user avatar
  • 481
11 votes
1 answer
2k views

Why is it not possible to kill Vim using the TERM signal from inside Vim itself?

Out of curiosity, I tried to kill Vim from inside vim --clean. I tried: :!kill $PPID :call system('kill ' . getpid()) However, nothing happens after running the commands above. The commands give no ...
Flux's user avatar
  • 991
2 votes
0 answers
1k views

Strange error when closing Vim

I'm victim of a witchcraft. Likely my own. There's no Vim session open, based on the empty output of pidof vim and can open a new or existing file just fine. When I quit it with :q, however, I see to ...
Enlico's user avatar
  • 2,162
3 votes
1 answer
64 views

Which highlight group is responsible for the confirmation dialog?

If I have set confirm, Vim will show a confirmation dialog if I attempt to quit Vim when there are unsaved changes: Which highlight group is responsible for the colors of the text in the confirmation ...
Flux's user avatar
  • 991
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 ...
Cyker's user avatar
  • 177
2 votes
2 answers
246 views

Buffer scope variable not exists when run autocmd BufUnload

Describe the issue I use a vim plugin that when use Vim to open a ipynb (python notebook) file, will call system function to use jupytext create corresponding python file to enable use like, YCM to ...
roachsinai's user avatar
5 votes
1 answer
2k views

Job still running in buffer while :qa

I'm using vim 8 with some plugins and shortcuts. I set a shortcut for :term to open a terminal in vim: nnoremap <F5> :wa<CR> \| :term<CR> command Q qa So when I type F5, a ...
Yves's user avatar
  • 963
7 votes
2 answers
2k views

How can I ensure Vim doesn't quit entirely when the last window is closed, unless it's empty?

I'd like to mimic the behaviour of i.e. TextMate and VScode and friends, in a GUI-vim: "closing" the last actual-content-window simply leaves me with an empty Vim window, and then "closing" that is ...
ELLIOTTCABLE's user avatar
0 votes
1 answer
141 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 ...
Luke Davis's user avatar
  • 1,377
2 votes
2 answers
1k views

closing :terminal / term_start() should quit vim if it's the last buffer

Situation: I've typed this: vim foo.js :terminal Now I have one split, a file editing buffer and a terminal. The good: I can quit by closing the terminal first, then the file buffer. The bad: But ...
JasonWoof's user avatar
  • 293
2 votes
0 answers
231 views

:q will not let me exit vim [closed]

When using nvi I have a file that I want to exit but everytime I use :q it just opens this thing and I can't exit out of it. Does anyone know what it is and how to get rid of it? Note: this is nvi ...
smmr's user avatar
  • 21
4 votes
2 answers
166 views

What is this strange area, and how do I exit out of it

Seems to be related to this question What is the '[Command Line]' that sometimes comes up when I try to quit, and how can I quickly exit it?, but the solution doesn't work for me. I pressed ...
Samaursa's user avatar
  • 171
3 votes
2 answers
7k views

I'm stuck in Vim; I see "Command Line" at the bottom and nothing makes Vim respond

I pressed :wq to write and quit. Except now I see a Command Line at the bottom and nothing I do makes vi respond (Enter, Esc, Ctrl+c, :, q, etc.). How do I get back to civilisation from here? If you ...
CJ Dennis's user avatar
  • 139
4 votes
2 answers
263 views

Quit subsequent files opened with gvim *.c?

If I use gvim *.c in a directory with multiple C files, gvim opens the next one once I close the one I am looking at. The warning message given is E173: n more files to edit. How do I quit all ...
Vikash's user avatar
  • 41
8 votes
2 answers
2k views

Any way to retrieve lost undo tree after closing window (but buffer is still open)

A lot of times, I end up accidentally closing a file with :wq when I only want to do :w. Since I work with multiple tabs and windows, the buffer is still there and I can open it with :ls followed by :...
cauthon14's user avatar
  • 183
2 votes
1 answer
1k views

How to exit Vim, without saving changes using the shortcut Ctrl-Q?

I have tried several things to set the keybinding Ctrl+Q to exit Vim without saving any changes (i.e., what is normally bound to :qa!). I have tried adding: inoremap <C-q> <esc>:qa!<cr&...
Josh Pinto's user avatar
8 votes
1 answer
421 views

vim ZZ lost output with autocommand

I want to check file before quitinq vim with custom functions, everything seems fine with QuitPre autocommand except using ZZ to exit. In this case the output is missing. Consider following function ...
mrajner's user avatar
  • 213
2 votes
3 answers
609 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 ...
Anon's user avatar
  • 855
5 votes
2 answers
714 views

How to detect whether Vim has been invoked by another shell command?

I would like to modify the behavior of one of my mapping but only when Vim is reading data which were piped to it by $ vipe. The mapping closes/quits the current window/session depending on certain ...
user9433424's user avatar
  • 6,118
2 votes
1 answer
3k views

mapping to quit using "<Ctrl> + q" not coming into effect [duplicate]

I am trying to map Ctrl + q to quit editing the file. I added the below line to my .vimrc nnoremap <C-q> :execute "q"<CR> On pressing the above key combination, nothing happens, vim ...
mtk's user avatar
  • 233
20 votes
3 answers
15k views

Cannot exit Vim even using q!

I cannot exit vim even when I type :q!. I get the error E37: No write since last change (add ! to override) E162: No write since last change for buffer... I think the buffer is a NetrwTreeListing ...
Tyler Durden's user avatar
  • 2,051
1 vote
2 answers
258 views

Why do I need to use q! after `find ... | vim -`, i.e., reading from stdin?

I do find $HOME -type f -name "*.tex" -exec grep -il "$1" {} + | vim - I cannot exit vim with q only because it gives the error which I do not understand why E37: No write since last change (add ! ...
Léo Léopold Hertz 준영's user avatar
4 votes
1 answer
194 views

Swap choices: how can I "skip" instead of "quit" or "abort"?

Swap file ".file.swp" already exists! [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: I usually see this message when I accidentally :edit the wrong file, i.e., one which I'm already ...
Zilk's user avatar
  • 205
7 votes
1 answer
2k views

How to safely quit vim if there's some unsaved changes?

If I have changed a bunch of files but without saving and maybe I have another pile of noname buffers which are changed and without a file name. I want vim to prompt confirmation for each one of the ...
Aaron Shen's user avatar
  • 2,479
66 votes
2 answers
55k 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 ...
wefwefa3's user avatar
  • 1,143
4 votes
1 answer
388 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 ...
trysis's user avatar
  • 149
30 votes
5 answers
15k views

How do I close Vim externally?

Let's say I have a X11 server that's hanging, keeping me from saving the work from the XTerm Vim session that X11 server controls. (Not GVim, just regular Vim-in-XTerm.) Is there a way that I could (...
DevSolar's user avatar
  • 789
1 vote
2 answers
81 views

Don't close regular + help window at once, reset a variable on keypress

I have this function and mapping: fun! TwiceToQuit() sil! q if v:errmsg == 'E37: No write since last change (add ! to override)' echohl ErrorMsg echo 'No write since last ...
MichalH's user avatar
  • 265
4 votes
3 answers
2k views

How do I avoid exiting vim to open a new file?

I usually exit vim to open other files, I know it is not productive and I want to avoid it. I want to use netrw instead to open the files I want. Is there any way to prevent me from exiting vim, using ...
bhathiya-perera's user avatar
3 votes
3 answers
393 views

Exit when only one empty window remains

I'm using a script to load files in vim remotely into one gvim instance per desktop viewport. It works fine, except that it causes an empty additional window, that will remain after closing all others,...
Volker Siegel's user avatar
31 votes
2 answers
5k views

What's the difference between "quit" and "abort"?

When I try to open a file from multiple vim instances, I get an error with several options: Swap file "~/.vim/tmp/file.swp" already exists! [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:...
Kevin's user avatar
  • 611
20 votes
2 answers
7k views

How to exit Vim from split mode?

How to efficiently exit Vim when editing multiple files in the split mode at one go? It seems when I'm having e.g. 10 split windows, I've to repeat 10 times :q! command for each window which is a bit ...
kenorb's user avatar
  • 18k
24 votes
2 answers
8k views

Prevent Vim from clearing the terminal after exit

If I do: $ less file And press q to exit less, I stil see the same text as I had on the screen when less was still running. However, if I do $ vim file And :q, my terminal is blanked... ...
Martin Tournoij's user avatar
40 votes
5 answers
5k views

Terminal borked after invoking Vim with xargs

I've sometimes tried invoking Vim using xargs, like this: find . -name '*.java' | xargs vim … which kind of works: As Vim launches, I see the following warning flash briefly: Vim: Warning: Input ...
200_success's user avatar
  • 9,339