So right now I've got ctrl-E mapped to "edit" the current line in my prompt via neovim. So if I've got a line like

$ cp -r path/with/typo a/really/really/really/long/path/name

then I can press ^e, edit out the typo, exit neovim, and run the fixed command.

This is great, except (and I'll admit this is a nitpick) I don't really like that neovim takes up the whole screen. Sometimes the edit I'll want to make is based off of the output of a previous command, in which case it's a bit annoying that the full-screen neovim obscures this information.

For example, if I had the terminal history looking like:

$ cat requirements.txt
$ cat .venv/lib/python3.10/site-packages/absl/__init__.py

But then I realised that instead of cat-ing the absl library, I wanted to cat a different library that was in the output of the first command cat requirements.txt . Maybe the spelling of that command is weird. Right now I could edit the second command with a full-screen neovim window but I wouldn't be able to see the output of my previous command to check the spelling.

To clarify some things I'm not looking for:

  • I'm not interested in a solution that somehow copies the history into the vim buffer.
  • I'm not interested in a solution that doesn't let me see the output of the previous commands.
  • I'm not interested in a solution that's offering some pseudo vim-mode for editing the current command with "vim-style" commands without actually opening vim.

Ideally the result should look like I've got a "mini-vim" (or neovim) instance that only takes up the lower 5 or so lines of the terminal, like:

-shell- $ cat requirements.txt
        $ cat .venv/lib/python3.10/site-packages/absl/__init__.py__init__.py
--vim-- 1   cat .venv/lib/python3.10/site-packages/**edits made here***/__init__.py
        /private/tmp/zshbASRss                                    1,55           All
-shell- $ cat .venv/lib/python3.10/site-packages/**edits made here***/__init__.py

(Where -shell- and --vim-- are just used to indicate which parts are shell and which parts are vim)

  • One way would be to set EDITOR to a custom script that opens vim in a tmux horizontal pane and waits for it to finish.
    – balki
    Oct 26, 2023 at 15:54
  • Hmm that's an option, although I'm often using zoomed/multi-pane tmux setups so I don't really look forward to figuring out how to make that work nicely. But good idea, definitely an option.
    – beyarkay
    Oct 28, 2023 at 16:12


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.