6d7c39a2aef023ac887f0cadbe0035706838c859

Author
Michele Bologna <michele.bologna@gmail.com>
Committer
Michele Bologna <michele.bologna@gmail.com>
Date

Message

Added fancy-ctrl-z plugin

Use Ctrl-Z to switch back to Vim
I frequently need to execute random command in my shell. To achieve it I pause
Vim by pressing Ctrl-z, type command and press fg<Enter> to switch back to Vim.

The fg part really hurts me. I just wanted to hit Ctrl-z once again to get back
to Vim.
I could not find a solution, so I developed one on my own that works wonderfully
with ZSH.

Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/

Diff

 1diff --git a/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh b/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..d4e41b71f5f74a46b94e227bbfb0cf29500c37dc
 4--- /dev/null
 5+++ b/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh
 6@@ -0,0 +1,21 @@
 7+# Use Ctrl-Z to switch back to Vim
 8+# I frequently need to execute random command in my shell. To achieve it I pause 
 9+# Vim by pressing Ctrl-z, type command and press fg<Enter> to switch back to Vim.
10+# The fg part really hurt sme. I just wanted to hit Ctrl-z once again to get back 
11+# to Vim. I could not find a solution, so I developed one on my own that 
12+# works wonderfully with ZSH
13+#
14+# Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/
15+
16+fancy-ctrl-z () {
17+  if [[ $#BUFFER -eq 0 ]]; then
18+    BUFFER="fg"
19+    zle accept-line
20+  else
21+    zle push-input
22+    zle clear-screen
23+  fi
24+}
25+zle -N fancy-ctrl-z
26+bindkey '^Z' fancy-ctrl-z
27+