Re:Ask HN: What is one Vim trick most people don't know?
by thedjinn on Friday June 29, 2018 @03:58AM
(#17423100)
Not really a trick of Vim itself, but when using Vim from the terminal I find ctrl-z very useful to background Vim, type in a few shell commands for git or whatever and then use "fg" to hop back into Vim.
[ Parent
| on HN ]
Re:Ask HN: What is one Vim trick most people don't know?
by hiyer on Friday June 29, 2018 @04:11AM
(#17423142)
vim 8 and neovim have pretty functional in-built terminals (:term). You can try that if you're using one of these.
Re:Ask HN: What is one Vim trick most people don't know?
by thedjinn on Friday June 29, 2018 @04:13AM
(#17423146)
That's more keystrokes. ;)
Re:Ask HN: What is one Vim trick most people don't know?
by sshine on Friday June 29, 2018 @06:40AM
(#17423691)
Not if you bind it to ^Z. ;)
Re:Ask HN: What is one Vim trick most people don't know?
by majewsky on Friday June 29, 2018 @06:55AM
(#17423736)
Well, you can't. The terminal translates Ctrl-Z into SIGTSTP before it even reaches vim. Alternative suggestion:
nmap gz :term zsh<CR>
Same number of keystrokes, and does not override any existing normal-mode command from what I can see.
Re:Ask HN: What is one Vim trick most people don't know?
by Pete_D on Friday June 29, 2018 @07:08AM
(#17423766)
:nnoremap <C-z> :term<Return>
works for me (tmux in urxvt).Ctrl-Z only gets converted to SIGTSTP if the terminal has ISIG set. For example, try `stty -isig; sleep 5` and try to suspend or interrupt the sleep command.
Re:Ask HN: What is one Vim trick most people don't know?
by vram22 on Friday June 29, 2018 @01:56PM
(#17426239)
Only a few more keystrokes is:
:sh ENTER
or for more control over which shell, or to run a shell with any arguments, or even to run any command w/ or w/o args:
:!bash
:!bash -o vi
:!bash some_script.sh
:!some_command some args
and after any of those, just press Ctrl-D or type exit ENTER to return to the vim session.
Very fast and easy to do. I use it all the time.