0

This questions sounds ridicolous, but is there any (mental?!) aid for my struggle when resizing windows?

Since the earliest days of my vi/m usage, I have struggle shrinking windows in the correct direction.

Does any/~greybeard~one have an advice how to solve my misery?

EDIT: I associated the keys </> with "moving a window" - Instead, it is about increasing/decreasing its width. Therefore, the entire following text is useless and I got cured! Thankfully


Demands:

  • built-in solution.
  • keyboard only.
  • proven.
  • bigger window on the left.

Preamble: I find myself working on my integrated screen most of the time; 1377 x 768 px resolution. But I like to open reference splits. These occupy to much screen real-estate.

Problem: After switching focus to, or opening, a new vertical tab I need to resize my panes. Even with my default workflow, where I am opening my first split, I am messing up the direction about half of the times when resizing. This results in resizing the pane in the opposite direction. Then, I double the count, but fail again miserably, because now I am thinking about the direction.

Result:
1.: |   |   |
2.: |  |    |
3.: | |     |

Execution:

CTRL-W_v "I'm in the new split to the right

20 CTRL-W_> "please shrink the window by the amount of 20 colums

Now I want to fix this by doing the opposite, but I find myself again failing about half of the times: I just want to move the right pane 40 to the right ('>')

Why I'm stuck:

  • replacing the arrows with the addition/substraction operation does not result in the same behaviour.
  • on some days, I am archiving my desired result perfectly.
  • help does not suggest any hints about this behavior:
                        *CTRL-W_<*
CTRL-W <    Decrease current window width by N (default 1).

                        *CTRL-W_>*
CTRL-W >    Increase current window width by N (default 1).

:vert[ical] res[ize] [N]            *:vertical-resize* *CTRL-W_bar*
CTRL-W |    Set current window width to N (default: widest possible).

You can also resize a window by dragging a status line up or down with the
mouse.  Or by dragging a vertical separator line left or right.  This only
works if the version of Vim that is being used supports the mouse and the
'mouse' option has been set to enable it.

The option 'winheight' ('wh') is used to set the minimal window height of the
current window.  This option is used each time another window becomes the
current window.  If the option is '0', it is disabled.  Set 'winheight' to a
very large value, e.g., '9999', to make the current window always fill all
available space.  Set it to a reasonable value, e.g., '10', to make editing in
the current window comfortable.

The equivalent 'winwidth' ('wiw') option is used to set the minimal width of
the current window.

When the option 'equalalways' ('ea') is set, all the windows are automatically
made the same size after splitting or closing a window.  If you don't set this
option, splitting a window will reduce the size of the current window and
leave the other windows the same.  When closing a window, the extra lines are
given to the window above it.

The 'eadirection' option limits the direction in which the 'equalalways'
option is applied.  The default "both" resizes in both directions.  When the
value is "ver" only the heights of windows are equalized.  Use this when you
have manually resized a vertically split window and want to keep this width.
Likewise, "hor" causes only the widths of windows to be equalized.

The option 'cmdheight' ('ch') is used to set the height of the command-line.
If you are annoyed by the |hit-enter| prompt for long messages, set this
option to 2 or 3.

If there is only one window, resizing that window will also change the command
line height.  If there are several windows, resizing the current window will
also change the height of the window below it (and sometimes the window above
it).

The minimal height and width of a window is set with 'winminheight' and
'winminwidth'.  These are hard values, a window will never become smaller.

The thing is, I am using the </> always, when writing, correctly (history of learning on a typewriter, probably.).

<C-left> <C-right> (default) <M-left> <M-right> (terminal-multiplexer) are occupied.

I am using the arrow keys to navigate, but H J K L (uppercase only) to position windows.

Often I am using horizontal splits in the reference window..

I am using a keyboard layout, where < and > are mapped to the same key (</<ctrl-<)

6
  • 2
    Have you tried :[vertical] resize? It accepts relative numbers (so, -10, +10).
    – D. Ben Knoble
    Dec 14, 2021 at 21:56
  • @D.BenKnoble This is the thing I am desiring, but it requires some operator binding I have not done yet. If you could post an answer with a binding, I would happily accept it. Meanwhile, I am exploring these bindings. : ))
    – Tomes
    Dec 14, 2021 at 22:03
  • 2
    I very much appreciate your suggestion/help. This is my solution, which works as desired: nnoremap <C-w>< :<C-u>execute "vertical resize -" . v:count<CR> nnoremap <C-w>> :<C-u>execute "vertical resize +" . v:count<CR> I will wait a few days for an answer, before accepting my own. Gratefully,
    – Tomes
    Dec 14, 2021 at 22:52
  • 1
    @Tomes Uhhh... But isn't 20 CTRL-W < exactly the same as :vert resize -20? I wonder if these mappings aren't just replicating the actual default behavior of these keys... Isn't that the case?
    – filbranden
    Dec 15, 2021 at 1:04
  • 1
    @filbranden Actually, you are right. It behaves exactly the same for two or three windows. Thanks for pointing out. It appears that my brain did not associate the keys correctly. Instead of moving the window in the desired direction, I am aware that the commands are actually increasing/decreasing the window. Shame on Me.. Thanks for the input..
    – Tomes
    Dec 15, 2021 at 19:11

1 Answer 1

1

Thanks to D. Ben Knoble and filbranden I came to my desired solution! I very much appreciate your answer.

I associated the keys with the wrong action - Instead of "moving the window" to a direction, It does in fact increase/decrease the width of the window. So this was an error of the user entirely. Thanks for pointing out.

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.