Tip #488: vimrc setting for wider vim diff window (gVim)
tip karma |
Rating 15/9, Viewed by 1282
|
created: |
|
June 16, 2003 15:57 |
|
complexity: |
|
basic |
author: |
|
jaldri1 at gl dot umbc dot edu |
|
as of Vim: |
|
6.0 |
The Vim diff feature (fantastic as it is) opens with the default window width (gVim), and the two files each get a half width buffer windows with a vertical split between them. When you resize, only one buffer window changes. We might write function to automatically center the split and possibly trigger it automatically with an autocmd (advanced). However, we can still have Vim open with a wider window when performing a diff. The following code can be added to the vimrc file. Be sure to adjust the numbers for the available screen real-estate and the other settings to taste.
"===============================================================
" Window settings
set lines=60 " Set window height
set columns=98 " Set window width 'co'
set guioptions+=b " Add bottom scroll bar 'go'
" If comparing files side-by-side, then ...
if &diff;
" double the width up to a reasonable maximum
let &columns; = ((&columns;*2 > 172)? 172: &columns;*2)
endif
"===============================================================
Remember, the default for the columns setting is either 80 or the terminal width. I wouldn't expect consistant results for non-gVim usage. By the way, I still need to add a test to detect vim vs. gVim in my own vimrc (perhaps greping $VIM for gvim) so that I can adjust colors and other settings accordingly. Note that the expression in the let statement can be replaced with a constant. But, that expression may prove usefull if the columns setting is to vary (e.g. a filetype plugin). For a general function (intermediate), someone would want to come up with some global names like MaxScreenColumns or MaxBufferColumns.
<<jump to a file to a certain line number |
Section jump in Latex >>
Additional Notes
|