I am trying to close the terminal window directly from vim.
The final purpose of this is to have a command (shortcut) that opens VSCode in the current directory from vim (when I need a GUI editor) and closes my terminal window.
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityI propose to:
Start vim using a script.
Launch VsCode using: On Windows I propose you to use:
:execute '!start code "%:p:h"' | cquit 2
or on Linux:
:execute '!code "%:p:h" &' | cquit 2
Detect the return code 2 in the script that launch vim to kill the parent terminal.
:!code .
to open VSCode but I need the terminal running vim to close after opening VSCode (or after executing any other command)
cquit
instead of qall
to quit vim and detect the return code in the script to kill the parent terminal.
Apr 18, 2022 at 5:33
:cquit
instead of :qall
. The first make vim returns a non zero code and the later a zero code that can be leveraged.
Apr 18, 2022 at 11:36
:exit
in the terminal prompt does not close your :terminal window?:!code
and skip the utilisation of the terminal.