4 ms·
Slightly relevant: if you find yourself in vim and don't have tmux/are too lazy to open another SSH connection, you can use ":sh" to drop to a shell. So for th
by emilburzo 10y ago
Slightly relevant: if you find yourself in vim and don't have tmux/are too lazy to open another SSH connection, you can use ":sh" to drop to a shell.
So for the nginx edit conf/restart server scenario you would:
# vim /etc/nginx/nginx.conf
<make changes>
:sh # drop to a shell
# nginx -t # check config, let's assume it failed due to a missing "}"
# exit # go back to vim
<make changes>
:sh
# nginx -t && nginx -s reload # config check passed
# exit # back to vim
:q # exit vim
#
- rz2k 10y agoCtrl-z will send Vim to the background (though you probably can't be in insert mode). `fg` in the shell will then bring the Vim session back to the foreground. If `:sh` doesn't give you your command history and the same working directory, that might be convenient.