|
|
|
|
@@ -1,10 +1,10 @@
|
|
|
|
|
*terminal.txt* Nvim
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NVIM REFERENCE MANUAL by Thiago de Arruda
|
|
|
|
|
NVIM REFERENCE MANUAL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Terminal emulator *terminal* *terminal-emulator*
|
|
|
|
|
Terminal emulator *terminal* *terminal-emulator*
|
|
|
|
|
|
|
|
|
|
Nvim embeds a VT220/xterm terminal emulator based on libvterm. The terminal is
|
|
|
|
|
presented as a special 'buftype', asynchronously updated as data is received
|
|
|
|
|
@@ -18,10 +18,10 @@ Terminal buffers behave like normal buffers, except:
|
|
|
|
|
closing the terminal buffer.
|
|
|
|
|
- 'bufhidden' defaults to "hide".
|
|
|
|
|
|
|
|
|
|
Type |gO| to see the table of contents.
|
|
|
|
|
Type |gO| to see the table of contents.
|
|
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
|
Start *terminal-start*
|
|
|
|
|
Start *terminal-start*
|
|
|
|
|
|
|
|
|
|
There are several ways to create a terminal buffer:
|
|
|
|
|
|
|
|
|
|
@@ -43,7 +43,7 @@ by |:mksession| to restore a terminal buffer (by restarting the {cmd}).
|
|
|
|
|
The terminal environment is initialized as in |jobstart-env|.
|
|
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
|
Input *terminal-input*
|
|
|
|
|
Input *terminal-input*
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
@@ -54,10 +54,10 @@ mode. *t_CTRL-\_CTRL-O*
|
|
|
|
|
|
|
|
|
|
Terminal-mode forces these local options:
|
|
|
|
|
|
|
|
|
|
'cursorlineopt' = number
|
|
|
|
|
'nocursorcolumn'
|
|
|
|
|
'scrolloff' = 0
|
|
|
|
|
'sidescrolloff' = 0
|
|
|
|
|
- 'cursorlineopt' = number
|
|
|
|
|
- 'nocursorcolumn'
|
|
|
|
|
- 'scrolloff' = 0
|
|
|
|
|
- 'sidescrolloff' = 0
|
|
|
|
|
|
|
|
|
|
Terminal-mode has its own |:tnoremap| namespace for mappings, this can be used
|
|
|
|
|
to automate any terminal interaction.
|
|
|
|
|
@@ -97,11 +97,12 @@ Mouse input has the following behavior:
|
|
|
|
|
the terminal won't lose focus and the hovered window will be scrolled.
|
|
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
|
Configuration *terminal-config*
|
|
|
|
|
Configuration *terminal-config*
|
|
|
|
|
|
|
|
|
|
Options: 'modified', 'scrollback'
|
|
|
|
|
Events: |TermOpen|, |TermEnter|, |TermLeave|, |TermClose|
|
|
|
|
|
Highlight groups: |hl-TermCursor|
|
|
|
|
|
- Options: 'modified', 'scrollback'
|
|
|
|
|
- Events: |TermOpen|, |TermEnter|, |TermLeave|, |TermClose|
|
|
|
|
|
- Event groups: "nvim.terminal" |default-autocmds|
|
|
|
|
|
- Highlight groups: |hl-TermCursor|
|
|
|
|
|
|
|
|
|
|
Terminal sets local defaults for some options, which may differ from your
|
|
|
|
|
global configuration.
|
|
|
|
|
@@ -114,7 +115,13 @@ global configuration.
|
|
|
|
|
- 'foldcolumn' is set to "0"
|
|
|
|
|
|
|
|
|
|
You can change the defaults with a TermOpen autocommand: >vim
|
|
|
|
|
au TermOpen * setlocal list
|
|
|
|
|
:autocmd TermOpen * setlocal list
|
|
|
|
|
|
|
|
|
|
By default, "[Process exited]" is displayed when the terminal process ends. To
|
|
|
|
|
disable that, you can delete the "nvim.terminal" TermClose handler (this also
|
|
|
|
|
deletes other |default-autocmds| TermClose functionality): >vim
|
|
|
|
|
:autocmd! nvim.terminal TermClose
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
TERMINAL COLORS ~
|
|
|
|
|
|
|
|
|
|
@@ -131,12 +138,12 @@ Editor highlighting (|syntax-highlighting|, |highlight-groups|, etc.) has
|
|
|
|
|
higher precedence: it is applied after terminal colors are resolved.
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
|
|
|
|
EVENTS *terminal-events*
|
|
|
|
|
EVENTS *terminal-events*
|
|
|
|
|
|
|
|
|
|
Applications running in a :terminal buffer can send requests, which Nvim
|
|
|
|
|
exposes via the |TermRequest| event.
|
|
|
|
|
|
|
|
|
|
OSC 7: change working directory *terminal-osc7*
|
|
|
|
|
OSC 7: change working directory *terminal-osc7*
|
|
|
|
|
|
|
|
|
|
Shells can emit the "OSC 7" sequence to announce when the current directory
|
|
|
|
|
(CWD) changed.
|
|
|
|
|
@@ -178,7 +185,7 @@ this command in a :terminal buffer: >
|
|
|
|
|
|
|
|
|
|
printf "\033]7;file://./foo/bar\033\\"
|
|
|
|
|
|
|
|
|
|
OSC 52: write to system clipboard *terminal-osc52*
|
|
|
|
|
OSC 52: write to system clipboard *terminal-osc52*
|
|
|
|
|
|
|
|
|
|
Applications in the :terminal buffer can write to the system clipboard by
|
|
|
|
|
emitting an OSC 52 sequence. Example: >
|
|
|
|
|
@@ -193,7 +200,7 @@ clipboard.
|
|
|
|
|
OSC 52 sequences sent from the :terminal buffer do not emit a |TermRequest|
|
|
|
|
|
event. The event is handled directly by Nvim and is not forwarded to plugins.
|
|
|
|
|
|
|
|
|
|
OSC 133: shell integration *terminal-osc133* *shell-prompt*
|
|
|
|
|
OSC 133: shell integration *terminal-osc133* *shell-prompt*
|
|
|
|
|
|
|
|
|
|
Shells can emit semantic escape sequences (OSC 133) to mark where each prompt
|
|
|
|
|
starts and ends. The start of a prompt is marked by sequence `OSC 133 ; A ST`,
|
|
|
|
|
@@ -217,7 +224,7 @@ To configure bash to mark the start of each prompt, set $PROMPT_COMMAND: >bash
|
|
|
|
|
The |]]| and |[[| motions jump to the next/previous prompts, if your shell
|
|
|
|
|
emits OSC 133 as described above.
|
|
|
|
|
|
|
|
|
|
*shell-prompt-signs*
|
|
|
|
|
*shell-prompt-signs*
|
|
|
|
|
To annotate each terminal prompt with a sign, call |nvim_buf_set_extmark()|
|
|
|
|
|
from a |TermRequest| handler: >lua
|
|
|
|
|
|
|
|
|
|
@@ -238,7 +245,7 @@ from a |TermRequest| handler: >lua
|
|
|
|
|
})
|
|
|
|
|
<
|
|
|
|
|
==============================================================================
|
|
|
|
|
Status Variables *terminal-status*
|
|
|
|
|
Status Variables *terminal-status*
|
|
|
|
|
|
|
|
|
|
Terminal buffers maintain some buffer-local variables and options. The values
|
|
|
|
|
are initialized before TermOpen, so you can use them in a local 'statusline'.
|
|
|
|
|
@@ -259,32 +266,31 @@ Use |jobwait()| to check if the terminal job has finished: >vim
|
|
|
|
|
let running = jobwait([&channel], 0)[0] == -1
|
|
|
|
|
<
|
|
|
|
|
==============================================================================
|
|
|
|
|
:Termdebug plugin *terminal-debug* *terminal-debugger*
|
|
|
|
|
*package-termdebug* *termdebug*
|
|
|
|
|
:Termdebug plugin *terminal-debug* *terminal-debugger*
|
|
|
|
|
*package-termdebug* *termdebug*
|
|
|
|
|
|
|
|
|
|
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*
|
|
|
|
|
*termdebug-starting*
|
|
|
|
|
Load the plugin with this command: >vim
|
|
|
|
|
packadd termdebug
|
|
|
|
|
packadd termdebug
|
|
|
|
|
When loading the plugin from the |vimrc| file, add the "!" attribute: >vim
|
|
|
|
|
packadd! termdebug
|
|
|
|
|
< *:Termdebug*
|
|
|
|
|
packadd! termdebug
|
|
|
|
|
< *:Termdebug*
|
|
|
|
|
To start debugging use `:Termdebug` or `:TermdebugCommand` followed by the
|
|
|
|
|
command name, for example: >vim
|
|
|
|
|
:Termdebug vim
|
|
|
|
|
:Termdebug vim
|
|
|
|
|
|
|
|
|
|
This opens two windows:
|
|
|
|
|
|
|
|
|
|
gdb window A terminal window in which "gdb vim" is executed. Here you
|
|
|
|
|
can directly interact with gdb.
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
that it does not interfere with controlling gdb.
|
|
|
|
|
- gdb window: A terminal window in which "gdb vim" is executed. Here you can
|
|
|
|
|
directly interact with gdb.
|
|
|
|
|
- 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 that it does not
|
|
|
|
|
interfere with controlling gdb.
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
@@ -300,45 +306,45 @@ 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*
|
|
|
|
|
*: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
|
|
|
|
|
additional parameters. >vim
|
|
|
|
|
:TermdebugCommand vim --clean -c ':set nu'
|
|
|
|
|
: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
|
|
|
|
|
(and cursor will be in the debugged window). For example: >vim
|
|
|
|
|
:TermdebugCommand! vim --clean
|
|
|
|
|
:TermdebugCommand! vim --clean
|
|
|
|
|
|
|
|
|
|
To attach gdb to an already running executable or use a core file, pass extra
|
|
|
|
|
arguments. E.g.: >vim
|
|
|
|
|
:Termdebug vim core
|
|
|
|
|
:Termdebug vim 98343
|
|
|
|
|
: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*
|
|
|
|
|
*termdebug-example*
|
|
|
|
|
Start in the Vim "src" directory and build Vim: >
|
|
|
|
|
% make
|
|
|
|
|
% make
|
|
|
|
|
Start Vim: >
|
|
|
|
|
% ./vim
|
|
|
|
|
% ./vim
|
|
|
|
|
Load the termdebug plugin and start debugging Vim: >vim
|
|
|
|
|
:packadd termdebug
|
|
|
|
|
:Termdebug vim
|
|
|
|
|
: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
|
|
|
|
|
- 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
|
|
|
|
|
break ex_help
|
|
|
|
|
run
|
|
|
|
|
Vim will start running in the program window. Put focus there and type: >vim
|
|
|
|
|
:help gui
|
|
|
|
|
:help gui
|
|
|
|
|
Gdb will run into the ex_help breakpoint. The source window now shows the
|
|
|
|
|
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
|
|
|
|
|
@@ -346,11 +352,11 @@ can now step through the program. You will see the highlighting move as the
|
|
|
|
|
debugger executes a line of source code.
|
|
|
|
|
|
|
|
|
|
Run |:Over| 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" ~
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
You can also use the "K" mapping that will either use Nvim floating windows
|
|
|
|
|
@@ -358,73 +364,71 @@ to show the results.
|
|
|
|
|
|
|
|
|
|
Now go back to the source window and put the cursor on the first line after
|
|
|
|
|
the for loop, then type: >
|
|
|
|
|
:Break
|
|
|
|
|
: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
|
|
|
|
|
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
|
|
|
|
|
delete 3
|
|
|
|
|
|
|
|
|
|
You can see the stack by typing in the gdb window: >
|
|
|
|
|
where
|
|
|
|
|
where
|
|
|
|
|
Move through the stack frames, e.g. with: >
|
|
|
|
|
frame 3
|
|
|
|
|
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*
|
|
|
|
|
*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
|
|
|
|
|
- until execute until past the current cursor line or past a specified
|
|
|
|
|
position or the current stack frame returns
|
|
|
|
|
- finish execute until leaving the current function
|
|
|
|
|
- where show the stack
|
|
|
|
|
- frame N go to the Nth stack frame
|
|
|
|
|
- continue continue execution
|
|
|
|
|
- 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
|
|
|
|
|
- until: execute until past the current cursor line or past a specified
|
|
|
|
|
position or the current stack frame returns
|
|
|
|
|
- finish: execute until leaving the current function
|
|
|
|
|
- where: show the stack
|
|
|
|
|
- frame N: go to the Nth stack frame
|
|
|
|
|
- continue: continue execution
|
|
|
|
|
|
|
|
|
|
*:Run* *:Arguments*
|
|
|
|
|
*: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`
|
|
|
|
|
- `: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 cursor position
|
|
|
|
|
:Break [{position}] [thread {nr}] [if {expr}]
|
|
|
|
|
set a breakpoint at the specified position
|
|
|
|
|
if {position} is omitted, use the current file and line
|
|
|
|
|
thread {nr} limits the breakpoint to one thread
|
|
|
|
|
if {expr} sets a conditional breakpoint
|
|
|
|
|
Examples: >
|
|
|
|
|
:Break if argc == 1
|
|
|
|
|
:Break 42 thread 3 if x > 10
|
|
|
|
|
:Break main
|
|
|
|
|
- *:Break* set a breakpoint at the cursor position
|
|
|
|
|
- :Break [{position}] [thread {nr}] [if {expr}]
|
|
|
|
|
set a breakpoint at the specified position if {position} is omitted, use the
|
|
|
|
|
current file and line thread {nr} limits the breakpoint to one thread if
|
|
|
|
|
{expr} sets a conditional breakpoint.
|
|
|
|
|
Examples: >
|
|
|
|
|
:Break if argc == 1
|
|
|
|
|
:Break 42 thread 3 if x > 10
|
|
|
|
|
:Break main
|
|
|
|
|
<
|
|
|
|
|
*:Tbreak* set a temporary breakpoint at the cursor position
|
|
|
|
|
:Tbreak [{position}] [thread {nr}] [if {expr}]
|
|
|
|
|
like `:Break`, but the breakpoint is deleted after
|
|
|
|
|
it is hit once
|
|
|
|
|
Examples: >
|
|
|
|
|
:Tbreak if argc == 1
|
|
|
|
|
:Tbreak 42 thread 3 if x > 10
|
|
|
|
|
:Tbreak main
|
|
|
|
|
- *:Tbreak* set a temporary breakpoint at the cursor position
|
|
|
|
|
- :Tbreak [{position}] [thread {nr}] [if {expr}]
|
|
|
|
|
like `:Break`, but the breakpoint is deleted after it is hit once.
|
|
|
|
|
Examples: >
|
|
|
|
|
:Tbreak if argc == 1
|
|
|
|
|
:Tbreak 42 thread 3 if x > 10
|
|
|
|
|
:Tbreak main
|
|
|
|
|
<
|
|
|
|
|
*:Clear* delete the breakpoint at the cursor position
|
|
|
|
|
- *:Clear* delete the breakpoint at the cursor position
|
|
|
|
|
|
|
|
|
|
*:Step* execute the gdb "step" command
|
|
|
|
|
*:Over* execute the gdb "next" command (`:Next` is a Vim command)
|
|
|
|
|
*:Until* execute the gdb "until" command
|
|
|
|
|
*:Finish* execute the gdb "finish" command
|
|
|
|
|
*:Continue* execute the gdb "continue" command
|
|
|
|
|
*:Stop* interrupt the program
|
|
|
|
|
- *:Step* execute the gdb "step" command
|
|
|
|
|
- *:Over* execute the gdb "next" command (`:Next` is a Vim command)
|
|
|
|
|
- *:Until* execute the gdb "until" command
|
|
|
|
|
- *: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
|
|
|
|
|
@@ -433,18 +437,18 @@ 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
|
|
|
|
|
- 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
|
|
|
|
|
`K` same (see |termdebug_map_K| to disable)
|
|
|
|
|
`:Evaluate` {expr} evaluate {expr}
|
|
|
|
|
`:'<,'>Evaluate` evaluate the Visually selected text
|
|
|
|
|
*termdebug-variables* *:Evaluate*
|
|
|
|
|
- `:Evaluate` evaluate the expression under the cursor
|
|
|
|
|
- `K` same (see |termdebug_map_K| to disable)
|
|
|
|
|
- `: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`.
|
|
|
|
|
@@ -453,64 +457,55 @@ You can move the cursor to this window by running `:Evaluate` (or `K`) again.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Navigating stack frames ~
|
|
|
|
|
*termdebug-frames* *:Frame* *:Up* *:Down*
|
|
|
|
|
`:Frame` [frame] select frame [frame], which is a frame number,
|
|
|
|
|
address, or function name (default: current frame)
|
|
|
|
|
`:Up` [count] go up [count] frames (default: 1; the frame that
|
|
|
|
|
called the current)
|
|
|
|
|
`+` same (see |termdebug_map_plus| to disable)
|
|
|
|
|
`:Down` [count] go down [count] frames (default: 1; the frame called
|
|
|
|
|
by the current)
|
|
|
|
|
`-` same (see |termdebug_map_minus| to disable)
|
|
|
|
|
*termdebug-frames* *:Frame* *:Up* *:Down*
|
|
|
|
|
- `:Frame` [frame] select frame [frame], which is a frame number,
|
|
|
|
|
address, or function name (default: current frame)
|
|
|
|
|
- `:Up` [count] go up [count] frames (default: 1; the frame that
|
|
|
|
|
called the current)
|
|
|
|
|
- `+` same (see |termdebug_map_plus| to disable)
|
|
|
|
|
- `:Down` [count] go down [count] frames (default: 1; the frame called
|
|
|
|
|
by the current)
|
|
|
|
|
- `-` same (see |termdebug_map_minus| to disable)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
*:Asm* jump to the window with the disassembly, create it if there
|
|
|
|
|
isn't one
|
|
|
|
|
*:Var* jump to the window with the local and argument variables,
|
|
|
|
|
create it if there isn't one. This window updates whenever the
|
|
|
|
|
program is stopped
|
|
|
|
|
*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
|
|
|
|
|
- *:Asm* jump to the window with the disassembly, create it if there
|
|
|
|
|
isn't one
|
|
|
|
|
- *:Var* jump to the window with the local and argument variables,
|
|
|
|
|
create it if there isn't one. This window updates whenever the
|
|
|
|
|
program is stopped
|
|
|
|
|
|
|
|
|
|
Events ~
|
|
|
|
|
*termdebug-events*
|
|
|
|
|
*termdebug-events*
|
|
|
|
|
Four autocommands can be used: >vim
|
|
|
|
|
au User TermdebugStartPre echomsg 'debugging starting'
|
|
|
|
|
au User TermdebugStartPost echomsg 'debugging started'
|
|
|
|
|
au User TermdebugStopPre echomsg 'debugging stopping'
|
|
|
|
|
au User TermdebugStopPost echomsg 'debugging stopped'
|
|
|
|
|
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
|
|
|
|
|
running or the debugger command cannot be
|
|
|
|
|
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.
|
|
|
|
|
- *TermdebugStartPre* Before starting debugging. Not triggered if the debugger
|
|
|
|
|
is already running or the debugger command cannot be executed.
|
|
|
|
|
- *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* Before debugging ends, when gdb is terminated, most likely
|
|
|
|
|
after issuing a "quit" command in the gdb window.
|
|
|
|
|
- *TermdebugStopPost* After debugging has ended, gdb-related windows are closed,
|
|
|
|
|
debug buffers wiped out and the state before the debugging was restored.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Customizing ~
|
|
|
|
|
*termdebug-customizing* *g:termdebug_config*
|
|
|
|
|
*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.
|
|
|
|
|
The recommended way is to start with an empty dictionary: >vim
|
|
|
|
|
let g:termdebug_config = {}
|
|
|
|
|
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
|
|
|
|
|
@@ -519,7 +514,7 @@ and take over the value, then delete the deprecated variable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Prompt mode ~
|
|
|
|
|
*termdebug-prompt*
|
|
|
|
|
*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
|
|
|
|
|
@@ -528,53 +523,53 @@ This works slightly differently:
|
|
|
|
|
such as `a` or `i`.
|
|
|
|
|
- A separate :terminal window will be opened to run the debugged program in.
|
|
|
|
|
|
|
|
|
|
*termdebug_use_prompt*
|
|
|
|
|
*termdebug_use_prompt*
|
|
|
|
|
Prompt mode can be used with: >vim
|
|
|
|
|
let g:termdebug_config['use_prompt'] = 1
|
|
|
|
|
let g:termdebug_config['use_prompt'] = 1
|
|
|
|
|
If there is no g:termdebug_config you can use: >vim
|
|
|
|
|
let g:termdebug_use_prompt = 1
|
|
|
|
|
let g:termdebug_use_prompt = 1
|
|
|
|
|
<
|
|
|
|
|
Mappings ~
|
|
|
|
|
The termdebug plugin enables a few default mappings. All those mappings
|
|
|
|
|
are reset to their original values once the termdebug session concludes.
|
|
|
|
|
|
|
|
|
|
*termdebug_map_K* *termdebug-mappings*
|
|
|
|
|
*termdebug_map_K* *termdebug-mappings*
|
|
|
|
|
The K key is normally mapped to |:Evaluate| unless a buffer local (|:map-local|)
|
|
|
|
|
mapping to K already exists. If you do not want this use: >vim
|
|
|
|
|
let g:termdebug_config['map_K'] = 0
|
|
|
|
|
let g:termdebug_config['map_K'] = 0
|
|
|
|
|
If there is no g:termdebug_config you can use: >vim
|
|
|
|
|
let g:termdebug_map_K = 0
|
|
|
|
|
let g:termdebug_map_K = 0
|
|
|
|
|
<
|
|
|
|
|
*termdebug_map_minus*
|
|
|
|
|
*termdebug_map_minus*
|
|
|
|
|
The - key is normally mapped to |:Down| unless a buffer local mapping to the -
|
|
|
|
|
key already exists. If you do not want this use: >vim
|
|
|
|
|
let g:termdebug_config['map_minus'] = 0
|
|
|
|
|
let g:termdebug_config['map_minus'] = 0
|
|
|
|
|
<
|
|
|
|
|
*termdebug_map_plus*
|
|
|
|
|
*termdebug_map_plus*
|
|
|
|
|
The + key is normally mapped to |:Up| unless a buffer local mapping to the +
|
|
|
|
|
key already exists. If you do not want this use: >vim
|
|
|
|
|
let g:termdebug_config['map_plus'] = 0
|
|
|
|
|
let g:termdebug_config['map_plus'] = 0
|
|
|
|
|
<
|
|
|
|
|
*termdebug_disasm_window*
|
|
|
|
|
*termdebug_disasm_window*
|
|
|
|
|
If you want the Asm window shown by default, set the "disasm_window" flag to
|
|
|
|
|
1. The "disasm_window_height" entry can be used to set the window height: >vim
|
|
|
|
|
let g:termdebug_config['disasm_window'] = 1
|
|
|
|
|
let g:termdebug_config['disasm_window_height'] = 15
|
|
|
|
|
let g:termdebug_config['disasm_window'] = 1
|
|
|
|
|
let g:termdebug_config['disasm_window_height'] = 15
|
|
|
|
|
If there is no g:termdebug_config you can use: >vim
|
|
|
|
|
let g:termdebug_disasm_window = 15
|
|
|
|
|
let g:termdebug_disasm_window = 15
|
|
|
|
|
Any value greater than 1 will set the Asm window height to that value.
|
|
|
|
|
If the current window has enough horizontal space, it will be vertically split
|
|
|
|
|
and the Asm window will be shown side by side with the source code window (and
|
|
|
|
|
the height option won't be used).
|
|
|
|
|
|
|
|
|
|
*termdebug_variables_window*
|
|
|
|
|
*termdebug_variables_window*
|
|
|
|
|
If you want the Var window shown by default, set the "variables_window" flag
|
|
|
|
|
to 1. The "variables_window_height" entry can be used to set the window
|
|
|
|
|
height: >vim
|
|
|
|
|
let g:termdebug_config['variables_window'] = 1
|
|
|
|
|
let g:termdebug_config['variables_window_height'] = 15
|
|
|
|
|
let g:termdebug_config['variables_window'] = 1
|
|
|
|
|
let g:termdebug_config['variables_window_height'] = 15
|
|
|
|
|
If there is no g:termdebug_config you can use: >vim
|
|
|
|
|
let g:termdebug_variables_window = 15
|
|
|
|
|
let g:termdebug_variables_window = 15
|
|
|
|
|
Any value greater than 1 will set the Var window height to that value.
|
|
|
|
|
If the current window has enough horizontal space, it will be vertically split
|
|
|
|
|
and the Var window will be shown side by side with the source code window (and
|
|
|
|
|
@@ -582,7 +577,7 @@ the height options won't be used).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Communication ~
|
|
|
|
|
*termdebug-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.
|
|
|
|
|
@@ -596,82 +591,82 @@ communication channel.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GDB command ~
|
|
|
|
|
*g:termdebugger*
|
|
|
|
|
*g:termdebugger*
|
|
|
|
|
To change the name of the gdb command, set "debugger" entry in
|
|
|
|
|
g:termdebug_config or the "g:termdebugger" variable before invoking
|
|
|
|
|
`:Termdebug`: >vim
|
|
|
|
|
let g:termdebug_config['command'] = "mygdb"
|
|
|
|
|
let g:termdebug_config['command'] = "mygdb"
|
|
|
|
|
If there is no g:termdebug_config you can use: >vim
|
|
|
|
|
let g:termdebugger = "mygdb"
|
|
|
|
|
let g:termdebugger = "mygdb"
|
|
|
|
|
|
|
|
|
|
If the command needs an argument use a List: >vim
|
|
|
|
|
let g:termdebug_config['command'] = ['rr', 'replay', '--']
|
|
|
|
|
let g:termdebug_config['command'] = ['rr', 'replay', '--']
|
|
|
|
|
If there is no g:termdebug_config you can use: >vim
|
|
|
|
|
let g:termdebugger = ['rr', 'replay', '--']
|
|
|
|
|
let g:termdebugger = ['rr', 'replay', '--']
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
cursor: >vim
|
|
|
|
|
nnoremap <RightMouse> :Evaluate<CR>
|
|
|
|
|
nnoremap <RightMouse> :Evaluate<CR>
|
|
|
|
|
or set/unset a breakpoint: >vim
|
|
|
|
|
nnoremap <RightMouse> :Break<CR>
|
|
|
|
|
nnoremap <RightMouse> :Break<CR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Several arguments will be added to make gdb work well for the debugger.
|
|
|
|
|
If you want to modify them, add a function to filter the argument list: >vim
|
|
|
|
|
let g:termdebug_config['command_filter'] = MyDebugFilter
|
|
|
|
|
let g:termdebug_config['command_filter'] = MyDebugFilter
|
|
|
|
|
|
|
|
|
|
If you do not want the arguments to be added, but you do need to set the
|
|
|
|
|
"pty", use a function to add the necessary arguments: >vim
|
|
|
|
|
let g:termdebug_config['command_add_args'] = MyAddArguments
|
|
|
|
|
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*
|
|
|
|
|
*gdb-version*
|
|
|
|
|
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".~
|
|
|
|
|
get this error: >
|
|
|
|
|
Undefined command: "new-ui". Try "help".
|
|
|
|
|
Then your gdb is too old.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Colors ~
|
|
|
|
|
*hl-debugPC* *hl-debugBreakpoint*
|
|
|
|
|
*hl-debugPC* *hl-debugBreakpoint*
|
|
|
|
|
The color of the signs can be adjusted with these highlight groups:
|
|
|
|
|
- debugPC the current position
|
|
|
|
|
- debugBreakpoint a breakpoint
|
|
|
|
|
- debugPC the current position
|
|
|
|
|
- debugBreakpoint a breakpoint
|
|
|
|
|
|
|
|
|
|
The defaults are, when 'background' is "light":
|
|
|
|
|
The defaults are, when 'background' is "light": >vim
|
|
|
|
|
hi debugPC term=reverse ctermbg=lightblue guibg=lightblue
|
|
|
|
|
hi debugBreakpoint term=reverse ctermbg=red guibg=red
|
|
|
|
|
|
|
|
|
|
When 'background' is "dark":
|
|
|
|
|
<
|
|
|
|
|
When 'background' is "dark": >vim
|
|
|
|
|
hi debugPC term=reverse ctermbg=darkblue guibg=darkblue
|
|
|
|
|
hi debugBreakpoint term=reverse ctermbg=red guibg=red
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
Shortcuts ~
|
|
|
|
|
*termdebug_shortcuts*
|
|
|
|
|
*termdebug_shortcuts*
|
|
|
|
|
You can define your own shortcuts (mappings) to control gdb, that can work in
|
|
|
|
|
any window, using the TermDebugSendCommand() function. Example: >vim
|
|
|
|
|
map ,w :call TermDebugSendCommand('where')<CR>
|
|
|
|
|
map ,w :call TermDebugSendCommand('where')<CR>
|
|
|
|
|
The argument is the gdb command.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Popup menu ~
|
|
|
|
|
*termdebug_popup*
|
|
|
|
|
*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`
|
|
|
|
|
- Set breakpoint `:Break`
|
|
|
|
|
- Clear breakpoint `:Clear`
|
|
|
|
|
- Evaluate `:Evaluate`
|
|
|
|
|
If you don't want this then disable it with: >vim
|
|
|
|
|
let g:termdebug_config['popup'] = 0
|
|
|
|
|
let g:termdebug_config['popup'] = 0
|
|
|
|
|
If there is no g:termdebug_config you can use: >vim
|
|
|
|
|
let g:termdebug_popup = 0
|
|
|
|
|
|
|
|
|
|
let g:termdebug_popup = 0
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
Change default signs ~
|
|
|
|
|
*termdebug_signs*
|
|
|
|
|
*termdebug_signs*
|
|
|
|
|
Termdebug uses the hex number of the breakpoint ID in the signcolumn to
|
|
|
|
|
represent breakpoints. If it is greater than "0xFF", then it will be
|
|
|
|
|
displayed as "F+", because there are only two screen cells available for the
|
|
|
|
|
@@ -679,25 +674,25 @@ sign. You may also use decimal breakpoint signs instead, in which case IDs
|
|
|
|
|
greater than 99 will be displayed as "9+".
|
|
|
|
|
|
|
|
|
|
If you want to customize the breakpoint signs to show `>>` in the signcolumn: >vim
|
|
|
|
|
let g:termdebug_config['sign'] = '>>'
|
|
|
|
|
let g:termdebug_config['sign'] = '>>'
|
|
|
|
|
You can also specify individual signs for the first several breakpoints: >vim
|
|
|
|
|
let g:termdebug_config['signs'] = ['>1', '>2', '>3', '>4', '>5', '>6', '>7', '>8', '>9']
|
|
|
|
|
let g:termdebug_config['sign'] = '>>'
|
|
|
|
|
let g:termdebug_config['signs'] = ['>1', '>2', '>3', '>4', '>5', '>6', '>7', '>8', '>9']
|
|
|
|
|
let g:termdebug_config['sign'] = '>>'
|
|
|
|
|
If you would like to use decimal (base 10) breakpoint signs: >vim
|
|
|
|
|
let g:termdebug_config['sign_decimal'] = 1
|
|
|
|
|
let g:termdebug_config['sign_decimal'] = 1
|
|
|
|
|
If the variable g:termdebug_config does not yet exist, you can use: >vim
|
|
|
|
|
let g:termdebug_config = {'sign': '>>'}
|
|
|
|
|
let g:termdebug_config = {'sign': '>>'}
|
|
|
|
|
Likewise, to enable decimal signs: >vim
|
|
|
|
|
let g:termdebug_config = {'sign_decimal': 1}
|
|
|
|
|
let g:termdebug_config = {'sign_decimal': 1}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vim window width ~
|
|
|
|
|
*termdebug_wide*
|
|
|
|
|
*termdebug_wide*
|
|
|
|
|
To change the width of the Vim window when debugging starts and use a vertical
|
|
|
|
|
split: >vim
|
|
|
|
|
let g:termdebug_config['wide'] = 163
|
|
|
|
|
let g:termdebug_config['wide'] = 163
|
|
|
|
|
If there is no g:termdebug_config you can use: >vim
|
|
|
|
|
let g:termdebug_wide = 163
|
|
|
|
|
let g:termdebug_wide = 163
|
|
|
|
|
|
|
|
|
|
This will set 'columns' to 163 when `:Termdebug` is used. The value is
|
|
|
|
|
restored when quitting the debugger.
|
|
|
|
|
@@ -709,4 +704,4 @@ Set the wide value to 1 to use a vertical split without ever changing
|
|
|
|
|
'columns'. This is useful when the terminal can't be resized by Vim.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
|
|
|
|
vim:tw=78:ts=8:et:sw=2:ft=help:norl:
|
|
|
|
|
|