robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #41113 from justinmk/doc27ce7a8d58c

master
30.3 KiB726 linesraw
1*terminal.txt*   Nvim
2
3
4                            NVIM REFERENCE MANUAL
5
6
7Terminal emulator                                     *terminal* *terminal-emulator*
8
9Nvim embeds a VT220/xterm terminal emulator based on libvterm. The terminal is
10presented as a special 'buftype', asynchronously updated as data is received
11from the connected program.
12
13Terminal buffers behave like normal buffers, except:
14- With 'modifiable', lines can be edited but not deleted.
15- 'scrollback' controls how many lines are kept.
16- Output is followed ("tailed") if cursor is on the last line.
17- 'modified' is the default. You can set 'nomodified' to avoid a warning when
18  closing the terminal buffer.
19- 'bufhidden' defaults to "hide".
20
21                                      Type |gO| to see the table of contents.
22
23==============================================================================
24Start                                                           *terminal-start*
25
26There are several ways to create a terminal buffer:
27
28- Run the |:terminal| command.
29- Call |nvim_open_term()| or `jobstart(…, {'term': v:true})`.
30- Edit a "term://" buffer. Examples: >vim
31    :edit term://bash
32    :vsplit term://top
33
34<    Note: To open a "term://" buffer from an autocmd, the |autocmd-nested|
35    modifier is required. >vim
36        autocmd VimEnter * ++nested split term://sh
37<    (This is only mentioned for reference; use |:terminal| instead.)
38
39When the terminal starts, the buffer contents are updated and the buffer is
40named in the form of `term://{cwd}//{pid}:{cmd}`. This naming scheme is used
41by |:mksession| to restore a terminal buffer (by restarting the {cmd}).
42
43The terminal environment is initialized as in |jobstart-env|.
44
45==============================================================================
46MS-Windows ConPTY                      *terminal-ms-windows* *terminal-conpty*
47
48The system ConPTY (in "kernel32.dll") mangles some VT sequences, which can
49garble |:terminal| output. To use a newer ConPTY from the Windows Terminal
50project, put its "conpty.dll" (and "OpenConsole.exe") next to the Nvim
51executable. Nvim uses that "conpty.dll" if present, else falls back to the
52system ConPTY, and logs which one (|$NVIM_LOG_FILE|): >
53    Loaded new ConPTY from conpty.dll
54    Loaded system ConPTY from kernel32.dll
55<
56
57==============================================================================
58Input                                                           *terminal-input*
59
60To send input, enter |Terminal-mode| with |i|, |I|, |a|, |A| or
61|:startinsert|. In this mode all keys except <C-\> are sent to the underlying
62program. If <C-\> is pressed, the next key is sent unless it is <C-N> or <C-O>.
63Use <C-\><C-N> to return to normal mode. |CTRL-\_CTRL-N|
64Use <C-\><C-O> to execute one normal mode command and then return to terminal
65mode. *t_CTRL-\_CTRL-O*
66
67Terminal-mode forces these local options:
68
69- 'cursorlineopt' = number
70- 'nocursorcolumn'
71- 'scrolloff' = 0
72- 'sidescrolloff' = 0
73
74Terminal-mode has its own |:tnoremap| namespace for mappings, this can be used
75to automate any terminal interaction.
76
77To map <Esc> to exit terminal-mode: >vim
78    :tnoremap <Esc> <C-\><C-n>
79
80To simulate |i_CTRL-R| in terminal-mode: >vim
81    :tnoremap <expr> <C-R> '<C-\><C-N>"'.nr2char(getchar()).'pi'
82
83To use `ALT+{h,j,k,l}` to navigate windows from any mode: >vim
84    :tnoremap <A-h> <C-\><C-N><C-w>h
85    :tnoremap <A-j> <C-\><C-N><C-w>j
86    :tnoremap <A-k> <C-\><C-N><C-w>k
87    :tnoremap <A-l> <C-\><C-N><C-w>l
88    :inoremap <A-h> <C-\><C-N><C-w>h
89    :inoremap <A-j> <C-\><C-N><C-w>j
90    :inoremap <A-k> <C-\><C-N><C-w>k
91    :inoremap <A-l> <C-\><C-N><C-w>l
92    :nnoremap <A-h> <C-w>h
93    :nnoremap <A-j> <C-w>j
94    :nnoremap <A-k> <C-w>k
95    :nnoremap <A-l> <C-w>l
96
97You can also create menus similar to terminal mode mappings, but you have to
98use |:tlmenu| instead of |:tmenu|.
99
100Mouse input has the following behavior:
101
102- If the program has enabled mouse events, the corresponding events will be
103  forwarded to the program.
104- If mouse events are disabled (the default), terminal focus will be lost and
105  the event will be processed as in a normal buffer.
106- If another window is clicked, terminal focus will be lost and nvim will jump
107  to the clicked window
108- If the mouse wheel is used while the mouse is positioned in another window,
109  the terminal won't lose focus and the hovered window will be scrolled.
110
111==============================================================================
112Configuration                                                  *terminal-config*
113
114- Options: 'modified', 'scrollback'
115- Events: |TermOpen|, |TermEnter|, |TermLeave|, |TermClose|
116- Event groups: "nvim.terminal" |default-autocmds|
117- Highlight groups: |hl-TermCursor|
118
119Terminal sets local defaults for some options, which may differ from your
120global configuration.
121
122- 'list' is disabled
123- 'wrap' is disabled
124- 'number' is disabled
125- 'relativenumber' is disabled
126- 'signcolumn' is set to "no"
127- 'foldcolumn' is set to "0"
128
129You can change the defaults with a TermOpen autocommand: >vim
130    :autocmd TermOpen * setlocal list
131
132By default, "[Process exited]" is displayed when the terminal process ends. To
133disable that, you can delete the "nvim.terminal" TermClose handler (this also
134deletes other |default-autocmds| TermClose functionality): >vim
135    :autocmd! nvim.terminal TermClose
136<
137
138TERMINAL COLORS ~
139
140The `{g,b}:terminal_color_x` variables control the terminal color palette,
141where `x` is the color index between 0 and 15 inclusive.  The variables are
142read during |TermOpen|. The value must be a color name or hexadecimal string.
143Example: >vim
144    let g:terminal_color_4 = '#ff0000'
145    let g:terminal_color_5 = 'green'
146Only works for RGB UIs (see 'termguicolors'); for 256-color terminals the
147color index is just forwarded.
148
149Editor highlighting (|syntax-highlighting|, |highlight-groups|, etc.) has
150higher precedence: it is applied after terminal colors are resolved.
151
152------------------------------------------------------------------------------
153EVENTS                                                        *terminal-events*
154
155Applications running in a :terminal buffer can send requests, which Nvim
156exposes via the |TermRequest| event.
157
158OSC 7: change working directory                                *terminal-osc7*
159
160Shells can emit the "OSC 7" sequence to announce when the current directory
161(CWD) changed.
162
163You can configure your shell init (e.g. ~/.bashrc) to emit OSC 7, or your
164terminal may attempt to do it for you.
165
166To configure bash to emit OSC 7: >bash
167  function print_osc7() {
168    printf '\033]7;file://%s\033\\' "$PWD"
169  }
170  PROMPT_COMMAND='print_osc7'
171
172Having ensured that your shell emits OSC 7, you can now handle it in Nvim. The
173following code runs |:bcd| whenever your shell CWD changes, so the :terminal
174buffer-local directory always follows the shell: >lua
175
176  vim.api.nvim_create_autocmd('TermRequest', {
177    desc = 'Handles OSC 7 dir change requests',
178    callback = function(ev)
179      local val, n = string.gsub(ev.data.sequence, '\027]7;file://[^/]*', '')
180      if n > 0 then
181        -- OSC 7: dir-change
182        local dir = val
183        if vim.fn.isdirectory(dir) == 0 then
184          vim.notify('invalid dir: '..dir)
185          return
186        end
187        vim.cmd.bcd(dir)
188      end
189    end
190  })
191
192To try it out, select the above code and source it with `:'<,'>lua`, then run
193this command in a :terminal buffer: >
194
195    printf "\033]7;file://./foo/bar\033\\"
196
197OSC 52: write to system clipboard                             *terminal-osc52*
198
199Applications in the :terminal buffer can write to the system clipboard by
200emitting an OSC 52 sequence. Example: >
201
202    printf '\033]52;;%s\033\\' "$(echo -n 'Hello world' | base64)"
203
204Nvim uses the configured |clipboard| provider to write to the system
205clipboard. Reading from the system clipboard with OSC 52 is not supported, as
206this would allow any arbitrary program in the :terminal to read the user's
207clipboard.
208
209OSC 52 sequences sent from the :terminal buffer do not emit a |TermRequest|
210event. The event is handled directly by Nvim and is not forwarded to plugins.
211
212OSC 133: shell integration                    *terminal-osc133* *shell-prompt*
213
214Shells can emit semantic escape sequences (OSC 133) to mark where each prompt
215starts and ends. The start of a prompt is marked by sequence `OSC 133 ; A ST`,
216and the end by `OSC 133 ; B ST`.
217
218You can configure your shell init (e.g. ~/.bashrc) to emit OSC 133 sequences,
219or your terminal may attempt to do it for you (assuming your shell config
220doesn't interfere).
221
222- fish: https://fishshell.com/docs/current/relnotes.html#improved-terminal-support
223- kitty: https://sw.kovidgoyal.net/kitty/shell-integration/
224- powershell: https://learn.microsoft.com/en-us/windows/terminal/tutorials/shell-integration#powershell-pwshexe
225- vscode: https://code.visualstudio.com/docs/terminal/shell-integration
226
227To configure bash to mark the start of each prompt, set $PROMPT_COMMAND: >bash
228
229    # Prompt start:
230    PROMPT_COMMAND='printf "\033]133;A\007"'
231<
232                                                *terminal_]]* *terminal_[[*
233The |]]| and |[[| motions jump to the next/previous prompts, if your shell
234emits OSC 133 as described above.
235
236                                                *shell-prompt-signs*
237To annotate each terminal prompt with a sign, call |nvim_buf_set_extmark()|
238from a |TermRequest| handler: >lua
239
240    vim.api.nvim_create_autocmd('TermOpen', {
241      command = 'setlocal signcolumn=auto',
242    })
243    local ns = vim.api.nvim_create_namespace('my.terminal.prompt')
244    vim.api.nvim_create_autocmd('TermRequest', {
245      callback = function(ev)
246        if string.match(ev.data.sequence, '^\027]133;A') then
247          local lnum = ev.data.cursor[1]
248          vim.api.nvim_buf_set_extmark(ev.buf, ns, lnum - 1, 0, {
249            sign_text = '▶',
250            sign_hl_group = 'SpecialChar',
251          })
252        end
253      end,
254    })
255<
256==============================================================================
257Status Variables                                             *terminal-status*
258
259Terminal buffers maintain some buffer-local variables and options. The values
260are initialized before TermOpen, so you can use them in a local 'statusline'.
261Example: >vim
262    :autocmd TermOpen * setlocal statusline=%{b:term_title}
263
264- *b:term_title*  Terminal title (user-writable), typically displayed in the
265  window title or tab title of a graphical terminal emulator. Terminal
266  programs can set this by emitting an escape sequence.
267- 'channel'  Terminal PTY |job-id|.  Can be used with |chansend()| to send
268  input to the terminal.
269- The |TermClose| event gives the terminal job exit code in the |v:event|
270  "status" field. For example, this autocommand outputs the terminal's exit
271  code to |:messages|: >vim
272    autocmd TermClose * echom 'Terminal exited with status '..v:event.status
273
274Use |jobwait()| to check if the terminal job has finished: >vim
275    let running = jobwait([&channel], 0)[0] == -1
276<
277
278==============================================================================
279Concepts                                                   *terminal-concepts*
280
281TODO
282
283==============================================================================
284:Termdebug plugin                         *terminal-debug* *terminal-debugger*
285                                               *package-termdebug* *termdebug*
286
287The Terminal debugging plugin can be used to debug a program with gdb and view
288the source code in a Vim window.  Since this is completely contained inside
289Vim this also works remotely over an ssh connection.
290
291Starting ~
292                                                        *termdebug-starting*
293Load the plugin with this command: >vim
294    packadd termdebug
295When loading the plugin from the |vimrc| file, add the "!" attribute: >vim
296    packadd! termdebug
297<                                                       *:Termdebug*
298To start debugging use `:Termdebug` or `:TermdebugCommand` followed by the
299command name, for example: >vim
300    :Termdebug vim
301
302This opens two windows:
303
304- gdb window: A terminal window in which "gdb vim" is executed.  Here you can
305  directly interact with gdb.
306- program window: A terminal window for the executed program.  When "run" is
307  used in gdb the program I/O will happen in this window, so that it does not
308  interfere with controlling gdb.
309
310The current window is used to show the source code.  When gdb pauses the
311source file location will be displayed, if possible.  A sign is used to
312highlight the current position, using highlight group debugPC.
313
314If the buffer in the current window is modified, another window will be opened
315to display the current gdb position.
316
317Focus the terminal of the executed program to interact with it.  This works
318the same as any command running in a terminal window.
319
320When the debugger ends, typically by typing "quit" in the gdb window, the two
321opened windows are closed.
322
323Only one debugger can be active at a time.
324                                                        *:TermdebugCommand*
325If you want to give specific commands to the command being debugged, you can
326use the `:TermdebugCommand` command followed by the command name and
327additional parameters. >vim
328    :TermdebugCommand vim --clean -c ':set nu'
329
330Both the `:Termdebug` and `:TermdebugCommand` support an optional "!" bang
331argument to start the command right away, without pausing at the gdb window
332(and cursor will be in the debugged window).  For example: >vim
333    :TermdebugCommand! vim --clean
334
335To attach gdb to an already running executable or use a core file, pass extra
336arguments.  E.g.: >vim
337    :Termdebug vim core
338    :Termdebug vim 98343
339
340If no argument is given, you'll end up in a gdb window, in which you need to
341specify which command to run using e.g. the gdb `file` command.
342
343
344Example session ~
345                                                        *termdebug-example*
346Start in the Vim "src" directory and build Vim: >
347    % make
348Start Vim: >
349    % ./vim
350Load the termdebug plugin and start debugging Vim: >vim
351    :packadd termdebug
352    :Termdebug vim
353You should now have three windows:
354- source:  where you started
355- gdb:     you can type gdb commands here
356- program: the executed program will use this window
357
358Put focus on the gdb window and type: >
359    break ex_help
360    run
361Vim will start running in the program window.  Put focus there and type: >vim
362    :help gui
363Gdb will run into the ex_help breakpoint.  The source window now shows the
364ex_cmds.c file.  A red "1 " marker will appear in the signcolumn where the
365breakpoint was set.  The line where the debugger stopped is highlighted.  You
366can now step through the program.  You will see the highlighting move as the
367debugger executes a line of source code.
368
369Run |:Over| a few times until the for loop is highlighted.  Put the cursor on
370the end of "eap->arg", then call ":Eval".  You will see this displayed: >
371    "eap->arg": 0x555555e68855 "gui"
372This way you can inspect the value of local variables.  You can also focus the
373gdb window and use a "print" command, e.g.: >
374    print *eap
375If mouse pointer movements are working, Vim will also show a balloon when the
376mouse rests on text that can be evaluated by gdb.
377You can also use the "K" mapping that will either use Nvim floating windows
378to show the results.
379
380Now go back to the source window and put the cursor on the first line after
381the for loop, then type: >
382    :Break
383You will see a "1" marker appear, this indicates the new breakpoint.  Now
384run ":Cont" command and the code until the breakpoint will be executed.
385
386You can type more advanced commands in the gdb window.  For example, type: >
387    watch curbuf
388Now run ":Cont" (or type "cont" in the gdb window). Execution
389will now continue until the value of "curbuf" changes, which is in do_ecmd().
390To remove this watchpoint again type in the gdb window: >
391    delete 3
392
393You can see the stack by typing in the gdb window: >
394    where
395Move through the stack frames, e.g. with: >
396    frame 3
397The source window will show the code, at the point where the call was made to
398a deeper level.
399
400
401Stepping through code ~
402                                                        *termdebug-stepping*
403Put focus on the gdb window to type commands there.  Some common ones are:
404- CTRL-C:   interrupt the program
405- next:     execute the current line and stop at the next line
406- step:     execute the current line and stop at the next statement,
407            entering functions
408- until:    execute until past the current cursor line or past a specified
409            position or the current stack frame returns
410- finish:   execute until leaving the current function
411- where:    show the stack
412- frame N:  go to the Nth stack frame
413- continue: continue execution
414
415                                                *:Run* *:Arguments*
416In the window showing the source code these commands can be used to control
417gdb:
418- `:Run` [args]        run the program with [args] or the previous arguments
419- `:Arguments` {args}  set arguments for the next `:Run`
420
421- *:Break* set a breakpoint at the cursor position
422- :Break [{position}] [thread {nr}] [if {expr}]
423  set a breakpoint at the specified position if {position} is omitted, use the
424  current file and line thread {nr} limits the breakpoint to one thread if
425  {expr} sets a conditional breakpoint.
426  Examples: >
427      :Break if argc == 1
428      :Break 42 thread 3 if x > 10
429      :Break main
430<
431- *:Tbreak* set a temporary breakpoint at the cursor position
432- :Tbreak [{position}] [thread {nr}] [if {expr}]
433  like `:Break`, but the breakpoint is deleted after it is hit once.
434  Examples: >
435      :Tbreak if argc == 1
436      :Tbreak 42 thread 3 if x > 10
437      :Tbreak main
438<
439- *:Clear* delete the breakpoint at the cursor position
440- *:ToggleBreak* set a breakpoint at the cursor position or delete all
441               breakpoints at the cursor positoin
442
443- *:Step*       execute the gdb "step" command
444- *:Over*       execute the gdb "next" command (`:Next` is a Vim command)
445- *:Until*      execute the gdb "until" command
446- *:Finish*     execute the gdb "finish" command
447- *:Continue*   execute the gdb "continue" command
448- *:RunOrContinue* execute the gdb "continue" command if program is running,
449                 otherwise run the program
450- *:Stop*       interrupt the program
451
452If gdb stops at a source line and there is no window currently showing the
453source code, a new window will be created for the source code.  This also
454happens if the buffer in the source code window has been modified and can't be
455abandoned.
456
457Gdb gives each breakpoint a number.  In Vim the number shows up in the sign
458column, with a red background.  You can use these gdb commands:
459- info break    list breakpoints
460- delete N      delete breakpoint N
461You can also use the `:Clear` command if the cursor is in the line with the
462breakpoint, or use the "Clear breakpoint" right-click menu entry.
463
464
465Inspecting variables ~
466                                        *termdebug-variables* *:Evaluate*
467- `:Evaluate`        evaluate the expression under the cursor
468- `K`                same (see |termdebug_map_K| to disable)
469- `:Evaluate` {expr} evaluate {expr}
470- `:'<,'>Evaluate`   evaluate the Visually selected text
471
472This is similar to using "print" in the gdb window.
473You can usually shorten `:Evaluate` to `:Ev`.
474The result is displayed in a floating window.
475You can move the cursor to this window by running `:Evaluate` (or `K`) again.
476
477
478Navigating stack frames ~
479                                *termdebug-frames* *:Frame* *:Up* *:Down*
480- `:Frame` [frame]       select frame [frame], which is a frame number,
481                       address, or function name (default: current frame)
482- `:Up` [count]          go up [count] frames (default: 1; the frame that
483                       called the current)
484- `+`                    same (see |termdebug_map_plus| to disable)
485- `:Down` [count]        go down [count] frames (default: 1; the frame called
486                       by the current)
487- `-`                    same (see |termdebug_map_minus| to disable)
488
489
490Other commands ~
491                                                        *termdebug-commands*
492- *:Gdb*      jump to the gdb window
493- *:Program*  jump to the window with the running program
494- *:Source*   jump to the window with the source code, create it if there
495            isn't one
496- *:Asm*      jump to the window with the disassembly, create it if there
497            isn't one
498- *:Var*      jump to the window with the local and argument variables,
499            create it if there isn't one.  This window updates whenever the
500            program is stopped
501
502Events ~
503                                                        *termdebug-events*
504Four autocommands can be used: >vim
505    au User TermdebugStartPre  echomsg 'debugging starting'
506    au User TermdebugStartPost echomsg 'debugging started'
507    au User TermdebugStopPre   echomsg 'debugging stopping'
508    au User TermdebugStopPost  echomsg 'debugging stopped'
509<
510- *TermdebugStartPre* Before starting debugging. Not triggered if the debugger
511  is already running or the debugger command cannot be executed.
512- *TermdebugStartPost* After debugging has initialized.
513  If a "!" bang is passed to `:Termdebug` or `:TermdebugCommand` the event is
514  triggered before running the provided command in gdb.
515- *TermdebugStopPre* Before debugging ends, when gdb is terminated, most likely
516  after issuing a "quit" command in the gdb window.
517- *TermdebugStopPost* After debugging has ended, gdb-related windows are closed,
518  debug buffers wiped out and the state before the debugging was restored.
519
520
521Customizing ~
522                                *termdebug-customizing* *g:termdebug_config*
523In the past several global variables were used for configuration.  These are
524deprecated and using the g:termdebug_config dictionary is preferred.  When
525g:termdebug_config exists the other global variables will NOT be used.
526The recommended way is to start with an empty dictionary: >vim
527    let g:termdebug_config = {}
528
529Then you can add entries to the dictionary as mentioned below.  The
530deprecated global variable names are mentioned for completeness.  If you are
531switching over to using g:termdebug_config you can find the old variable name
532and take over the value, then delete the deprecated variable.
533
534
535Prompt mode ~
536                                                *termdebug-prompt*
537When on MS-Windows, gdb will run in a buffer with 'buftype' set to "prompt".
538This works slightly differently:
539- The gdb window will be in Insert mode while typing commands.  Go to Normal
540  mode with <Esc>, then you can move around in the buffer, copy/paste, etc.
541  Go back to editing the gdb command with any command that starts Insert mode,
542  such as `a` or `i`.
543- A separate :terminal window will be opened to run the debugged program in.
544
545                                                *termdebug_use_prompt*
546Prompt mode can be used with: >vim
547    let g:termdebug_config['use_prompt'] = 1
548If there is no g:termdebug_config you can use: >vim
549    let g:termdebug_use_prompt = 1
550<
551Mappings ~
552The termdebug plugin enables a few default mappings.  All those mappings
553are reset to their original values once the termdebug session concludes.
554
555                                        *termdebug_map_K* *termdebug-mappings*
556The K key is normally mapped to |:Evaluate| unless a buffer local (|:map-local|)
557mapping to K already exists.  If you do not want this use: >vim
558    let g:termdebug_config['map_K'] = 0
559If there is no g:termdebug_config you can use: >vim
560    let g:termdebug_map_K = 0
561<
562                                                *termdebug_map_minus*
563The - key is normally mapped to |:Down| unless a buffer local mapping to the -
564key already exists.  If you do not want this use: >vim
565    let g:termdebug_config['map_minus'] = 0
566<
567                                                *termdebug_map_plus*
568The + key is normally mapped to |:Up| unless a buffer local mapping to the +
569key already exists.  If you do not want this use: >vim
570    let g:termdebug_config['map_plus'] = 0
571<
572                                                *termdebug_disasm_window*
573If you want the Asm window shown by default, set the "disasm_window" flag to
5741.  The "disasm_window_height" entry can be used to set the window height: >vim
575    let g:termdebug_config['disasm_window'] = 1
576    let g:termdebug_config['disasm_window_height'] = 15
577If there is no g:termdebug_config you can use: >vim
578    let g:termdebug_disasm_window = 15
579Any value greater than 1 will set the Asm window height to that value.
580If the current window has enough horizontal space, it will be vertically split
581and the Asm window will be shown side by side with the source code window (and
582the height option won't be used).
583
584                                                *termdebug_variables_window*
585If you want the Var window shown by default, set the "variables_window" flag
586to 1.  The "variables_window_height" entry can be used to set the window
587height: >vim
588    let g:termdebug_config['variables_window'] = 1
589    let g:termdebug_config['variables_window_height'] = 15
590If there is no g:termdebug_config you can use: >vim
591    let g:termdebug_variables_window = 15
592Any value greater than 1 will set the Var window height to that value.
593If the current window has enough horizontal space, it will be vertically split
594and the Var window will be shown side by side with the source code window (and
595the height options won't be used).
596
597
598Communication ~
599                                                *termdebug-communication*
600There is another, hidden, buffer, which is used for Vim to communicate with
601gdb.  The buffer name is "gdb communication".  Do not delete this buffer, it
602will break the debugger.
603
604Gdb has some weird behavior, the plugin does its best to work around that.
605For example, after typing "continue" in the gdb window a CTRL-C can be used to
606interrupt the running program.  But after using the MI command
607"-exec-continue"  pressing CTRL-C does not interrupt.  Therefore you will see
608"continue" being used for the `:Continue` command, instead of using the
609communication channel.
610
611
612GDB command ~
613                                                        *g:termdebugger*
614To change the name of the gdb command, set "debugger" entry in
615g:termdebug_config or the "g:termdebugger" variable before invoking
616`:Termdebug`: >vim
617    let g:termdebug_config['command'] = "mygdb"
618If there is no g:termdebug_config you can use: >vim
619    let g:termdebugger = "mygdb"
620
621If the command needs an argument use a List: >vim
622    let g:termdebug_config['command'] = ['rr', 'replay', '--']
623If there is no g:termdebug_config you can use: >vim
624    let g:termdebugger = ['rr', 'replay', '--']
625
626If you are a mouse person, you can also define a mapping using your right
627click to one of the terminal command like evaluate the variable under the
628cursor: >vim
629    nnoremap <RightMouse> :Evaluate<CR>
630or set/unset a breakpoint: >vim
631    nnoremap <RightMouse> :Break<CR>
632
633
634Several arguments will be added to make gdb work well for the debugger.
635If you want to modify them, add a function to filter the argument list: >vim
636    let g:termdebug_config['command_filter'] = MyDebugFilter
637
638If you do not want the arguments to be added, but you do need to set the
639"pty", use a function to add the necessary arguments: >vim
640    let g:termdebug_config['command_add_args'] = MyAddArguments
641The function will be called with the list of arguments so far, and a second
642argument that is the name of the pty.
643                                                        *gdb-version*
644Only debuggers fully compatible with gdb will work.  Vim uses the GDB/MI
645interface.  The "new-ui" command requires gdb version 7.12 or later.  If you
646get this error: >
647    Undefined command: "new-ui". Try "help".
648Then your gdb is too old.
649
650
651Colors ~
652                                        *hl-debugPC* *hl-debugBreakpoint*
653The color of the signs can be adjusted with these highlight groups:
654- debugPC               the current position
655- debugBreakpoint       a breakpoint
656
657The defaults are, when 'background' is "light": >vim
658  hi debugPC term=reverse ctermbg=lightblue guibg=lightblue
659  hi debugBreakpoint term=reverse ctermbg=red guibg=red
660<
661When 'background' is "dark": >vim
662  hi debugPC term=reverse ctermbg=darkblue guibg=darkblue
663  hi debugBreakpoint term=reverse ctermbg=red guibg=red
664<
665
666Shortcuts ~
667                                                        *termdebug_shortcuts*
668You can define your own shortcuts (mappings) to control gdb, that can work in
669any window, using the TermDebugSendCommand() function.  Example: >vim
670    map ,w :call TermDebugSendCommand('where')<CR>
671The argument is the gdb command.
672
673
674Popup menu ~
675                                                        *termdebug_popup*
676By default the Termdebug plugin sets 'mousemodel' to "popup_setpos" and adds
677these entries to the popup menu:
678- Set breakpoint          `:Break`
679- Clear breakpoint        `:Clear`
680- Evaluate                `:Evaluate`
681If you don't want this then disable it with: >vim
682    let g:termdebug_config['popup'] = 0
683If there is no g:termdebug_config you can use: >vim
684    let g:termdebug_popup = 0
685<
686
687Change default signs ~
688                                                        *termdebug_signs*
689Termdebug uses the hex number of the breakpoint ID in the signcolumn to
690represent breakpoints.  If it is greater than "0xFF", then it will be
691displayed as "F+", because there are only two screen cells available for the
692sign.  You may also use decimal breakpoint signs instead, in which case IDs
693greater than 99 will be displayed as "9+".
694
695If you want to customize the breakpoint signs to show `>>` in the signcolumn: >vim
696    let g:termdebug_config['sign'] = '>>'
697You can also specify individual signs for the first several breakpoints: >vim
698    let g:termdebug_config['signs'] = ['>1', '>2', '>3', '>4', '>5', '>6', '>7', '>8', '>9']
699    let g:termdebug_config['sign'] = '>>'
700If you would like to use decimal (base 10) breakpoint signs: >vim
701    let g:termdebug_config['sign_decimal'] = 1
702If the variable g:termdebug_config does not yet exist, you can use: >vim
703    let g:termdebug_config = {'sign': '>>'}
704Likewise, to enable decimal signs: >vim
705    let g:termdebug_config = {'sign_decimal': 1}
706
707
708Vim window width ~
709                                                        *termdebug_wide*
710To change the width of the Vim window when debugging starts and use a vertical
711split: >vim
712    let g:termdebug_config['wide'] = 163
713If there is no g:termdebug_config you can use: >vim
714    let g:termdebug_wide = 163
715
716This will set 'columns' to 163 when `:Termdebug` is used.  The value is
717restored when quitting the debugger.
718
719If the wide value is set and 'columns' is already a greater value, then a
720vertical split will be used without modifying 'columns'.
721
722Set the wide value to 1 to use a vertical split without ever changing
723'columns'.  This is useful when the terminal can't be resized by Vim.
724
725
726 vim:tw=78:ts=8:et:sw=2:ft=help:norl: