2017-03-21 09:08:19 -07:00
|
|
|
*terminal_emulator.txt* Nvim
|
2015-03-28 08:33:19 -07:00
|
|
|
|
|
|
|
|
|
|
|
NVIM REFERENCE MANUAL by Thiago de Arruda
|
|
|
|
|
|
|
|
|
2017-05-22 15:25:15 -07:00
|
|
|
Terminal emulator *terminal* *terminal-emulator*
|
2015-03-28 08:33:19 -07:00
|
|
|
|
2017-02-21 07:16:48 -07:00
|
|
|
Nvim embeds a VT220/xterm terminal emulator based on libvterm. The terminal is
|
2019-05-02 00:56:22 -07:00
|
|
|
presented as a special 'buftype', asynchronously updated as data is received
|
|
|
|
from the connected program.
|
2015-03-28 08:33:19 -07:00
|
|
|
|
2017-03-14 16:12:21 -07:00
|
|
|
Terminal buffers behave like normal buffers, except:
|
|
|
|
- With 'modifiable', lines can be edited but not deleted.
|
|
|
|
- 'scrollback' controls how many lines are kept.
|
2021-08-28 08:58:27 -07:00
|
|
|
- Output is followed ("tailed") if cursor is on the last line.
|
2017-03-14 16:12:21 -07:00
|
|
|
- 'modified' is the default. You can set 'nomodified' to avoid a warning when
|
|
|
|
closing the terminal buffer.
|
|
|
|
- 'bufhidden' defaults to "hide".
|
2015-03-28 08:33:19 -07:00
|
|
|
|
2017-10-20 17:33:58 -07:00
|
|
|
Type |gO| to see the table of contents.
|
2017-05-01 08:09:29 -07:00
|
|
|
|
2015-03-28 08:33:19 -07:00
|
|
|
==============================================================================
|
2017-03-14 16:12:21 -07:00
|
|
|
Start *terminal-start*
|
2015-03-28 08:33:19 -07:00
|
|
|
|
2019-05-02 00:56:22 -07:00
|
|
|
There are several ways to create a terminal buffer:
|
2015-03-28 08:33:19 -07:00
|
|
|
|
2022-05-03 06:08:35 -07:00
|
|
|
- Run the |:terminal| command.
|
|
|
|
- Call the |nvim_open_term()| or |termopen()| function.
|
2022-11-22 10:41:00 -07:00
|
|
|
- Edit a "term://" buffer. Examples: >vim
|
2016-07-03 02:21:57 -07:00
|
|
|
:edit term://bash
|
|
|
|
:vsplit term://top
|
2022-05-03 06:08:35 -07:00
|
|
|
|
|
|
|
< Note: To open a "term://" buffer from an autocmd, the |autocmd-nested|
|
2022-11-22 10:41:00 -07:00
|
|
|
modifier is required. >vim
|
2019-03-13 14:13:25 -07:00
|
|
|
autocmd VimEnter * ++nested split term://sh
|
2022-05-03 06:08:35 -07:00
|
|
|
< (This is only mentioned for reference; use |:terminal| instead.)
|
2016-07-03 02:21:57 -07:00
|
|
|
|
2017-03-14 16:12:21 -07:00
|
|
|
When the terminal starts, the buffer contents are updated and the buffer is
|
|
|
|
named in the form of `term://{cwd}//{pid}:{cmd}`. This naming scheme is used
|
|
|
|
by |:mksession| to restore a terminal buffer (by restarting the {cmd}).
|
2015-03-28 08:33:19 -07:00
|
|
|
|
2022-05-03 06:08:35 -07:00
|
|
|
The terminal environment is initialized as in |jobstart-env|.
|
|
|
|
|
2015-03-28 08:33:19 -07:00
|
|
|
==============================================================================
|
2017-03-14 16:12:21 -07:00
|
|
|
Input *terminal-input*
|
2017-02-21 07:16:48 -07:00
|
|
|
|
2022-04-18 02:49:06 -07:00
|
|
|
To send input, enter |Terminal-mode| with |i|, |I|, |a|, |A| or
|
|
|
|
|:startinsert|. In this mode all keys except <C-\> are sent to the underlying
|
2022-07-30 13:07:58 -07:00
|
|
|
program. If <C-\> is pressed, the next key is sent unless it is <C-N> or <C-O>.
|
|
|
|
Use <C-\><C-N> to return to normal mode. |CTRL-\_CTRL-N|
|
|
|
|
Use <C-\><C-O> to execute one normal mode command and then return to terminal
|
|
|
|
mode. *t_CTRL-\_CTRL-O*
|
2017-02-21 07:16:48 -07:00
|
|
|
|
2020-05-04 21:04:47 -07:00
|
|
|
Terminal-mode forces these local options:
|
|
|
|
|
2021-10-06 15:31:14 -07:00
|
|
|
'cursorlineopt' = number
|
2020-05-04 21:04:47 -07:00
|
|
|
'nocursorcolumn'
|
|
|
|
'scrolloff' = 0
|
|
|
|
'sidescrolloff' = 0
|
|
|
|
|
2017-05-11 05:34:48 -07:00
|
|
|
Terminal-mode has its own |:tnoremap| namespace for mappings, this can be used
|
|
|
|
to automate any terminal interaction.
|
|
|
|
|
2022-11-22 10:41:00 -07:00
|
|
|
To map <Esc> to exit terminal-mode: >vim
|
2015-03-28 08:33:19 -07:00
|
|
|
:tnoremap <Esc> <C-\><C-n>
|
2017-05-11 05:34:48 -07:00
|
|
|
|
2022-11-22 10:41:00 -07:00
|
|
|
To simulate |i_CTRL-R| in terminal-mode: >vim
|
2017-05-11 05:34:48 -07:00
|
|
|
:tnoremap <expr> <C-R> '<C-\><C-N>"'.nr2char(getchar()).'pi'
|
|
|
|
|
2022-11-22 10:41:00 -07:00
|
|
|
To use `ALT+{h,j,k,l}` to navigate windows from any mode: >vim
|
2017-05-11 05:34:48 -07:00
|
|
|
:tnoremap <A-h> <C-\><C-N><C-w>h
|
|
|
|
:tnoremap <A-j> <C-\><C-N><C-w>j
|
|
|
|
:tnoremap <A-k> <C-\><C-N><C-w>k
|
|
|
|
:tnoremap <A-l> <C-\><C-N><C-w>l
|
|
|
|
:inoremap <A-h> <C-\><C-N><C-w>h
|
|
|
|
:inoremap <A-j> <C-\><C-N><C-w>j
|
|
|
|
:inoremap <A-k> <C-\><C-N><C-w>k
|
|
|
|
:inoremap <A-l> <C-\><C-N><C-w>l
|
2015-03-28 08:33:19 -07:00
|
|
|
:nnoremap <A-h> <C-w>h
|
|
|
|
:nnoremap <A-j> <C-w>j
|
|
|
|
:nnoremap <A-k> <C-w>k
|
|
|
|
:nnoremap <A-l> <C-w>l
|
|
|
|
|
2022-06-30 02:17:27 -07:00
|
|
|
You can also create menus similar to terminal mode mappings, but you have to
|
|
|
|
use |:tlmenu| instead of |:tmenu|.
|
|
|
|
|
2017-05-11 05:34:48 -07:00
|
|
|
Mouse input has the following behavior:
|
2015-03-28 08:33:19 -07:00
|
|
|
|
|
|
|
- If the program has enabled mouse events, the corresponding events will be
|
|
|
|
forwarded to the program.
|
|
|
|
- If mouse events are disabled (the default), terminal focus will be lost and
|
|
|
|
the event will be processed as in a normal buffer.
|
|
|
|
- If another window is clicked, terminal focus will be lost and nvim will jump
|
|
|
|
to the clicked window
|
|
|
|
- If the mouse wheel is used while the mouse is positioned in another window,
|
2021-12-28 10:15:16 -07:00
|
|
|
the terminal won't lose focus and the hovered window will be scrolled.
|
2015-03-28 08:33:19 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2020-08-31 00:51:35 -07:00
|
|
|
Configuration *terminal-config*
|
2017-02-21 07:16:48 -07:00
|
|
|
|
2017-03-14 16:12:21 -07:00
|
|
|
Options: 'modified', 'scrollback'
|
2019-09-14 15:54:19 -07:00
|
|
|
Events: |TermOpen|, |TermEnter|, |TermLeave|, |TermClose|
|
2017-02-21 07:16:48 -07:00
|
|
|
Highlight groups: |hl-TermCursor|, |hl-TermCursorNC|
|
2015-03-28 08:33:19 -07:00
|
|
|
|
2017-05-22 15:25:15 -07:00
|
|
|
Terminal sets local defaults for some options, which may differ from your
|
|
|
|
global configuration.
|
|
|
|
|
|
|
|
- 'list' is disabled
|
|
|
|
- 'wrap' is disabled
|
|
|
|
|
2022-11-22 10:41:00 -07:00
|
|
|
You can change the defaults with a TermOpen autocommand: >vim
|
2019-05-02 00:56:22 -07:00
|
|
|
au TermOpen * setlocal list
|
2017-05-22 15:25:15 -07:00
|
|
|
|
2017-03-14 16:12:21 -07:00
|
|
|
TERMINAL COLORS ~
|
2015-03-28 08:33:19 -07:00
|
|
|
|
2019-05-02 00:56:22 -07:00
|
|
|
The `{g,b}:terminal_color_x` variables control the terminal color palette,
|
2023-03-21 05:43:40 -07:00
|
|
|
where `x` is the color index between 0 and 15 inclusive. The variables are
|
2019-05-02 00:56:22 -07:00
|
|
|
read during |TermOpen|. The value must be a color name or hexadecimal string.
|
2022-11-22 10:41:00 -07:00
|
|
|
Example: >vim
|
2019-05-02 00:56:22 -07:00
|
|
|
let g:terminal_color_4 = '#ff0000'
|
|
|
|
let g:terminal_color_5 = 'green'
|
|
|
|
Only works for RGB UIs (see 'termguicolors'); for 256-color terminals the
|
|
|
|
color index is just forwarded.
|
|
|
|
|
|
|
|
Editor highlighting (|syntax-highlighting|, |highlight-groups|, etc.) has
|
|
|
|
higher precedence: it is applied after terminal colors are resolved.
|
2015-04-08 04:34:27 -07:00
|
|
|
|
2016-07-10 12:41:07 -07:00
|
|
|
==============================================================================
|
2017-03-14 16:12:21 -07:00
|
|
|
Status Variables *terminal-status*
|
2016-07-10 12:41:07 -07:00
|
|
|
|
2019-06-29 15:09:45 -07:00
|
|
|
Terminal buffers maintain some buffer-local variables and options. The values
|
|
|
|
are initialized before TermOpen, so you can use them in a local 'statusline'.
|
2022-11-22 10:41:00 -07:00
|
|
|
Example: >vim
|
2019-06-29 15:09:45 -07:00
|
|
|
:autocmd TermOpen * setlocal statusline=%{b:term_title}
|
2016-07-10 12:41:07 -07:00
|
|
|
|
2019-06-29 15:09:45 -07:00
|
|
|
- *b:term_title* Terminal title (user-writable), typically displayed in the
|
|
|
|
window title or tab title of a graphical terminal emulator. Terminal
|
|
|
|
programs can set this by emitting an escape sequence.
|
|
|
|
- |'channel'| Terminal PTY |job-id|. Can be used with |chansend()| to send
|
|
|
|
input to the terminal.
|
2021-08-20 10:45:28 -07:00
|
|
|
- The |TermClose| event gives the terminal job exit code in the |v:event|
|
|
|
|
"status" field. For example, this autocmd closes terminal buffers if the job
|
2022-11-22 10:41:00 -07:00
|
|
|
exited without error: >vim
|
2021-08-20 10:45:28 -07:00
|
|
|
autocmd TermClose * if !v:event.status | exe 'bdelete! '..expand('<abuf>') | endif
|
2019-06-29 15:09:45 -07:00
|
|
|
|
2022-11-22 10:41:00 -07:00
|
|
|
Use |jobwait()| to check if the terminal job has finished: >vim
|
2019-07-19 12:32:04 -07:00
|
|
|
let running = jobwait([&channel], 0)[0] == -1
|
2016-07-10 12:41:07 -07:00
|
|
|
|
2015-03-28 08:33:19 -07:00
|
|
|
==============================================================================
|
2019-06-29 15:09:45 -07:00
|
|
|
:Termdebug plugin *terminal-debug*
|
2019-05-16 02:21:05 -07:00
|
|
|
|
|
|
|
The Terminal debugging plugin can be used to debug a program with gdb and view
|
|
|
|
the source code in a Vim window. Since this is completely contained inside
|
|
|
|
Vim this also works remotely over an ssh connection.
|
|
|
|
|
|
|
|
Starting ~
|
|
|
|
*termdebug-starting*
|
2022-11-22 10:41:00 -07:00
|
|
|
Load the plugin with this command: >vim
|
2019-05-16 02:21:05 -07:00
|
|
|
packadd termdebug
|
|
|
|
< *:Termdebug*
|
|
|
|
To start debugging use `:Termdebug` or `:TermdebugCommand` followed by the
|
2022-11-22 10:41:00 -07:00
|
|
|
command name, for example: >vim
|
2019-05-16 02:21:05 -07:00
|
|
|
:Termdebug vim
|
|
|
|
|
|
|
|
This opens two windows:
|
|
|
|
|
|
|
|
gdb window A terminal window in which "gdb vim" is executed. Here you
|
2022-01-23 10:38:41 -07:00
|
|
|
can directly interact with gdb.
|
2019-05-16 02:21:05 -07:00
|
|
|
|
|
|
|
program window A terminal window for the executed program. When "run" is
|
|
|
|
used in gdb the program I/O will happen in this window, so
|
2022-01-23 10:38:41 -07:00
|
|
|
that it does not interfere with controlling gdb.
|
2019-05-16 02:21:05 -07:00
|
|
|
|
|
|
|
The current window is used to show the source code. When gdb pauses the
|
|
|
|
source file location will be displayed, if possible. A sign is used to
|
2021-10-06 15:31:14 -07:00
|
|
|
highlight the current position, using highlight group debugPC.
|
2019-05-16 02:21:05 -07:00
|
|
|
|
|
|
|
If the buffer in the current window is modified, another window will be opened
|
|
|
|
to display the current gdb position.
|
|
|
|
|
|
|
|
Focus the terminal of the executed program to interact with it. This works
|
|
|
|
the same as any command running in a terminal window.
|
|
|
|
|
|
|
|
When the debugger ends, typically by typing "quit" in the gdb window, the two
|
|
|
|
opened windows are closed.
|
|
|
|
|
|
|
|
Only one debugger can be active at a time.
|
|
|
|
*:TermdebugCommand*
|
|
|
|
If you want to give specific commands to the command being debugged, you can
|
|
|
|
use the `:TermdebugCommand` command followed by the command name and
|
2022-11-22 10:41:00 -07:00
|
|
|
additional parameters. >vim
|
2019-05-16 02:21:05 -07:00
|
|
|
:TermdebugCommand vim --clean -c ':set nu'
|
|
|
|
|
|
|
|
Both the `:Termdebug` and `:TermdebugCommand` support an optional "!" bang
|
|
|
|
argument to start the command right away, without pausing at the gdb window
|
2022-11-22 10:41:00 -07:00
|
|
|
(and cursor will be in the debugged window). For example: >vim
|
2019-05-16 02:21:05 -07:00
|
|
|
:TermdebugCommand! vim --clean
|
|
|
|
|
|
|
|
To attach gdb to an already running executable or use a core file, pass extra
|
2022-11-22 10:41:00 -07:00
|
|
|
arguments. E.g.: >vim
|
2019-05-16 02:21:05 -07:00
|
|
|
:Termdebug vim core
|
|
|
|
:Termdebug vim 98343
|
|
|
|
|
|
|
|
If no argument is given, you'll end up in a gdb window, in which you need to
|
|
|
|
specify which command to run using e.g. the gdb `file` command.
|
|
|
|
|
|
|
|
|
|
|
|
Example session ~
|
|
|
|
*termdebug-example*
|
|
|
|
Start in the Vim "src" directory and build Vim: >
|
|
|
|
% make
|
|
|
|
Start Vim: >
|
|
|
|
% ./vim
|
2022-11-22 10:41:00 -07:00
|
|
|
Load the termdebug plugin and start debugging Vim: >vim
|
2019-05-16 02:21:05 -07:00
|
|
|
:packadd termdebug
|
|
|
|
:Termdebug vim
|
|
|
|
You should now have three windows:
|
|
|
|
source - where you started
|
|
|
|
gdb - you can type gdb commands here
|
|
|
|
program - the executed program will use this window
|
|
|
|
|
|
|
|
Put focus on the gdb window and type: >
|
|
|
|
break ex_help
|
|
|
|
run
|
2022-11-22 10:41:00 -07:00
|
|
|
Vim will start running in the program window. Put focus there and type: >vim
|
2019-05-16 02:21:05 -07:00
|
|
|
:help gui
|
2021-10-06 15:31:14 -07:00
|
|
|
Gdb will run into the ex_help breakpoint. The source window now shows the
|
2019-05-16 02:21:05 -07:00
|
|
|
ex_cmds.c file. A red "1 " marker will appear in the signcolumn where the
|
|
|
|
breakpoint was set. The line where the debugger stopped is highlighted. You
|
|
|
|
can now step through the program. You will see the highlighting move as the
|
|
|
|
debugger executes a line of source code.
|
|
|
|
|
|
|
|
Run ":Next" a few times until the for loop is highlighted. Put the cursor on
|
|
|
|
the end of "eap->arg", then call ":Eval". You will see this displayed:
|
|
|
|
"eap->arg": 0x555555e68855 "gui" ~
|
|
|
|
This way you can inspect the value of local variables. You can also focus the
|
|
|
|
gdb window and use a "print" command, e.g.: >
|
|
|
|
print *eap
|
|
|
|
If mouse pointer movements are working, Vim will also show a balloon when the
|
|
|
|
mouse rests on text that can be evaluated by gdb.
|
2023-02-21 09:07:26 -07:00
|
|
|
You can also use the "K" mapping that will either use Nvim floating windows
|
2019-05-16 02:21:05 -07:00
|
|
|
if available to show the results or print below the status bar.
|
|
|
|
|
|
|
|
Now go back to the source window and put the cursor on the first line after
|
|
|
|
the for loop, then type: >
|
|
|
|
:Break
|
|
|
|
You will see a "1" marker appear, this indicates the new breakpoint. Now
|
|
|
|
run ":Cont" command and the code until the breakpoint will be executed.
|
|
|
|
|
|
|
|
You can type more advanced commands in the gdb window. For example, type: >
|
|
|
|
watch curbuf
|
|
|
|
Now run ":Cont" (or type "cont" in the gdb window). Execution
|
|
|
|
will now continue until the value of "curbuf" changes, which is in do_ecmd().
|
|
|
|
To remove this watchpoint again type in the gdb window: >
|
|
|
|
delete 3
|
|
|
|
|
|
|
|
You can see the stack by typing in the gdb window: >
|
|
|
|
where
|
|
|
|
Move through the stack frames, e.g. with: >
|
|
|
|
frame 3
|
|
|
|
The source window will show the code, at the point where the call was made to
|
|
|
|
a deeper level.
|
|
|
|
|
|
|
|
|
|
|
|
Stepping through code ~
|
|
|
|
*termdebug-stepping*
|
|
|
|
Put focus on the gdb window to type commands there. Some common ones are:
|
|
|
|
- CTRL-C interrupt the program
|
|
|
|
- next execute the current line and stop at the next line
|
|
|
|
- step execute the current line and stop at the next statement,
|
|
|
|
entering functions
|
2022-04-19 06:14:17 -07:00
|
|
|
- until execute until past the current cursor line or past a specified
|
|
|
|
position or the current stack frame returns
|
2019-05-16 02:21:05 -07:00
|
|
|
- finish execute until leaving the current function
|
|
|
|
- where show the stack
|
|
|
|
- frame N go to the Nth stack frame
|
|
|
|
- continue continue execution
|
|
|
|
|
|
|
|
*:Run* *:Arguments*
|
|
|
|
In the window showing the source code these commands can be used to control
|
|
|
|
gdb:
|
|
|
|
`:Run` [args] run the program with [args] or the previous arguments
|
|
|
|
`:Arguments` {args} set arguments for the next `:Run`
|
|
|
|
|
|
|
|
*:Break* set a breakpoint at the current line; a sign will be displayed
|
|
|
|
*:Clear* delete the breakpoint at the current line
|
|
|
|
|
|
|
|
*:Step* execute the gdb "step" command
|
|
|
|
*:Over* execute the gdb "next" command (`:Next` is a Vim command)
|
2022-04-19 06:14:17 -07:00
|
|
|
*:Until* execute the gdb "until" command
|
2019-05-16 02:21:05 -07:00
|
|
|
*:Finish* execute the gdb "finish" command
|
|
|
|
*:Continue* execute the gdb "continue" command
|
|
|
|
*:Stop* interrupt the program
|
|
|
|
|
|
|
|
If gdb stops at a source line and there is no window currently showing the
|
|
|
|
source code, a new window will be created for the source code. This also
|
|
|
|
happens if the buffer in the source code window has been modified and can't be
|
|
|
|
abandoned.
|
|
|
|
|
|
|
|
Gdb gives each breakpoint a number. In Vim the number shows up in the sign
|
|
|
|
column, with a red background. You can use these gdb commands:
|
|
|
|
- info break list breakpoints
|
|
|
|
- delete N delete breakpoint N
|
|
|
|
You can also use the `:Clear` command if the cursor is in the line with the
|
|
|
|
breakpoint, or use the "Clear breakpoint" right-click menu entry.
|
|
|
|
|
|
|
|
|
|
|
|
Inspecting variables ~
|
|
|
|
*termdebug-variables* *:Evaluate*
|
|
|
|
`:Evaluate` evaluate the expression under the cursor
|
2022-05-24 19:31:32 -07:00
|
|
|
`K` same (see |termdebug_map_K| to disable)
|
2019-05-16 02:21:05 -07:00
|
|
|
`:Evaluate` {expr} evaluate {expr}
|
|
|
|
`:'<,'>Evaluate` evaluate the Visually selected text
|
|
|
|
|
|
|
|
This is similar to using "print" in the gdb window.
|
|
|
|
You can usually shorten `:Evaluate` to `:Ev`.
|
|
|
|
|
|
|
|
|
|
|
|
Other commands ~
|
|
|
|
*termdebug-commands*
|
|
|
|
*:Gdb* jump to the gdb window
|
|
|
|
*:Program* jump to the window with the running program
|
|
|
|
*:Source* jump to the window with the source code, create it if there
|
|
|
|
isn't one
|
2021-03-10 06:20:22 -07:00
|
|
|
*:Asm* jump to the window with the disassembly, create it if there
|
|
|
|
isn't one
|
2019-05-16 02:21:05 -07:00
|
|
|
|
|
|
|
|
2021-09-12 02:02:33 -07:00
|
|
|
Events ~
|
|
|
|
*termdebug-events*
|
2022-11-22 10:41:00 -07:00
|
|
|
Four autocommands can be used: >vim
|
2021-09-12 02:02:33 -07:00
|
|
|
au User TermdebugStartPre echomsg 'debugging starting'
|
|
|
|
au User TermdebugStartPost echomsg 'debugging started'
|
|
|
|
au User TermdebugStopPre echomsg 'debugging stopping'
|
|
|
|
au User TermdebugStopPost echomsg 'debugging stopped'
|
|
|
|
<
|
|
|
|
*TermdebugStartPre*
|
|
|
|
TermdebugStartPre Before starting debugging.
|
|
|
|
Not triggered if the debugger is already
|
2022-05-24 18:46:19 -07:00
|
|
|
running or the debugger command cannot be
|
2021-09-12 02:02:33 -07:00
|
|
|
executed.
|
|
|
|
*TermdebugStartPost*
|
|
|
|
TermdebugStartPost After debugging has initialized.
|
|
|
|
If a "!" bang is passed to `:Termdebug` or
|
|
|
|
`:TermdebugCommand` the event is triggered
|
|
|
|
before running the provided command in gdb.
|
|
|
|
*TermdebugStopPre*
|
|
|
|
TermdebugStopPre Before debugging ends, when gdb is terminated,
|
|
|
|
most likely after issuing a "quit" command in
|
|
|
|
the gdb window.
|
|
|
|
*TermdebugStopPost*
|
|
|
|
TermdebugStopPost After debugging has ended, gdb-related windows
|
|
|
|
are closed, debug buffers wiped out and
|
|
|
|
the state before the debugging was restored.
|
|
|
|
|
|
|
|
|
2022-11-19 03:31:51 -07:00
|
|
|
Customizing ~
|
|
|
|
*termdebug-customizing* *g:termdebug_config*
|
|
|
|
In the past several global variables were used for configuration. These are
|
|
|
|
deprecated and using the g:termdebug_config dictionary is preferred. When
|
|
|
|
g:termdebug_config exists the other global variables will NOT be used.
|
2022-11-22 10:41:00 -07:00
|
|
|
The recommended way is to start with an empty dictionary: >vim
|
2022-11-19 03:31:51 -07:00
|
|
|
let g:termdebug_config = {}
|
|
|
|
|
|
|
|
Then you can add entries to the dictionary as mentioned below. The
|
|
|
|
deprecated global variable names are mentioned for completeness. If you are
|
|
|
|
switching over to using g:termdebug_config you can find the old variable name
|
|
|
|
and take over the value, then delete the deprecated variable.
|
|
|
|
|
|
|
|
|
2019-05-23 03:30:28 -07:00
|
|
|
Prompt mode ~
|
|
|
|
*termdebug-prompt*
|
|
|
|
When on MS-Windows, gdb will run in a buffer with 'buftype' set to "prompt".
|
|
|
|
This works slightly differently:
|
|
|
|
- The gdb window will be in Insert mode while typing commands. Go to Normal
|
|
|
|
mode with <Esc>, then you can move around in the buffer, copy/paste, etc.
|
|
|
|
Go back to editing the gdb command with any command that starts Insert mode,
|
|
|
|
such as `a` or `i`.
|
2021-07-07 18:51:40 -07:00
|
|
|
- A separate :terminal window will be opened to run the debugged program in.
|
2019-05-23 03:30:28 -07:00
|
|
|
|
|
|
|
*termdebug_use_prompt*
|
2022-11-22 10:41:00 -07:00
|
|
|
Prompt mode can be used with: >vim
|
2022-05-24 18:46:19 -07:00
|
|
|
let g:termdebug_config['use_prompt'] = 1
|
2022-11-22 10:41:00 -07:00
|
|
|
If there is no g:termdebug_config you can use: >vim
|
2019-05-23 03:30:28 -07:00
|
|
|
let g:termdebug_use_prompt = 1
|
2022-05-24 19:31:32 -07:00
|
|
|
<
|
|
|
|
*termdebug_map_K*
|
2022-11-22 10:41:00 -07:00
|
|
|
The K key is normally mapped to :Evaluate. If you do not want this use: >vim
|
2022-05-24 18:46:19 -07:00
|
|
|
let g:termdebug_config['map_K'] = 0
|
2022-11-22 10:41:00 -07:00
|
|
|
If there is no g:termdebug_config you can use: >vim
|
2022-05-24 19:31:32 -07:00
|
|
|
let g:termdebug_map_K = 0
|
2021-03-10 06:20:22 -07:00
|
|
|
<
|
|
|
|
*termdebug_disasm_window*
|
2022-05-24 18:46:19 -07:00
|
|
|
If you want the Asm window shown by default, set the flag to 1.
|
2022-11-22 10:41:00 -07:00
|
|
|
the "disasm_window_height" entry can be used to set the window height: >vim
|
2022-05-24 18:46:19 -07:00
|
|
|
let g:termdebug_config['disasm_window'] = 1
|
|
|
|
let g:termdebug_config['disasm_window_height'] = 15
|
2022-11-22 10:41:00 -07:00
|
|
|
If there is no g:termdebug_config you can use: >vim
|
2021-03-10 06:20:22 -07:00
|
|
|
let g:termdebug_disasm_window = 15
|
2022-06-27 01:23:09 -07:00
|
|
|
Any value greater than 1 will set the Asm window height to that value.
|
2019-05-23 03:30:28 -07:00
|
|
|
|
2019-05-16 02:21:05 -07:00
|
|
|
Communication ~
|
|
|
|
*termdebug-communication*
|
|
|
|
There is another, hidden, buffer, which is used for Vim to communicate with
|
|
|
|
gdb. The buffer name is "gdb communication". Do not delete this buffer, it
|
|
|
|
will break the debugger.
|
|
|
|
|
|
|
|
Gdb has some weird behavior, the plugin does its best to work around that.
|
|
|
|
For example, after typing "continue" in the gdb window a CTRL-C can be used to
|
|
|
|
interrupt the running program. But after using the MI command
|
|
|
|
"-exec-continue" pressing CTRL-C does not interrupt. Therefore you will see
|
|
|
|
"continue" being used for the `:Continue` command, instead of using the
|
|
|
|
communication channel.
|
|
|
|
|
|
|
|
|
2022-05-24 18:46:19 -07:00
|
|
|
GDB command ~
|
2022-05-24 19:31:32 -07:00
|
|
|
*g:termdebugger*
|
2022-05-24 18:46:19 -07:00
|
|
|
To change the name of the gdb command, set "debugger" entry in
|
|
|
|
g:termdebug_config or the "g:termdebugger" variable before invoking
|
2022-11-22 10:41:00 -07:00
|
|
|
`:Termdebug`: >vim
|
2022-05-24 18:46:19 -07:00
|
|
|
let g:termdebug_config['command'] = "mygdb"
|
2022-11-22 10:41:00 -07:00
|
|
|
If there is no g:termdebug_config you can use: >vim
|
2022-05-24 19:31:32 -07:00
|
|
|
let g:termdebugger = "mygdb"
|
2022-05-24 18:46:19 -07:00
|
|
|
|
2022-11-22 10:41:00 -07:00
|
|
|
If the command needs an argument use a List: >vim
|
2022-05-24 18:46:19 -07:00
|
|
|
let g:termdebug_config['command'] = ['rr', 'replay', '--']
|
2022-11-22 10:41:00 -07:00
|
|
|
If there is no g:termdebug_config you can use: >vim
|
2021-12-26 03:03:25 -07:00
|
|
|
let g:termdebugger = ['rr', 'replay', '--']
|
2019-05-16 02:21:05 -07:00
|
|
|
|
2023-02-21 09:07:26 -07:00
|
|
|
To not use Nvim floating windows for previewing variable evaluation, set the
|
2022-11-22 10:41:00 -07:00
|
|
|
`g:termdebug_useFloatingHover` variable like this: >vim
|
2019-05-16 12:58:07 -07:00
|
|
|
let g:termdebug_useFloatingHover = 0
|
2019-05-16 02:21:05 -07:00
|
|
|
|
|
|
|
If you are a mouse person, you can also define a mapping using your right
|
|
|
|
click to one of the terminal command like evaluate the variable under the
|
2022-11-22 10:41:00 -07:00
|
|
|
cursor: >vim
|
2023-02-21 09:07:26 -07:00
|
|
|
nnoremap <RightMouse> :Evaluate<CR>
|
2022-11-22 10:41:00 -07:00
|
|
|
or set/unset a breakpoint: >vim
|
2019-05-16 02:21:05 -07:00
|
|
|
nnoremap <RightMouse> :Break<CR>
|
|
|
|
|
2022-05-24 18:46:19 -07:00
|
|
|
|
|
|
|
Several arguments will be added to make gdb work well for the debugger.
|
2022-11-22 10:41:00 -07:00
|
|
|
If you want to modify them, add a function to filter the argument list: >vim
|
2022-05-24 18:46:19 -07:00
|
|
|
let g:termdebug_config['command_filter'] = MyDebugFilter
|
|
|
|
|
|
|
|
If you do not want the arguments to be added, but you do need to set the
|
2022-11-22 10:41:00 -07:00
|
|
|
"pty", use a function to add the necessary arguments: >vim
|
2022-05-24 18:46:19 -07:00
|
|
|
let g:termdebug_config['command_add_args'] = MyAddArguments
|
|
|
|
The function will be called with the list of arguments so far, and a second
|
|
|
|
argument that is the name of the pty.
|
|
|
|
*gdb-version*
|
2019-05-16 02:21:05 -07:00
|
|
|
Only debuggers fully compatible with gdb will work. Vim uses the GDB/MI
|
|
|
|
interface. The "new-ui" command requires gdb version 7.12 or later. if you
|
|
|
|
get this error:
|
|
|
|
Undefined command: "new-ui". Try "help".~
|
|
|
|
Then your gdb is too old.
|
|
|
|
|
|
|
|
|
2022-06-27 01:23:09 -07:00
|
|
|
Colors ~
|
2022-11-19 03:31:51 -07:00
|
|
|
*hl-debugPC* *hl-debugBreakpoint*
|
2019-05-16 02:21:05 -07:00
|
|
|
The color of the signs can be adjusted with these highlight groups:
|
|
|
|
- debugPC the current position
|
|
|
|
- debugBreakpoint a breakpoint
|
|
|
|
|
|
|
|
The defaults are, when 'background' is "light":
|
|
|
|
hi debugPC term=reverse ctermbg=lightblue guibg=lightblue
|
|
|
|
hi debugBreakpoint term=reverse ctermbg=red guibg=red
|
|
|
|
|
|
|
|
When 'background' is "dark":
|
|
|
|
hi debugPC term=reverse ctermbg=darkblue guibg=darkblue
|
|
|
|
hi debugBreakpoint term=reverse ctermbg=red guibg=red
|
|
|
|
|
|
|
|
|
2022-06-27 01:23:09 -07:00
|
|
|
Shortcuts ~
|
|
|
|
*termdebug_shortcuts*
|
2019-05-16 02:21:05 -07:00
|
|
|
You can define your own shortcuts (mappings) to control gdb, that can work in
|
2022-11-22 10:41:00 -07:00
|
|
|
any window, using the TermDebugSendCommand() function. Example: >vim
|
2019-05-16 02:21:05 -07:00
|
|
|
map ,w :call TermDebugSendCommand('where')<CR>
|
|
|
|
The argument is the gdb command.
|
|
|
|
|
|
|
|
|
2022-07-05 05:57:01 -07:00
|
|
|
Popup menu ~
|
|
|
|
*termdebug_popup*
|
|
|
|
By default the Termdebug plugin sets 'mousemodel' to "popup_setpos" and adds
|
|
|
|
these entries to the popup menu:
|
|
|
|
Set breakpoint `:Break`
|
|
|
|
Clear breakpoint `:Clear`
|
|
|
|
Evaluate `:Evaluate`
|
2022-11-22 10:41:00 -07:00
|
|
|
If you don't want this then disable it with: >vim
|
2022-07-05 05:57:01 -07:00
|
|
|
let g:termdebug_config['popup'] = 0
|
2022-11-22 10:41:00 -07:00
|
|
|
If there is no g:termdebug_config you can use: >vim
|
2022-07-05 05:57:01 -07:00
|
|
|
let g:termdebug_popup = 0
|
|
|
|
|
|
|
|
|
2022-06-27 01:23:09 -07:00
|
|
|
Vim window width ~
|
|
|
|
*termdebug_wide*
|
2022-05-24 19:31:32 -07:00
|
|
|
To change the width of the Vim window when debugging starts and use a vertical
|
2022-11-22 10:41:00 -07:00
|
|
|
split: >vim
|
2022-05-24 18:46:19 -07:00
|
|
|
let g:termdebug_config['wide'] = 163
|
2022-11-22 10:41:00 -07:00
|
|
|
If there is no g:termdebug_config you can use: >vim
|
2022-05-24 19:31:32 -07:00
|
|
|
let g:termdebug_wide = 163
|
|
|
|
|
|
|
|
This will set 'columns' to 163 when `:Termdebug` is used. The value is
|
|
|
|
restored when quitting the debugger.
|
|
|
|
|
2022-05-24 18:46:19 -07:00
|
|
|
If the wide value is set and 'columns' is already a greater value, then a
|
2022-05-24 19:31:32 -07:00
|
|
|
vertical split will be used without modifying 'columns'.
|
2019-05-16 02:21:05 -07:00
|
|
|
|
2022-05-24 18:46:19 -07:00
|
|
|
Set the wide value to 1 to use a vertical split without ever changing
|
2022-05-24 19:31:32 -07:00
|
|
|
'columns'. This is useful when the terminal can't be resized by Vim.
|
2019-05-16 02:21:05 -07:00
|
|
|
|
|
|
|
|
2015-03-28 08:33:19 -07:00
|
|
|
vim:tw=78:ts=8:noet:ft=help:norl:
|