8/8/2023 0 Comments Quit vim![]() When there are unsaved changes, it quits as expected. When there are unsaved changes, :q still fails, and :x fails if other buffers are unsaved.Ī curious behavior occurs with :q!, though all seems well nonetheless. When multiple files are being edited, and there are no changes, both :x and :q quit, as desired. Various experiments are confirming to me that it has the right behavior, and fixes :x also. When the QuitPre event is triggered on any buffer, we issue the qa command. Vim's :autocmd has useful hooks, one of which is QuitPre. Turns out, we can use :autocmd as a close facsimile. Ideally, Vim would have a command execution hook: a piece of code that could be executed each time a command is run, or at least an interactive command. The :cabbrev-answer has downsides because the abbreviation is active everywhere in the : command line, even if restricted to that type of command using the mechanism. ![]() The documentation does not seem to mention that if the command fails due to the last file not having been edited, simply repeating the command will then force it. The forced execution :q! will work, but is not acceptable because it will discard unsaved changes. when the last file in the argument list has not been edited". Which just confirms the behavior: "fails. See CTRL-W_q for quitting another window. Window in the current tab page the current tab page is If there are other tab pages and quitting the last ![]() The last file in the argument list has not been Vim refuses to abandon the current buffer, and when This fails when changes have been made and In the :help documentation, we have: :q Quit the current window. Is there a way to eliminate this behavior? 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 with a message like "43 files left to edit" and refuses to quit, even though nothing has been modified.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |