I like to use the vim embedded terminal, but I do not know how I could adjust its height. Sometimes, I need it to be lower so that I could concentrate on my editor how could I adjust it ?
4 Answers
:h termwinsize
You need to set termwinsize
option. It's argument like {row}x{columns}. So if you want your terminal appear 30 row and 200 column, you should use:
:set termwinsize=30x200
-
The OP asked to change the terminal height only.
:help termwinsize
specifies that the format is written as "{rows}x{columns}" and that "when columns is zero then use the width of the window." For example to get a terminal buffer with 10 lines only, enter:set termwinsize=10x0
. Commented Jan 11, 2021 at 12:46 -
@PaulRougieux Does the
width
,height
of Neovim'svim.fn.jobstart
the same idea as you had described? Commented Feb 26, 2023 at 18:37 -
To open a terminal for running command
with height 20 you can do
:new +resize20 term://command
If the terminal is ready created, you either use :resize 20
or 20<c-w>_
for height. :vertical resize 20
or 20<c-w>|
for width.
There are several options:
(1) The simple way is to drag the bar separating the two split windows using the mouse. As far as I know this works by default, but I've only been using neovim, not standard vim so you may need to enable the mouse first.
(2) In normal mode, type 10<C-W>+
to increase the size of the current split by 10 lines. Or make a binding for this, e.g. nmap <Leader>b 10<C-W>+<CR>
(b for bigger; Leader is \
by default but should be rebound to space in my opinion)
(3) A more automatic solution to the problem of the current split being too small is to add this to your vimrc:
set winheight=38
This will make the currently active window 38 lines tall, with the terminal filling the remaining space. But when you switch to the terminal, this is swapped around so that you can see the command output better.
-
It does not work since the height of the upper window may affect the terminal height. Commented Sep 13, 2018 at 11:54
-
which of the options does not work, and what unexpected result do you get? Commented Sep 13, 2018 at 12:50
-
1You can also use the
++rows
option to specify height, e.g.:terminal ++rows=10
. See:h :terminal
Commented Sep 13, 2018 at 14:33 -
Note if you are considering option 3, perhaps vim-maximizer bound to \ is a better option. Commented Oct 5, 2021 at 8:09
-
With winheight set, is there a way to set the unfocused window default height? I would like my terminal to be there with a height of, say, 1 row. Commented Dec 9, 2021 at 11:07
To enforce a default height when running a vanilla :term
ex command, you can add the following to your vimrc:
autocmd TerminalWinOpen *
\ if &buftype == 'terminal' |
\ resize 10 |
\ setlocal termwinsize=0x140 |
\ setlocal nowrap |
\ endif
The other setlocal
commands are optional, but helpful to make sure the terminal doesn't wrap.
:h window-resize
<Ctrl-W> N
to enter terminal-normal mode. Then use the standard window-resizing commands to change the window. e.g.10<Ctrl-W>_
or:res 10
. Then pressi
ora
to get back into regular terminal mode.