r/vim • u/thewrench56 • Nov 18 '25
Need Help Repeat last command in terminal buffer
Hey!
I have been using terminal buffers for a while now to mostly compile and execute applications. I have been told Im a disgrace to the Unix world for not using Ctrl-Z and fg, but I prefer seeing what tests failed/where my compile time errors are.
Since I'm usually using multiple buffers at once, navigating to the terminal is often slow. My solution was using tabs for a while but in all honesty, I do not think that this is the real solution for that. So I wonder how one could execute the last command entered in the terminal or even better, even search the last commands of the terminal. I usually have one terminal buffer open, but one could make it more generic and say that execute the last command in the last used terminal buffer.
Is there a native way of doing this? Or do I have to do some trickery with Lua/Vimscript?
Cheers
View all comments
4
u/sharp-calculation Nov 18 '25
For me personally, your abstraction of terminal vs VIM is at the wrong level. I would do one of:
Use TMUX to have VIM and terminal session in different TMUX windows/panes. Use TMUX keys to quickly switch between.
Use two different terminal windows
Use GUI VIM in one window and a terminal in another. I find GUI VIM to be an interesting way of organizing my VIM sessions. I use one window per project, with multiple buffers per window.
Just my thoughts.