在 VIM 中查看终端历史记录

View terminal history in VIM

有没有办法在 VIM 中查看和/或搜索终端历史记录?

试过 :! history 但没有显示任何内容。

Is there a way to see and or search the terminal history in VIM?

是的,您可以执行以下任一操作:

  • <C-z>暂停Vim,$ history查看历史,$ fg返回Vim。
  • :shell,然后$ history
  • :terminal history:terminal,然后 $ history
  • :!bash,然后$ history

默认情况下,:!<cmd> 执行 <cmd> 就像它被传递给 -c 标志一样,因此 :!history 等同于在您的 shell: 没有历史。

你可以做到

:new |r !history

这将拆分您的 window 并将 !history 的输出通过管道传输到新的 window。