1

I start up vim using the following command: vim -u NONE -U NONE -c ':set columns=40 nu'

enter image description here

Then, I push vim to the foreground...

enter image description here

...and return.

For some reason, VIM has changed the columns variable to the width of the window without me telling it to do that.

Note that I did not manually resize the window after Ctrl+Z.

The reason that I tried to change the :columns value was to change the width of the VIM editor. If the :columns variable is not the right solution, could you provide some better ideas for changing the width?

  • is there a reason, why you did set columns to an obviously wrong value? – Christian Brabandt Jun 15 '17 at 8:34
  • When? After returning to foreground? Vim set it to 69 automatically somehow – robert Jun 15 '17 at 16:31
  • Yes and this is probably the correct terminal size. So let me ask you again, why do you need tell vim a different terminal size? This is going to cause subtle strange behaviour – Christian Brabandt Jun 15 '17 at 18:41
  • 1
    This seems like an XY problem ;-) – Martin Tournoij Jun 16 '17 at 3:44
  • 1
    @Carpetsmoker is correct. You probably want to check out the 'textwidth' option – Christian Brabandt Jun 16 '17 at 5:41
0

:columns is an internal VIM property that is intended to be a mirror for the number of columns for the interactive shell environment that VIM is running under.

:columns should always match the result of tput cols (for bash). This means that VIM is able to automatically reflow the text on the screen when the terminal dimensions change. One such reflow event is triggered when VIM recovered from a "STOPPED" (ctrl+Z) state.

:columns is not the best way to set the width of text in the VIM editor. In most GUI environments, simply resizing the VIM window is the best way

Recommendation

  • Windowed GUI environments: Simply click and drag the terminal to the desired size.
  • Plain console: (BASH) Run stty cols ${COLUMN_WIDTH} in the shell to set the number of columns for your terminal. This will change the dimensions of your shell, and VIM will automatically pick up the new dimensions.

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.