When running Vim in a Terminal, the vim window does not fill the entire screen space, which is very irritating when the terminal background color radically differs from vim's. Admittedly, one might want to keep them somewhat in sync, but given that I don't want that, how can I make vim stretch across the entire window?
The screenshot below illustrates the problem.
You have only two solutions:
give your terminal emulator's background and Vim's background the same color,
or remove Vim's background color.
Vim, your shell and every command-line program divide the screen in a grid of which every cell is the size of a character. If the GUI window's size in pixels doesn't fit your shell's grid size you get that ugly padding.
Example:
my cell size is 7x19 and my display is 1680x1050,
I can fit 240 columns and 55 lines but I will always have a 5 pixels padding at the bottom of the screen.
Additionally, most terminal emulators add a default padding around the usable screen to increase legibility so you will never be able to make Vim really full screen when run in a terminal emulator.
It looks like your terminal allows resizing in increments less than a single row/column.
Vim, on the other hand, draws only complete rows or columns. The partially visible rows/columns in the terminal are therefore not being drawn when Vim displays its window.
I've recently written a Medium article which could help solving this issue visually. Link.
One way to go about this is by triggering a change in your terminal's background color when Vim is running. This makes use of escape sequences and terminal colors, which might not be available in your terminal emulator.
change_terminal_background() {
local COLOR="$1"
if [ "$TERM" == "screen-256color" ]; then
# TMUX
echo -ne "\\ePtmux;\\e\\033]11;$COLOR\\007\\e\\\\"
else
# NOT TMUX
echo -ne "\\033]11;$COLOR\\007"
fi
}
Call it like this:
vim() {
# Change the terminal's color when Vim starts
change_terminal_background "#924560"
/usr/bin/vim "$#"
# Change it back when it exits
change_terminal_background "#000000"
}
You can use my plugin vim-pedant to automatically update iterm2's palette to match vim's colorscheme.
It's not that VIM isn't filling the screen; it is. What you're seeing is the help text. The help text is centered. Once you go into insert mode or run a command it goes away.
Ok so first off, this is NOT the answer I'm looking for:
autocmd VimResized * :wincmd =
Let me explain: Let's assume I have 2 vertically split windows, one at 30% size and one at 70% size. When I resize my window, I want that percentage to stay the same. Without this command, the split on the right slowly collapses so that you eventually can't see anything in the window. With the command above, once you start resizing the window, the window sizes immediately change to 50%/50%.
I work with a lot of splits (vertical and horizontal) and I don't want the command above to just make everything equal, but at the same time I do want them to resize, just PROPORTIONALLY to the window... I want the percentage height/width of all splits in the window to stay the same when the window is resized. Ideas?
I've attempted to implement this in my ProportionalResize plugin, following basically the approach outlined in romainl's answer. You can wrap your resize commands in a :ProportionalResize wrapper; the plugin also hooks into various events to allow automatic adaptation when the Vim window is resized e.g. with the mouse.
if you are asking a "vim - official" way to do that, answer is NO. (Vim 7.3)
to prove it:
open vim, type :h todo<Enter>then type /proportionally[Enter] you will see:
- When resizing the whole Vim window, the windows inside should be resized
proportionally (Webb).
so it is in vim's todo list. In this window type gg, you can see the leading minus "-" means Priority classification:
- unclassified
If you want to do it, you could write a function by yourself, on VimResized event, resize all windows based on your logic.
You could create a function that logs window sizes and bind them to a bunch of events like WinEnter/WinLeave and another one bound to VimResized that uses those values to resize the windows.
This doesn't sound like a trivial task.
Or even like a good idea.
In a single VIM window with 4 or 5 buffers for example, is it possible to give each buffer a different background shade?
Let's assume that the color theme is darkblue, I would like to make each buffer have a slightly different background shade of the dark blue.
No, the colorscheme settings are global.
You can do:
:hi ColorColumn guibg=#550000
and then color the background of selected windows with:
:setlocal colorcolumn=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256
Unfortunately this will only give you two shades (the one you set and the default), and colorcolumn's limit of 256 columns will break the illusion on very wide windows or long wrapped lines.
Thanks to blueyed for this tip.
I usually work fullscreen with Vim and Emacs on a 30" monitor which means I tend to have a lot of splits. The active pane's modeline changes background in Vim and Emacs, but sometimes that's not an easy to see indicator of the active pane.
Is there a way to change the background color of the active pane so I can easily, at a glance, see what split I'm currently in?
Either Vim or Emacs solution would be fine.
How about customizing the color of your active mode-line?
M-x customize-face RET mode-line
Change the background to "red" and the foreground to "white", and you won't be able to focus on anything else except you active buffer:)
Three years have passed since this question. There is a mode that permits to do this now, take a look at color-theme-buffer-local.
Vim is no different from Emacs in that the actual background color can't be changed within overall application window, all the "windows" in Vim must have same background. As dash-tom-bang says, though, the status line can be used to give some visual cue to which window is active. This is done by using the highlight command to set the StatusLine and StatusLineNC highlight groups to have different colors, active window will have status line with color of StatusLine highlight, and all other windows will have the 'No Cursor' StatusLineNC highlight.
There is also the txtfmt plugin, which (despite some misleading screenshots) doesn't really let you have different backgrounds, but it can be useful to give some added differentiating to windows, a little clunky by requiring you to add marker characters into your text: http://www.txtfmt.webs.com/
M-x package-install RET auto-dim-other-buffers RET.
"Visually makes non-current buffers less prominent"
Repo here: https://github.com/mina86/auto-dim-other-buffers.el
It's possible, and very easy to do so with this 'highlight-focus' package :
https://github.com/kriyative/highlight-focus
What I needed to do :
M-x package-install RET use-package RET.
Put the 'highlight-focus.el' in a folder emacs is looking.
If needed put something like this in your .emacs:
(add-to-list 'load-path "~/.emacs.d/folder_with_lisp_files/")
Then in my .emacs :
(use-package highlight-focus
:config
;; set the background of the mode-line
(setq highlight-focus:face 'mode-line
highlight-focus:face-property :background
highlight-focus:face-property-value "DarkMagenta")
;; set the background
(setq highlight-focus:face 'default
highlight-focus:face-property :background
highlight-focus:face-property-value "black")) ;; change color to desired value here
For Emacs, you cannot do this. You can change the background for a frame only.
See the related questions:
How can I change the background colour of a single emacs buffer?
Emacs custom background color by mode
One option could be to use a tiling window manager, and use a bunch of different Emacs frames. And then you can use the FrameMove package to easily move between the frames.
There are color schemes in Vim which make the status line really pop out. That's not exactly what you're looking for, but you may be able to make it work. Play with the built in colorschemes in a window with a lot of splits (and filetypes) and you can see the effects. I remember thinking that one in particular was god awful due to the change of the status line color, from inverse colors to something with bright yellow text in the active window. I hated it overall but one of these days will incorporate something like that into my own colorscheme.