From e0b35d87d482a8b4e6f04febfb044b3739e0f432 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Thu, 1 Aug 2024 23:03:46 +0200 Subject: [PATCH] zsh: use a ZLE widget to save command line when opening nvim with ctrl-v --- config/zsh/.zshrc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/config/zsh/.zshrc b/config/zsh/.zshrc index a2f5464..da26029 100644 --- a/config/zsh/.zshrc +++ b/config/zsh/.zshrc @@ -194,6 +194,14 @@ fs_setup_zle() { zle accept-line } + # Open nvim, preserving the current command line. + zle -N fs_zle_open_nvim + fs_zle_open_nvim() { + zle push-line + BUFFER="nvim" + zle accept-line + } + autoload edit-command-line && zle -N edit-command-line # from zshcontrib ############################# @@ -211,7 +219,7 @@ fs_setup_zle() { # ^r history search using fzf # ^t paste file/directory using fzf bindkey -M viins '^u' kill-whole-line - bindkey -s '^v' '^unvim\r' + bindkey -M viins '^v' fs_zle_open_nvim bindkey -M viins '^x^e' edit-command-line bindkey -M viins '^y' yank