blob: d44e1b802b331b86824b9c181d49f78452031b24 [file] [log] [blame]
Bram Moolenaar24a98a02017-09-27 22:23:55 +02001*terminal.txt* For Vim version 8.0. Last change: 2017 Sep 26
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
Bram Moolenaarb6e0ec62017-07-23 22:12:20 +020012The terminal feature is optional, use this to check if your Vim has it: >
13 echo has('terminal')
14If the result is "1" you have it.
15
Bram Moolenaare4f25e42017-07-07 11:54:15 +020016
171. Basic use |terminal-use|
182. Remote testing |terminal-testing|
193. Debugging |terminal-debug|
20
21{Vi does not have any of these commands}
Bram Moolenaarc572da52017-08-27 16:52:01 +020022{only available when compiled with the |+terminal| feature}
23
24The terminal feature requires the |+multi_byte|, |+job| and |+channel| features.
Bram Moolenaare4f25e42017-07-07 11:54:15 +020025
26==============================================================================
271. Basic use *terminal-use*
28
29This feature is for running a terminal emulator in a Vim window. A job can be
30started connected to the terminal emulator. For example, to run a shell: >
31 :term bash
32
Bram Moolenaare09ba7b2017-09-09 22:19:47 +020033Or to run build command: >
34 :term make myprogram
Bram Moolenaare4f25e42017-07-07 11:54:15 +020035
36The job runs asynchronously from Vim, the window will be updated to show
Bram Moolenaare09ba7b2017-09-09 22:19:47 +020037output from the job, also while editing in another window.
Bram Moolenaare4f25e42017-07-07 11:54:15 +020038
Bram Moolenaar423802d2017-07-30 16:52:24 +020039
Bram Moolenaar1f28b4c2017-07-28 13:48:34 +020040Typing ~
Bram Moolenaar69fbc9e2017-09-14 20:37:57 +020041 *terminal-typing*
Bram Moolenaardd693ce2017-08-10 23:15:19 +020042When the keyboard focus is in the terminal window, typed keys will be sent to
Bram Moolenaar1f28b4c2017-07-28 13:48:34 +020043the job. This uses a pty when possible. You can click outside of the
44terminal window to move keyboard focus elsewhere.
Bram Moolenaare4f25e42017-07-07 11:54:15 +020045
Bram Moolenaar423802d2017-07-30 16:52:24 +020046CTRL-W can be used to navigate between windows and other CTRL-W commands, e.g.:
47 CTRL-W CTRL-W move focus to the next window
48 CTRL-W : enter an Ex command
49See |CTRL-W| for more commands.
Bram Moolenaare4f25e42017-07-07 11:54:15 +020050
Bram Moolenaar423802d2017-07-30 16:52:24 +020051Special in the terminal window: *CTRL-W_.* *CTRL-W_N*
52 CTRL-W . send a CTRL-W to the job in the terminal
Bram Moolenaardd693ce2017-08-10 23:15:19 +020053 CTRL-W N go to Terminal-Normal mode, see |Terminal-mode|
54 CTRL-\ CTRL-N go to Terminal-Normal mode, see |Terminal-mode|
Bram Moolenaarf55e4c82017-08-01 20:44:53 +020055 CTRL-W " {reg} paste register {reg} *CTRL-W_quote*
56 Also works with the = register to insert the result of
57 evaluating an expression.
Bram Moolenaar8e539c52017-08-18 22:57:06 +020058 CTRL-W CTRL-C ends the job, see below |t_CTRL-W_CTRL-C|
Bram Moolenaar423802d2017-07-30 16:52:24 +020059
60See option 'termkey' for specifying another key instead of CTRL-W that
61will work like CTRL-W. However, typing 'termkey' twice sends 'termkey' to
62the job. For example:
63 'termkey' CTRL-W move focus to the next window
64 'termkey' : enter an Ex command
65 'termkey' 'termkey' send 'termkey' to the job in the terminal
66 'termkey' . send a CTRL-W to the job in the terminal
67 'termkey' N go to terminal Normal mode, see below
68 'termkey' CTRL-N same as CTRL-W N
Bram Moolenaar8e539c52017-08-18 22:57:06 +020069 'termkey' CTRL-C same as |t_CTRL-W_CTRL-C|
Bram Moolenaar69198192017-08-05 14:10:48 +020070 *t_CTRL-\_CTRL-N*
Bram Moolenaardd693ce2017-08-10 23:15:19 +020071The special key combination CTRL-\ CTRL-N can be used to switch to Normal
72mode, just like this works in any other mode.
Bram Moolenaar8e539c52017-08-18 22:57:06 +020073 *t_CTRL-W_CTRL-C*
74CTRL-W CTRL-C can be typed to forcefully end the job. On MS-Windows a
75CTRL-BREAK will also kill the job.
76
77If you type CTRL-C the effect depends on what the pty has been configured to
78do. For simple commands this causes a SIGINT to be sent to the job, which
79would end it. Other commands may ignore the SIGINT or handle the CTRL-C
80themselves (like Vim does).
Bram Moolenaar423802d2017-07-30 16:52:24 +020081
Bram Moolenaar69fbc9e2017-09-14 20:37:57 +020082To change the keys you type use terminal mode mappings, see |:tmap|.
83These are defined like any mapping, but apply only when typing keys that are
Bram Moolenaar24a98a02017-09-27 22:23:55 +020084sent to the job running in the terminal. For example, to make Escape switch
85to Terminal-Normal mode: >
86 tnoremap <Esc> <C-W>N
87
88After opening the terminal window and setting 'buftype' to "terminal" the
89BufWinEnter autocommand event is triggered. This makes it possible to set
90options specifically for the window and buffer. Example: >
91 au BufWinEnter * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
Bram Moolenaar69fbc9e2017-09-14 20:37:57 +020092
Bram Moolenaar1f28b4c2017-07-28 13:48:34 +020093
Bram Moolenaar8e539c52017-08-18 22:57:06 +020094Size and color ~
Bram Moolenaare4f25e42017-07-07 11:54:15 +020095
Bram Moolenaar74675a62017-07-15 13:53:23 +020096See option 'termsize' for controlling the size of the terminal window.
97(TODO: scrolling when the terminal is larger than the window)
Bram Moolenaare4f25e42017-07-07 11:54:15 +020098
Bram Moolenaar38baa3e2017-09-14 16:10:38 +020099The job running in the terminal can change the colors. The default foreground
100and background colors are taken from Vim, the Normal highlight group.
101
102For a color terminal the 'background' option is used to decide whether the
103terminal window will start with a white or black background.
104
105To use a different color the Terminal highlight group can be used: >
106 hi Terminal ctermbg=lightgrey ctermfg=blue guibg=lightgrey guifg=blue
Bram Moolenaar8e539c52017-08-18 22:57:06 +0200107
Bram Moolenaar423802d2017-07-30 16:52:24 +0200108
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200109Syntax ~
Bram Moolenaar8a773062017-07-24 22:29:21 +0200110
Bram Moolenaardd693ce2017-08-10 23:15:19 +0200111:[range]ter[minal] [options] [command] *:ter* *:terminal*
Bram Moolenaar8a773062017-07-24 22:29:21 +0200112 Open a new terminal window.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200113
114 If [command] is provided run it as a job and connect
115 the input and output to the terminal.
116 If [command] is not given the 'shell' option is used.
Bram Moolenaarc572da52017-08-27 16:52:01 +0200117 if [command] is NONE no job is started, the pty of the
118 terminal can be used by a command like gdb.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200119
120 A new buffer will be created, using [command] or
Bram Moolenaarf55e4c82017-08-01 20:44:53 +0200121 'shell' as the name, prefixed with a "!". If a buffer
122 by this name already exists a number is added in
Bram Moolenaardd693ce2017-08-10 23:15:19 +0200123 parentheses. E.g. if "gdb" exists the second terminal
Bram Moolenaarf55e4c82017-08-01 20:44:53 +0200124 buffer will use "!gdb (1)".
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200125
Bram Moolenaarb2412082017-08-20 18:09:14 +0200126 If [range] is given the specified lines are used as
127 input for the job. It will not be possible to type
Bram Moolenaare09ba7b2017-09-09 22:19:47 +0200128 keys in the terminal window. For MS-Windows see the
129 ++eof argument below.
Bram Moolenaardd693ce2017-08-10 23:15:19 +0200130
131 Two comma separated numbers are used as "rows,cols".
132 E.g. `:24,80gdb` opens a terminal with 24 rows and 80
133 columns. However, if the terminal window spans the
134 Vim window with, there is no vertical split, the Vim
135 window width is used.
136 *term++close* *term++open*
137 Supported [options] are:
138 ++close The terminal window will close
139 automatically when the job terminates.
140 ++open When the job terminates and no window
Bram Moolenaar8cad9302017-08-12 14:32:32 +0200141 shows it, a window will be opened.
Bram Moolenaardd693ce2017-08-10 23:15:19 +0200142 Note that this can be interruptive.
Bram Moolenaar8cad9302017-08-12 14:32:32 +0200143 ++curwin Open the terminal in the current
144 window, do not split the current
145 window. Fails if the current buffer
146 cannot be |abandon|ed.
147 ++hidden Open the terminal in a hidden buffer,
148 no window will be used.
Bram Moolenaarb2412082017-08-20 18:09:14 +0200149 ++rows={height} Use {height} for the terminal window
150 height.
151 ++cols={width} Use {width} for the terminal window
152 width.
Bram Moolenaare09ba7b2017-09-09 22:19:47 +0200153 ++eof={text} when using [range]: text to send after
154 the last line was written. Cannot
155 contain white space. A CR is
156 appended. For MS-Windows the default
157 is to send CTRL-D.
Bram Moolenaaref68e4f2017-09-02 16:28:36 +0200158 E.g. for a shell use "++eof=exit" and
159 for Python "++eof=exit()". Special
160 codes can be used like with `:map`,
161 e.g. "<C-Z>" for CTRL-Z.
Bram Moolenaar8cad9302017-08-12 14:32:32 +0200162
163 If you want to use more options use the |term_start()|
164 function.
Bram Moolenaardd693ce2017-08-10 23:15:19 +0200165
Bram Moolenaar8e539c52017-08-18 22:57:06 +0200166When the buffer associated with the terminal is unloaded or wiped out the job
167is killed, similar to calling `job_stop(job, "kill")`
Bram Moolenaarb6e0ec62017-07-23 22:12:20 +0200168
Bram Moolenaare561a7e2017-08-29 22:44:59 +0200169So long as the job is running the window behaves like it contains a modified
Bram Moolenaaref68e4f2017-09-02 16:28:36 +0200170buffer. Trying to close the window with `CTRL-W :quit` fails. When using
171`CTRL-W :quit!` the job is ended. The text in the window is lost. The buffer
172still exists, but getting it in a window with `:buffer` will show an empty
173buffer.
174
175Trying to close the window with `CTRL-W :close` also fails. Using
176`CTRL-W :close!` will close the window and make the buffer hidden.
Bram Moolenaare561a7e2017-08-29 22:44:59 +0200177
178You can use `CTRL-W :hide` to close the terminal window and make the buffer
179hidden, the job keeps running. The `:buffer` command can be used to turn the
180current window into a terminal window. If there are unsaved changes this
181fails, use ! to force, as usual.
Bram Moolenaar8cad9302017-08-12 14:32:32 +0200182
183To have a background job run without a window, and open the window when it's
184done, use options like this: >
185 :term ++hidden ++open make
186Note that the window will open at an unexpected moment, this will interrupt
187what you are doing.
188
Bram Moolenaar8e539c52017-08-18 22:57:06 +0200189 *E947* *E948*
Bram Moolenaar78712a72017-08-05 14:50:12 +0200190So long as the job is running, the buffer is considered modified and Vim
191cannot be quit easily, see |abandon|.
Bram Moolenaarf55e4c82017-08-01 20:44:53 +0200192
193When the job has finished and no changes were made to the buffer: closing the
194window will wipe out the buffer.
195
196Before changes can be made to a terminal buffer, the 'modifiable' option must
197be set. This is only possible when the job has finished. At the first change
198the buffer will become a normal buffer and the highlighting is removed.
199You may want to change the buffer name with |:file| to be able to write, since
200the buffer name will still be set to the command.
201
Bram Moolenaarb6e0ec62017-07-23 22:12:20 +0200202
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200203Resizing ~
204
205The size of the terminal can be in one of three modes:
206
2071. The 'termsize' option is empty: The terminal size follows the window size.
208 The minimal size is 2 screen lines with 10 cells.
209
2102. The 'termsize' option is "rows*cols", where "rows" is the minimal number of
Bram Moolenaar8a773062017-07-24 22:29:21 +0200211 screen rows and "cols" is the minimal number of cells.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200212
2133. The 'termsize' option is "rowsXcols" (where the x is upper or lower case).
214 The terminal size is fixed to the specified number of screen lines and
215 cells. If the window is bigger there will be unused empty space.
216
217If the window is smaller than the terminal size, only part of the terminal can
218be seen (the lower-left part).
219
220The |term_getsize()| function can be used to get the current size of the
221terminal. |term_setsize()| can be used only when in the first or second mode,
222not when 'termsize' is "rowsXcols".
223
Bram Moolenaarb6e0ec62017-07-23 22:12:20 +0200224
Bram Moolenaardd693ce2017-08-10 23:15:19 +0200225Terminal-Job and Terminal-Normal mode ~
Bram Moolenaar423802d2017-07-30 16:52:24 +0200226 *Terminal-mode*
227When the job is running the contents of the terminal is under control of the
Bram Moolenaardd693ce2017-08-10 23:15:19 +0200228job. That includes the cursor position. Typed keys are sent to the job.
229The terminal contents can change at any time. This is called Terminal-Job
230mode.
Bram Moolenaar423802d2017-07-30 16:52:24 +0200231
Bram Moolenaardd693ce2017-08-10 23:15:19 +0200232Use CTRL-W N (or 'termkey' N) to switch to Terminal-Normal mode. Now the
233contents of the terminal window is under control of Vim, the job output is
234suspended. CTRL-\ CTRL-N does the same.
Bram Moolenaar69fbc9e2017-09-14 20:37:57 +0200235
Bram Moolenaar1b9645d2017-09-17 23:03:31 +0200236Terminal-Job mode is where |:tmap| mappings are applied. Keys sent by
Bram Moolenaar69fbc9e2017-09-14 20:37:57 +0200237|term_sendkeys()| are not subject to tmap, but keys from |feedkeys()| are.
238
Bram Moolenaar423802d2017-07-30 16:52:24 +0200239 *E946*
Bram Moolenaardd693ce2017-08-10 23:15:19 +0200240In Terminal-Normal mode you can move the cursor around with the usual Vim
241commands, Visually mark text, yank text, etc. But you cannot change the
242contents of the buffer. The commands that would start insert mode, such as
243'i' and 'a', return to Terminal-Job mode. The window will be updated to show
Bram Moolenaar1b9645d2017-09-17 23:03:31 +0200244the contents of the terminal. |:startinsert| is ineffective.
Bram Moolenaar423802d2017-07-30 16:52:24 +0200245
Bram Moolenaardd693ce2017-08-10 23:15:19 +0200246In Terminal-Normal mode the statusline and window title show "(Terminal)". If
247the job ends while in Terminal-Normal mode this changes to
248"(Terminal-finished)".
Bram Moolenaar423802d2017-07-30 16:52:24 +0200249
Bram Moolenaar8e539c52017-08-18 22:57:06 +0200250It is not possible to enter Insert mode from Terminal-Job mode.
251
Bram Moolenaar423802d2017-07-30 16:52:24 +0200252
Bram Moolenaarc572da52017-08-27 16:52:01 +0200253Cursor style ~
254
255By default the cursor in the terminal window uses a not blinking block. The
256normal xterm escape sequences can be used to change the blinking state and the
257shape. Once focus leaves the terminal window Vim will restore the original
258cursor.
259
260An exception is when xterm is started with the "-bc" argument, or another way
261that causes the cursor to blink. This actually means that the blinking flag
262is inverted. Since Vim cannot detect this, the terminal window cursor
263blinking will also be inverted.
264
265
Bram Moolenaarb6e0ec62017-07-23 22:12:20 +0200266Unix ~
267
268On Unix a pty is used to make it possible to run all kinds of commands. You
269can even run Vim in the terminal! That's used for debugging, see below.
270
Bram Moolenaarf55e4c82017-08-01 20:44:53 +0200271Environment variables are used to pass information to the running job:
272 TERM name of the terminal, 'term'
273 ROWS number of rows in the terminal initially
274 LINES same as ROWS
275 COLUMNS number of columns in the terminal initially
276 COLORS number of colors, 't_Co' (256*256*256 in the GUI)
277 VIM_SERVERNAME v:servername
278
279The |client-server| feature can be used to communicate with the Vim instance
280where the job was started. This only works when v:servername is not empty.
281If needed you can set it with: >
282 call remote_startserver('vim-server')
283
284In the job you can then do something like: >
285 vim --servername $VIM_SERVERNAME --remote +123 some_file.c
286This will open the file "some_file.c" and put the cursor on line 123.
287
Bram Moolenaarb6e0ec62017-07-23 22:12:20 +0200288
289MS-Windows ~
290
Bram Moolenaar8a773062017-07-24 22:29:21 +0200291On MS-Windows winpty is used to make it possible to run all kind of commands.
292Obviously, they must be commands that run in a terminal, not open their own
293window.
294
295You need the following two files from winpty:
296
297 winpty.dll
298 winpty-agent.exe
299
300You can download them from the following page:
301
302 https://github.com/rprichard/winpty
303
Bram Moolenaar8e539c52017-08-18 22:57:06 +0200304Just put the files somewhere in your PATH. You can set the 'winptydll' option
305to point to the right file, if needed. If you have both the 32-bit and 64-bit
306version, rename to winpty32.dll and winpty64.dll to match the way Vim was
307build.
Bram Moolenaarb6e0ec62017-07-23 22:12:20 +0200308
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200309==============================================================================
3102. Remote testing *terminal-testing*
311
312Most Vim tests execute a script inside Vim. For some tests this does not
313work, running the test interferes with the code being tested. To avoid this
314Vim is executed in a terminal window. The test sends keystrokes to it and
315inspects the resulting screen state.
316
317Functions ~
318
Bram Moolenaar69fbc9e2017-09-14 20:37:57 +0200319term_sendkeys() send keystrokes to a terminal (not subject to tmap)
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200320term_wait() wait for screen to be updated
321term_scrape() inspect terminal screen
322
323
324==============================================================================
3253. Debugging *terminal-debug*
326
327The Terminal debugging plugin can be used to debug a program with gdb and view
Bram Moolenaare09ba7b2017-09-09 22:19:47 +0200328the source code in a Vim window. Since this is completely contained inside
329Vim this also works remotely over an ssh connection.
330
331
332Starting ~
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200333
Bram Moolenaarc572da52017-08-27 16:52:01 +0200334Load the plugin with this command: >
335 packadd termdebug
Bram Moolenaare09ba7b2017-09-09 22:19:47 +0200336< *:Termdebug*
Bram Moolenaarc572da52017-08-27 16:52:01 +0200337To start debugging use `:TermDebug` folowed by the command name, for example: >
Bram Moolenaar24a98a02017-09-27 22:23:55 +0200338 :Termdebug vim
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200339
Bram Moolenaarc572da52017-08-27 16:52:01 +0200340This opens two windows:
Bram Moolenaar45d5f262017-09-10 19:14:31 +0200341gdb window A terminal window in which "gdb vim" is executed. Here you
342 can directly interact with gdb. The buffer name is "!gdb".
343program window A terminal window for the executed program. When "run" is
344 used in gdb the program I/O will happen in this window, so
345 that it does not interfere with controlling gdb. The buffer
346 name is "gdb program".
Bram Moolenaare09ba7b2017-09-09 22:19:47 +0200347
348The current window is used to show the source code. When gdb pauses the
349source file location will be displayed, if possible. A sign is used to
350highlight the current position (using highlight group debugPC).
351
352If the buffer in the current window is modified, another window will be opened
353to display the current gdb position.
354
355Focus the terminal of the executed program to interact with it. This works
356the same as any command running in a terminal window.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200357
Bram Moolenaar45d5f262017-09-10 19:14:31 +0200358When the debugger ends, typically by typing "quit" in the gdb window, the two
359opened windows are closed.
Bram Moolenaarc572da52017-08-27 16:52:01 +0200360
361
Bram Moolenaar24a98a02017-09-27 22:23:55 +0200362Example session ~
363
364Start in the Vim "src" directory and build Vim: >
365 % make
366Start Vim: >
367 % ./vim
368Load the termdebug plugin and start debugging Vim: >
369 :packadd termdebug
370 :Termdebug vim
371You should now have three windows:
372 source - where you started, has a window toolbar with buttons
373 gdb - you can type gdb commands here
374 program - the executed program will use this window
375You can use CTRL-W CTRL-W or the mouse to move focus between windows.
376Put focus on the gdb window and type: >
377 break ex_help
378 run
379Vim will start running in the program window. Put focus there and type: >
380 :help gui
381Gdb will run into the ex_help breakpoint. The source window now shows the
382ex_cmds.c file. A ">>" marker will appear where the breakpoint was set. The
383line where the debugger stopped is highlighted. You can now step through the
384program. Let's use the mouse: click on the "Next" button in the window
385toolbar. You will see the highlighting move as the debugger executes a line
386of source code.
387
388Click "Next" a few times until the for loop is highlighted. Put the cursor on
389the end of "eap->arg", then click "Eval" in the toolbar. You will see this
390displayed:
391 "eap->arg": 0x555555e68855 "gui" ~
392This way you can inspect the value of local variables. You can also focus the
393gdb window and use a "print" command, e.g.: >
394 print *eap
395
396Now go back to the source window and put the cursor on the first line after
397the for loop, then type: >
398 :Break
399You will see a ">>" marker appear, this indicates the new breakpoint. Now
400click "Cont" in the toolbar and the code until the breakpoint will be
401executed.
402
403You can type more advanced commands in the gdb window. For example, type: >
404 watch curbuf
405Now click "Cont" in the toolbar (or type "cont" in the gdb window). Execution
406will now continue until the value of "curbuf" changes, which is in do_ecmd().
407To remove this watchpoint again type in the gdb window: >
408 delete 3
409
410You can see the stack by typing in the gdb window: >
411 where
412Move through the stack frames, e.g. with: >
413 frame 3
414The source window will show the code, at the point where the call was made to
415a deeper level.
416
417
Bram Moolenaare09ba7b2017-09-09 22:19:47 +0200418Stepping through code ~
419
420Put focus on the gdb window to type commands there. Some common ones are:
421- CTRL-C interrupt the program
422- next execute the current line and stop at the next line
423- step execute the current line and stop at the next statement, entering
424 functions
425- finish execute until leaving the current function
426- where show the stack
427- frame N go to the Nth stack frame
428- continue continue execution
429
Bram Moolenaar45d5f262017-09-10 19:14:31 +0200430In the window showing the source code some commands can used to control gdb:
431 :Break set a breakpoint at the current line; a sign will be displayed
432 :Delete delete a breakpoint at the current line
433 :Step execute the gdb "step" command
434 :Over execute the gdb "next" command (:Next is a Vim command)
435 :Finish execute the gdb "finish" command
436 :Continue execute the gdb "continue" command
437
Bram Moolenaar1b9645d2017-09-17 23:03:31 +0200438The plugin adds a window toolbar with these entries:
439 Step :Step
440 Next :Over
441 Finish :Finish
442 Cont :Continue
443 Eval :Evaluate
444This way you can use the mouse to perform the most common commands.
445
Bram Moolenaar45d5f262017-09-10 19:14:31 +0200446
447Inspecting variables ~
448
449 :Evaluate evaluate the expression under the cursor
450 K same
451 :Evaluate {expr} evaluate {expr}
452 :'<,'>Evaluate evaluate the Visually selected text
453
454This is similar to using "print" in the gdb window.
455
456
457Other commands ~
458
459 :Gdb jump to the gdb window
460 :Program jump to the window with the running program
Bram Moolenaare09ba7b2017-09-09 22:19:47 +0200461
462
463Communication ~
464
465There is another, hidden, buffer, which is used for Vim to communicate with
466gdb. The buffer name is "gdb communication". Do not delete this buffer, it
467will break the debugger.
468
469
Bram Moolenaarc572da52017-08-27 16:52:01 +0200470Customizing ~
471
Bram Moolenaare09ba7b2017-09-09 22:19:47 +0200472To change the name of the gdb command, set the "termdebugger" variable before
473invoking `:Termdebug`: >
474 let termdebugger = "mygdb"
475Only debuggers fully compatible with gdb will work. Vim uses the GDB/MI
Bram Moolenaar24a98a02017-09-27 22:23:55 +0200476interface. This probably requires gdb version 7.12.
Bram Moolenaare09ba7b2017-09-09 22:19:47 +0200477
478The color of the signs can be adjusted with these highlight groups:
479- debugPC the current position
480- debugBreakpoint a breakpoint
481
482The defaults are, when 'background' is "light":
483 hi debugPC term=reverse ctermbg=lightblue guibg=lightblue
484 hi debugBreakpoint term=reverse ctermbg=red guibg=red
485
486When 'background' is "dark":
487 hi debugPC term=reverse ctermbg=darkblue guibg=darkblue
488 hi debugBreakpoint term=reverse ctermbg=red guibg=red
Bram Moolenaarc572da52017-08-27 16:52:01 +0200489
Bram Moolenaar38baa3e2017-09-14 16:10:38 +0200490To change the width of the Vim window when debugging starts, and use a
491vertical split: >
492 let g:termdebug_wide = 163
493This will set &columns to 163 when :Termdebug is used. The value is restored
494when quitting the debugger.
Bram Moolenaar24a98a02017-09-27 22:23:55 +0200495If g:termdebug_wide is set and &Columns is already larger than
496g:termdebug_wide then a vertical split will be used without changing &columns.
497Set it to 1 to get a vertical split without every changing &columns (useful
498for when the terminal can't be resized by Vim).
Bram Moolenaar38baa3e2017-09-14 16:10:38 +0200499
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200500
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200501
502 vim:tw=78:ts=8:ft=help:norl: