I wanted a way to easily toggle a single terminal that would keep the same size and content.
My solution lies in two functions: the main one controls whether a terminal should be opened, the second opens a terminal split where we want on the screen.
If one or more terminal splits exist, they are hidden. Else, a terminal split is opened, either a new one or ...
This question is a couple of years old now but I found it when I was looking for a way to open a terminal inside vim below a bunch of vertical splits. What I want looks something like this:
¦ ¦ ¦ ¦
¦ f1 ¦ f2 ¦ f3 ¦
¦ terminal ¦
What you get with :below terminal or with :set splitbelow and then :...
You could use substitute() on the contents of the register to make a replacement, and use a :let command to assign it back to the clipboard register.
For example, start by copying it to the default register in step 4, with y (instead of "+y.)
And then use the :let command to apply a substitute() on the contents of the default register and assign that to ...
To enter vim command-mode from a terminal buffer, you can use: <c-\>n.
Then, you will be able to use regular vim commands as in any buffer.
Thus, : lets you enter vim command-line and i switches back to terminal input as you'd expect.
Terminal buffer is special:
When the job has finished and no changes were made to the buffer: closing the
window will wipe out the buffer.
Change buffer type will stop this.
After job finished, clear buffer type:
This also works:
" make any change, the 1st change will convert terminal buffer to be a normal ...
I was looking for a robust way to toggle a terminal and ended up building something that meets my expectations.
Off: any visible terminal is hidden
On: terminal as a bottom panel (restore first hidden terminal or create new one)
Works with already open terminal
Arguments: size and side of the terminal, defaults to 6 lines at the bottom
It seems pretty ...