blob: 461e9059fe964feaddad1a9116713efaadec4d2d [file] [log] [blame]
Bram Moolenaar74675a62017-07-15 13:53:23 +02001*terminal.txt* For Vim version 8.0. Last change: 2017 Jul 15
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002
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
Bram Moolenaar74675a62017-07-15 13:53:23 +020038See option 'termkey' for specifying the key that precedes a Vim command.
Bram Moolenaare4f25e42017-07-07 11:54:15 +020039Default is CTRL-W.
40
Bram Moolenaar74675a62017-07-15 13:53:23 +020041See option 'termsize' for controlling the size of the terminal window.
42(TODO: scrolling when the terminal is larger than the window)
Bram Moolenaare4f25e42017-07-07 11:54:15 +020043
44Syntax ~
45 *:ter* *:terminal*
46:terminal[!] [command] Open a new terminal window.
47
48 If [command] is provided run it as a job and connect
49 the input and output to the terminal.
50 If [command] is not given the 'shell' option is used.
51
52 A new buffer will be created, using [command] or
53 'shell' as the name. If a buffer by this name already
54 exists a number is added in parenthesis.
55 E.g. if "gdb" exists the second terminal buffer will
56 use "gdb (1)".
57
58 The window can be closed, in which case the buffer
59 becomes hidden. The command will not be stopped. The
60 `:buffer` command can be used to turn the current
61 window into a terminal window, using the existing
62 buffer. If there are unsaved changes this fails, use
63 ! to force, as usual.
64
65Resizing ~
66
67The size of the terminal can be in one of three modes:
68
691. The 'termsize' option is empty: The terminal size follows the window size.
70 The minimal size is 2 screen lines with 10 cells.
71
722. The 'termsize' option is "rows*cols", where "rows" is the minimal number of
73 screen rows and "cols" is the minial number of cells.
74
753. The 'termsize' option is "rowsXcols" (where the x is upper or lower case).
76 The terminal size is fixed to the specified number of screen lines and
77 cells. If the window is bigger there will be unused empty space.
78
79If the window is smaller than the terminal size, only part of the terminal can
80be seen (the lower-left part).
81
82The |term_getsize()| function can be used to get the current size of the
83terminal. |term_setsize()| can be used only when in the first or second mode,
84not when 'termsize' is "rowsXcols".
85
86==============================================================================
872. Remote testing *terminal-testing*
88
89Most Vim tests execute a script inside Vim. For some tests this does not
90work, running the test interferes with the code being tested. To avoid this
91Vim is executed in a terminal window. The test sends keystrokes to it and
92inspects the resulting screen state.
93
94Functions ~
95
96term_sendkeys() send keystrokes to a terminal
97term_wait() wait for screen to be updated
98term_scrape() inspect terminal screen
99
100
101==============================================================================
1023. Debugging *terminal-debug*
103
104The Terminal debugging plugin can be used to debug a program with gdb and view
105the source code in a Vim window. For example: >
106
107 :TermDebug vim
108
109This opens three windows:
110- A terminal window in which "gdb vim" is executed. Here you can directly
111 interact with gdb.
112- A terminal window for the executed program. When "run" is used in gdb the
113 program I/O will happen in this window, so that it does not interfere with
114 controlling gdb.
115- A normal Vim window used to show the source code. When gdb jumps to a
116 source file location this window will display the code, if possible. Values
117 of variables can be inspected, breakpoints set and cleared, etc.
118
119This uses two terminal windows. To open the gdb window: >
120 :term gdb [arguments]
121To open the terminal to run the tested program |term_open()| is used.
122
123TODO
124
125
126 vim:tw=78:ts=8:ft=help:norl: