terminal.txt 25 KB

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