terminal.txt 25 KB

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