Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In an effort to get more lines of text on the screen in widescreen monitors1 I have tried decreasing the font size. I find that I can get enough2 lines of text at font size 8px or 10px, but I prefer to code in 14px! My preferred environment is VIM, and I know that GVIM can specify different font sizes.

Is it possible for the current and ±3 lines to be 14px, up to 6 lines away to be 12px, and the rest to be 10px? I would prefer this setup in GVIM, but I would like to try it in any (Linux) editor that might support this feature.

1Yes, I have tried running the monitor sideways, but in my current setup I cannot do that.

2There is never enough!

share|improve this question

2 Answers 2

up vote 2 down vote accepted

The vim :highlight command can be used together with the match and autocmd commands to change the near lines. As follows:

:highlight CurrentLines gui=bold
:autocmd CursorMoved * :execute 'match CurrentLines /.*\n.*\%#.*\n.*/'
:autocmd CursorMovedI * :execute 'match CurrentLines /.*\n.*\%#.*\n.*/'

First we define a new highlight group with the desired format, than we define an auto action for the CursorMoved event (both for the command and for the insert mode) that match the highligh to the current line and it's neighbors.
The match pattern cant be adjusted to include more or less text as required.

The problem: the :highligh command have a GUI argument for setting the font, but for me (gvim 2.7 on Ubunt) it seems that gvim ignores the font setting.

There is a stackoverflow.com answer that deals with a simillar issue and might be of help for you http://stackoverflow.com/questions/6127845/dynamic-vim-font-size-based-on-file-length

share|improve this answer
    
Thanks, this is great. I think that it is close to working. When I use this highlight :highlight CurrentLines gui=bold I get this error E423: Illegal argument: guifont=DejaVu\ Sans\ Mono\ 16. However when I use this highlight :highlight CurrentLines font=DejaVu\ Sans\ Mono\ 16 I get this error E416: missing equal sign: Sans\ Mono\ 16. That last one looks a bit more promising. –  dotancohen Aug 13 '12 at 16:04
    
The argument guifont is indeed illegal for the highlight command. gvim considers the font size number you've added as a following argument key, this is why you get the missing equal sign error. Try removing the number. –  amotzg Aug 13 '12 at 16:07
    
Thanks. Using :highlight CurrentLines font=Monospace:h16 I don't get the error, but I don't get the font size changed. –  dotancohen Aug 13 '12 at 16:11
    
That comment was sent prematurely. I can try setting only the font, but it does not in fact change. –  dotancohen Aug 13 '12 at 16:13
    
I do notice that the fine documents state All fonts used, except for Menu and Tooltip, should be of the same character size as the default font! Otherwise redrawing problems will occur.. I suspect that changing the font size of an entire line would be alright, though. (and I'm happy to check) –  dotancohen Aug 13 '12 at 16:21

You can instruct GVim to use different fonts and sizes but it works like in CSS: the first definition that works is used and the rest is discarded. You can't have multiple font sizes and fonts displayed at the same time in Vim.

Use folding instead.

share|improve this answer
    
Thanks, romainl. Folding shows me less code, not more! –  dotancohen Aug 14 '12 at 8:49
    
You want to emphasize some parts of your code to the detriment of others. That's what folding is for. –  romainl Aug 14 '12 at 10:08
    
That is not my goal, romainl. My goal is to get more lines of text on the screen, yet keep the lines that I am working on at a comfortable size. –  dotancohen Aug 14 '12 at 10:11
    
This can't be achieved with Vim/GVim. Take a look at Scite, maybe, or IDEs like Eclipse. I've read a bunch of blog posts in the past about that kind of idea: mixed size/font/slant… it never seemed practical to me and AFAIK is not widely supported, if it is. –  romainl Aug 14 '12 at 10:45
    
Thank you. Scite looks nice, but I am not giving up my VIM keybindings! –  dotancohen Aug 14 '12 at 11:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.