Screenshot showing how the editor doesn't occupy full screen

When I use vi or vim to edit files in putty, it only shows a limited lines and columns. So how to extend the editor to full screen?


The problem is likely that the program does not know what the correct screensize is. Usually the system can get this information from the terminal program. But sometimes it cannot, or it is overridden.

Assuming that you are using some unix-like system, the stty command can show what the system thinks the screensize is, e.g.,

$ stty -a
speed 38400 baud; rows 40; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

The rows and columns values are what the system thinks the screensize is. If that is wrong, you can use stty to change them, e.g.,

stty rows 50 columns 132

but a better way is using resize (just by running it, it calls the same interface that stty reads).

However, stty may show correct values. Your environment may override its settings with the LINES and/or COLUMNS environment variables. (Those are longstanding legacy crutches for termcap applications). Just unsetting those variables fixes that problem.

Further reading:

  • Thanks Thomas! A simple resize perfectly solves my problem. – Terry Qiao Jan 25 '16 at 23:54
  • Was looking for this for past 5 years – PnotNP May 22 '19 at 22:19

Typing in terminal


will recalculate the rows and lines given by command

stty -a | grep columns 
speed 38400 baud; rows 55;columns 138; line = 0;

I had the same problem and after a while discovered I had lines and rows set (set lines=30 and set columns=80) in .vimrc file. Commenting them out (" starts inline comment in the vim-rc syntax) fixed the issue.

  • 1
    Can you explain in detail how to edit this file? Please see How to Answer and take our tour. – Burgi Jul 29 '16 at 7:56
  • that's VIM's configuration file. From VIM itself you can edit it by typing :e $MYVIMRC – user110954 Aug 1 '16 at 15:09

the best and easiest way of doing is create .vimrc file on your home directory then paste below content in file

set ai
set mouse=a
set incsearch
set confirm
set number
set ignorecase
set smartcase
set wildmenu
set wildmode=list:longest,full
set lines=80
set columns=80

Save the file and exit then reload the file on current shell

source .vimrc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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