I am new to Vim. I managed to use :terminal
and :vertical terminal
to have a terminal side by side with my code. This works great, I can move between my code and the terminals. However, how do I go back to the last command in terminal? For example, I can't just press "Up" on the keyboard while in terminal. For the standalone terminal application, this would bring up the previous command. This doesn't work on while in Vim's terminal. The error is
"cannot make changes, modifieable is off"
.
I noticed that there are two modes when you use Terminal in Vim. There's the usual command line in Linux, and the Vim mode where you can use hjkl to move and etc.
Is this why I cant press up to use previous command? Please let me know and thank you.
P/S: This is solved. I mapped the Esc key to exit Terminal Normal Mode to Terminal Vim Mode. There were replies below but for some reasons those got deleted. Anyway, yes we can press up to get to the last command. Just remember, that we have to be in Normal terminal mode and not Vim mode.
vim --clean
and see if the behavior persists; double check<C-w>:map
and<C-w>:tmap
while in terminal mode)? Do the arrow keys work for you outside of a:terminal
(if not, they may be sending commands to the terminal window like<esc>D
, which could fail)? Note that there is a way to put terminal windows in Normal mode, either by using++noclose
and stopping the process, or temporarily by sending<C-w>N
(called terminal normal mode)—could this be tripping you up?tmux
is what you need. Easy to switch between windows, zoom-in/out. All in all, just a delight to work with once you get a hang of the mappings.