ctrl-z
is the short cut for bg
,what's for fg
?
Anyone knows this?
crtl+z sends the suspend signal (SIGTSTP). It doesn't place the process in the background.
bg
while in vim
,so I want another short cut to go back to vim instead of typing fg
..
bg
runs the job, but stdin and stdout are no longer attached to the console. fg
attaches a background or suspended job to the console again.
Terminal->Preferences->Keyboard
.
You can define your own in $HOME/.inputrc...
# ALT+Z
"\M-z": "fg\n"
...or by adding bind -x
's to your .profile/.bashrc.
bind -x '"\M-z"':"fg" # ALT+Z
For more information, see the READLINE section of the bash manpage.
. .bashrc
or . .profile
; or pressing CTRL+x CTRL+r
for .inputrc
if default keybindings haven't been changed) If so, do you get any errors?
The goal is, I suppose, to exit vim
, do some shell stuff and reenter vim
as fast as possible. I got quite fast by using crtl+z to exit vim
and crtl+z again to reenter.
Exit works well without further ado.
To make the reentry work I undefed the standard crtl+z behaviour (susp
) and mapped it to fg
followed by the Enter key (\015
).
These are the relevant lines from my .bashrc
.
stty susp undef
bind '"\C-z":"fg\015"'
Works like a charm on OS X 10.10 and Ubuntu Linux 12.04 LTS. Probably should work on other Unices, too.
See also this Github Repo for a nice looking solution using iTerm2 and these vim productivity hints for a native zsh
implementation (hint VII) and other general awesomeness.
:!
. It's just better suited to one off commands and not for longer sessions in the shell. Of course, one could also use a tmux
split and a vim
session side by side...
Jul 14, 2015 at 18:55
bind -x '"\C-a":"fg"'
and this works great. ctrl-a is now 'anti-ctrl-z', so I can quickly switch between terminal and vim, and only one arrow up to repeat last command to test the updated script or code.
Oct 2, 2015 at 8:29