Neat vim/screen trick.
Posted Thu, 07 Aug 2003
For some time I've been wanting to be able to pop open a small
split-pane in vim to run simple commands like, oh.. I don't know.. javac
and such. Just for temporary, quick shell access.
Tonight, as I was browsing through the screen manpage, I saw that screen allowed you to split the window into different regions. Using this and a quick vim key mapping, I was able to do it without much trouble!
Thanks to screen being smart, you don't have to specify what screen session to send these commands to, which made it 10000% easier, as we don't have to bother trying to figure out which screen session is running vim. You could optionally add a
Tonight, as I was browsing through the screen manpage, I saw that screen allowed you to split the window into different regions. Using this and a quick vim key mapping, I was able to do it without much trouble!
The vim keymapping:
map \s :silent !screen -X split<CR>:silent !screen -X focus down<CR>:silent !screen -X screen screener.sh<CR>:redraw!<CR>
Contents of screener.sh
$SHELL; screen -X remove
Thanks to screen being smart, you don't have to specify what screen session to send these commands to, which made it 10000% easier, as we don't have to bother trying to figure out which screen session is running vim. You could optionally add a
:!screen -X resize
>whatever< before the screener.sh :! execution
to resize the lower frame to a specific size. See the
screen manpage for more information
on how to use screen -X and the resize
command.
The results of hitting \s in vim can be found in the screenshot on the right. After logging out of that shell, the newly-split screen disappears and returns you to your original, full-screen vim.