Search this site

Metadata

Articles

Projects

Presentations

Neat vim/screen trick.

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!

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.


0 responses to 'Neat vim/screen trick.'

Showing last 0 comments... (Click here to view all comments)


Leave a reply

You need javascript enabled to use this form. Anti-spam efforts ongoing. Also, if the comment doesn't show up, it's because the form expired. Go back and copy your comment, reload the form, and resubmit. Apologies if this is a hassle, I'm just playing with antispam methods right now. If this insists on not working, please email me about it.

Name (required)
E-mail (optional, if you want me to be able to email you back)
URL (also optional)
Comment: