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