blob: c16a793193e5bcb6bbf6063867de3ec955d950a8 [file] [log] [blame]
Bram Moolenaare4f25e42017-07-07 11:54:15 +02001*terminal.txt* For Vim version 8.0. Last change: 2017 Jul 04
2
3
4 VIM REFERENCE MANUAL by Bram Moolenaar
5
6
7Terminal window support *terminal*
8
9
10WARNING: THIS IS ONLY PARTLY IMPLEMENTED, ANYTHING CAN STILL CHANGE
11
12
131. Basic use |terminal-use|
142. Remote testing |terminal-testing|
153. Debugging |terminal-debug|
16
17{Vi does not have any of these commands}
18
19==============================================================================
201. Basic use *terminal-use*
21
22This feature is for running a terminal emulator in a Vim window. A job can be
23started connected to the terminal emulator. For example, to run a shell: >
24 :term bash
25
26Or to run a debugger: >
27 :term gdb vim
28
29The job runs asynchronously from Vim, the window will be updated to show
30output from the job, also while editing in any other window.
31
32When the keyboard focus is in the terminal window, typed keys will be send to
33the job. This uses a pty when possible.
34
35Navigate between windows with CTRL-W commands (and mouse).
36E.g. CTRL-W CTRL-W moves focus to the next window.
37
38Option 'termkey'
39Specify key for Vim command in terminal window. local to window.
40Default is CTRL-W.
41
42Option 'termsize'
43Specify terminal size. Local to window.
44When empty the terminal gets the size from the window.
45When set (e.g., "24x80") the terminal size is fixed. If the window is smaller
46only the top-left part is displayed. (TODO: scrolling?)
47
48Syntax ~
49 *:ter* *:terminal*
50:terminal[!] [command] Open a new terminal window.
51
52 If [command] is provided run it as a job and connect
53 the input and output to the terminal.
54 If [command] is not given the 'shell' option is used.
55
56 A new buffer will be created, using [command] or
57 'shell' as the name. If a buffer by this name already
58 exists a number is added in parenthesis.
59 E.g. if "gdb" exists the second terminal buffer will
60 use "gdb (1)".
61
62 The window can be closed, in which case the buffer
63 becomes hidden. The command will not be stopped. The
64 `:buffer` command can be used to turn the current
65 window into a terminal window, using the existing
66 buffer. If there are unsaved changes this fails, use
67 ! to force, as usual.
68
69Resizing ~
70
71The size of the terminal can be in one of three modes:
72
731. The 'termsize' option is empty: The terminal size follows the window size.
74 The minimal size is 2 screen lines with 10 cells.
75
762. The 'termsize' option is "rows*cols", where "rows" is the minimal number of
77 screen rows and "cols" is the minial number of cells.
78
793. The 'termsize' option is "rowsXcols" (where the x is upper or lower case).
80 The terminal size is fixed to the specified number of screen lines and
81 cells. If the window is bigger there will be unused empty space.
82
83If the window is smaller than the terminal size, only part of the terminal can
84be seen (the lower-left part).
85
86The |term_getsize()| function can be used to get the current size of the
87terminal. |term_setsize()| can be used only when in the first or second mode,
88not when 'termsize' is "rowsXcols".
89
90==============================================================================
912. Remote testing *terminal-testing*
92
93Most Vim tests execute a script inside Vim. For some tests this does not
94work, running the test interferes with the code being tested. To avoid this
95Vim is executed in a terminal window. The test sends keystrokes to it and
96inspects the resulting screen state.
97
98Functions ~
99
100term_sendkeys() send keystrokes to a terminal
101term_wait() wait for screen to be updated
102term_scrape() inspect terminal screen
103
104
105==============================================================================
1063. Debugging *terminal-debug*
107
108The Terminal debugging plugin can be used to debug a program with gdb and view
109the source code in a Vim window. For example: >
110
111 :TermDebug vim
112
113This opens three windows:
114- A terminal window in which "gdb vim" is executed. Here you can directly
115 interact with gdb.
116- A terminal window for the executed program. When "run" is used in gdb the
117 program I/O will happen in this window, so that it does not interfere with
118 controlling gdb.
119- A normal Vim window used to show the source code. When gdb jumps to a
120 source file location this window will display the code, if possible. Values
121 of variables can be inspected, breakpoints set and cleared, etc.
122
123This uses two terminal windows. To open the gdb window: >
124 :term gdb [arguments]
125To open the terminal to run the tested program |term_open()| is used.
126
127TODO
128
129
130 vim:tw=78:ts=8:ft=help:norl: