9

I often program with lines no more than 80 characters long. I start with an 80-character-wide terminal, but sometimes due to a plugin runs or after creating a vsplit results in the editing area being less than 80 characters wide.

For example, :set number will take four columns from the editing area and use them for line numbers. After this, using :vertical resize, only changes the size relative to other splits, it doesn't widen the window.

Is there a way to keep the width of the editing area at a fixed width or to quickly resize the editing area or the window to a specified width?

3
  • 1
    set columns=90 will resize a gvim, but unfortunately that's the total width, not the width of the displayed text. So you'd have to use 84+ with numbers on.
    – derobert
    Feb 18, 2015 at 17:03
  • 1
    Are you talking about (internal) Vim-windows, or the Terminal itself, or both?
    – Runium
    Feb 18, 2015 at 18:18
  • I'm talking about both. If the Vim window needs to be larger than the terminal width, I'd like the terminal to expand. Perhaps this isn't possible within vim...
    – drs
    Feb 19, 2015 at 11:57

4 Answers 4

3

Take a look at the various window functions. For example ctrl-w = will set all splits to equal width. There are also methods to set the window to a certain width, increase/decrease width by N, always maintain equal width, etc... :help window-resize

0
2

Ctrl+W+ (n) >/<: For right/left
Ctrl+W+ (n) +/-: For up/down
where n = any number.

1

:vertical resize 80 will set your current vsplit to 80 characters wide

0

CTRL-W with pipe | will set the window to a specific width. E.g., to set the window to 80 columns/characters wide:

CTRL-W + 80 + |

From :help window-resize (~ @collin-peters):

Set current window width to N (default: widest possible)

2
  • 1
    I think typically you'd type 80 C-w |, but if the other way around works, too, that's great.
    – D. Ben Knoble
    Mar 5 at 15:03
  • Indeed, both work.
    – John
    Mar 8 at 0:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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