annotate runtime/doc/terminal.txt @ 13304:013c44d9dc09 v8.0.1526

patch 8.0.1526: no test using a screen dump yet commit https://github.com/vim/vim/commit/da65058a9c4774dc534c7ae98d24c58b5db669fa Author: Bram Moolenaar <Bram@vim.org> Date: Tue Feb 20 15:51:40 2018 +0100 patch 8.0.1526: no test using a screen dump yet Problem: No test using a screen dump yet. Solution: Add a test for C syntax highlighting. Add helper functions.
author Christian Brabandt <cb@256bit.org>
date Tue, 20 Feb 2018 16:00:06 +0100
parents 371ceeebbdaa
children 1ffba37fd222
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
1 *terminal.txt* For Vim version 8.0. Last change: 2018 Feb 20
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 VIM REFERENCE MANUAL by Bram Moolenaar
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 Terminal window support *terminal*
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 WARNING: THIS IS ONLY PARTLY IMPLEMENTED, ANYTHING CAN STILL CHANGE
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11
11763
21f3930dfe6e Documentation updates.
Christian Brabandt <cb@256bit.org>
parents: 11659
diff changeset
12 The terminal feature is optional, use this to check if your Vim has it: >
21f3930dfe6e Documentation updates.
Christian Brabandt <cb@256bit.org>
parents: 11659
diff changeset
13 echo has('terminal')
21f3930dfe6e Documentation updates.
Christian Brabandt <cb@256bit.org>
parents: 11659
diff changeset
14 If the result is "1" you have it.
21f3930dfe6e Documentation updates.
Christian Brabandt <cb@256bit.org>
parents: 11659
diff changeset
15
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
17 1. Basic use |terminal-use|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
18 Typing |terminal-typing|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
19 Size and color |terminal-size-color|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
20 Syntax |:terminal|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
21 Resizing |terminal-resizing|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
22 Terminal Modes |Terminal-mode|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
23 Cursor style |terminal-cursor-style|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
24 Special keys |terminal-special-keys|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
25 Unix |terminal-unix|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
26 MS-Windows |terminal-ms-windows|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
27 2. Remote testing |terminal-testing|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
28 3. Diffing screen dumps |terminal-diff|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
29 Writing a screen dump test for Vim |terminal-dumptest|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
30 Creating a screen dump |terminal-screendump|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
31 Comparing screen dumps |terminal-diffscreendump|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
32 4. Debugging |terminal-debug|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
33 Starting |termdebug-starting|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
34 Example session |termdebug-example|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
35 Stepping through code |termdebug-stepping|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
36 Inspecting variables |termdebug-variables|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
37 Other commands |termdebug-commands|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
38 Communication |termdebug-communication|
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
39 Customizing |termdebug-customizing|
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 {Vi does not have any of these commands}
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
42 {only available when compiled with the |+terminal| feature}
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
43
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
44 The terminal feature requires the |+multi_byte|, |+job| and |+channel| features.
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 ==============================================================================
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 1. Basic use *terminal-use*
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 This feature is for running a terminal emulator in a Vim window. A job can be
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 started connected to the terminal emulator. For example, to run a shell: >
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 :term bash
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
53 Or to run build command: >
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
54 :term make myprogram
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 The job runs asynchronously from Vim, the window will be updated to show
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
57 output from the job, also while editing in another window.
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58
11866
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
59
11814
d3d0db111d17 patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents: 11774
diff changeset
60 Typing ~
12457
dfb8254aa735 patch 8.0.1108: cannot specify mappings for the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
61 *terminal-typing*
12031
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
62 When the keyboard focus is in the terminal window, typed keys will be sent to
11814
d3d0db111d17 patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents: 11774
diff changeset
63 the job. This uses a pty when possible. You can click outside of the
d3d0db111d17 patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents: 11774
diff changeset
64 terminal window to move keyboard focus elsewhere.
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65
11866
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
66 CTRL-W can be used to navigate between windows and other CTRL-W commands, e.g.:
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
67 CTRL-W CTRL-W move focus to the next window
11866
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
68 CTRL-W : enter an Ex command
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
69 See |CTRL-W| for more commands.
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
70
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
71 Special in the terminal window: *CTRL-W_.* *CTRL-W_N*
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
72 CTRL-W . send a CTRL-W to the job in the terminal
12031
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
73 CTRL-W N go to Terminal-Normal mode, see |Terminal-mode|
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
74 CTRL-\ CTRL-N go to Terminal-Normal mode, see |Terminal-mode|
11914
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
75 CTRL-W " {reg} paste register {reg} *CTRL-W_quote*
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
76 Also works with the = register to insert the result of
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
77 evaluating an expression.
12160
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
78 CTRL-W CTRL-C ends the job, see below |t_CTRL-W_CTRL-C|
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79
11866
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
80 See option 'termkey' for specifying another key instead of CTRL-W that
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
81 will work like CTRL-W. However, typing 'termkey' twice sends 'termkey' to
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
82 the job. For example:
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
83 'termkey' CTRL-W move focus to the next window
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
84 'termkey' : enter an Ex command
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
85 'termkey' 'termkey' send 'termkey' to the job in the terminal
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
86 'termkey' . send a CTRL-W to the job in the terminal
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
87 'termkey' N go to terminal Normal mode, see below
11866
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
88 'termkey' CTRL-N same as CTRL-W N
12160
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
89 'termkey' CTRL-C same as |t_CTRL-W_CTRL-C|
11965
a932d3da41c8 patch 8.0.0863: a remote command does not work in the terminal window
Christian Brabandt <cb@256bit.org>
parents: 11914
diff changeset
90 *t_CTRL-\_CTRL-N*
12031
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
91 The special key combination CTRL-\ CTRL-N can be used to switch to Normal
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
92 mode, just like this works in any other mode.
12160
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
93 *t_CTRL-W_CTRL-C*
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
94 CTRL-W CTRL-C can be typed to forcefully end the job. On MS-Windows a
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
95 CTRL-BREAK will also kill the job.
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
96
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
97 If you type CTRL-C the effect depends on what the pty has been configured to
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
98 do. For simple commands this causes a SIGINT to be sent to the job, which
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
99 would end it. Other commands may ignore the SIGINT or handle the CTRL-C
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
100 themselves (like Vim does).
11866
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
101
12457
dfb8254aa735 patch 8.0.1108: cannot specify mappings for the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
102 To change the keys you type use terminal mode mappings, see |:tmap|.
dfb8254aa735 patch 8.0.1108: cannot specify mappings for the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
103 These are defined like any mapping, but apply only when typing keys that are
12559
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
104 sent to the job running in the terminal. For example, to make Escape switch
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
105 to Terminal-Normal mode: >
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
106 tnoremap <Esc> <C-W>N
12756
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 12559
diff changeset
107 < *options-in-terminal*
12559
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
108 After opening the terminal window and setting 'buftype' to "terminal" the
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
109 BufWinEnter autocommand event is triggered. This makes it possible to set
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
110 options specifically for the window and buffer. Example: >
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
111 au BufWinEnter * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
12457
dfb8254aa735 patch 8.0.1108: cannot specify mappings for the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
112
12907
32531a3eab1f patch 8.0.1330: MS-Windows: job in terminal can't get back to Vim
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
113 Mouse events (click and drag) are passed to the terminal. Mouse move events
32531a3eab1f patch 8.0.1330: MS-Windows: job in terminal can't get back to Vim
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
114 are only passed when Vim itself is receiving them. For a terminal that is
32531a3eab1f patch 8.0.1330: MS-Windows: job in terminal can't get back to Vim
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
115 when 'balloonevalterm' is enabled.
32531a3eab1f patch 8.0.1330: MS-Windows: job in terminal can't get back to Vim
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
116
11814
d3d0db111d17 patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents: 11774
diff changeset
117
12160
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
118 Size and color ~
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
119 *terminal-size-color*
11659
49c12c93abf3 Updated runtime files and translations.
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
120 See option 'termsize' for controlling the size of the terminal window.
49c12c93abf3 Updated runtime files and translations.
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
121 (TODO: scrolling when the terminal is larger than the window)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
123 The job running in the terminal can change the colors. The default foreground
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
124 and background colors are taken from Vim, the Normal highlight group.
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
125
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
126 For a color terminal the 'background' option is used to decide whether the
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
127 terminal window will start with a white or black background.
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
128
13100
656ab57d1ddc update a few runtime files
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
129 To use a different color the Terminal highlight group can be used, for
656ab57d1ddc update a few runtime files
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
130 example: >
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
131 hi Terminal ctermbg=lightgrey ctermfg=blue guibg=lightgrey guifg=blue
12160
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
132
11866
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
133
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 Syntax ~
11774
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
135
12031
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
136 :[range]ter[minal] [options] [command] *:ter* *:terminal*
11774
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
137 Open a new terminal window.
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 If [command] is provided run it as a job and connect
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 the input and output to the terminal.
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 If [command] is not given the 'shell' option is used.
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
142 if [command] is NONE no job is started, the pty of the
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
143 terminal can be used by a command like gdb.
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145 A new buffer will be created, using [command] or
11914
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
146 'shell' as the name, prefixed with a "!". If a buffer
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
147 by this name already exists a number is added in
12031
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
148 parentheses. E.g. if "gdb" exists the second terminal
11914
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
149 buffer will use "!gdb (1)".
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150
12192
6947d5bcf57f patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents: 12160
diff changeset
151 If [range] is given the specified lines are used as
6947d5bcf57f patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents: 12160
diff changeset
152 input for the job. It will not be possible to type
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
153 keys in the terminal window. For MS-Windows see the
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
154 ++eof argument below.
12031
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
155
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
156 *term++close* *term++open*
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
157 Supported [options] are:
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
158 ++close The terminal window will close
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
159 automatically when the job terminates.
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
160 ++open When the job terminates and no window
12064
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
161 shows it, a window will be opened.
12031
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
162 Note that this can be interruptive.
12064
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
163 ++curwin Open the terminal in the current
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
164 window, do not split the current
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
165 window. Fails if the current buffer
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
166 cannot be |abandon|ed.
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
167 ++hidden Open the terminal in a hidden buffer,
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
168 no window will be used.
12192
6947d5bcf57f patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents: 12160
diff changeset
169 ++rows={height} Use {height} for the terminal window
13125
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13100
diff changeset
170 height. If the terminal uses the full
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13100
diff changeset
171 Vim height (no window above or below
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13100
diff changeset
172 th terminal window) the command line
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13100
diff changeset
173 height will be reduced as needed.
12192
6947d5bcf57f patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents: 12160
diff changeset
174 ++cols={width} Use {width} for the terminal window
13125
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13100
diff changeset
175 width. If the terminal uses the full
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13100
diff changeset
176 Vim width (no window left or right of
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13100
diff changeset
177 the terminal window) this value is
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13100
diff changeset
178 ignored.
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
179 ++eof={text} when using [range]: text to send after
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
180 the last line was written. Cannot
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
181 contain white space. A CR is
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
182 appended. For MS-Windows the default
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
183 is to send CTRL-D.
12311
66fa8eabbd6e patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12267
diff changeset
184 E.g. for a shell use "++eof=exit" and
66fa8eabbd6e patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12267
diff changeset
185 for Python "++eof=exit()". Special
66fa8eabbd6e patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12267
diff changeset
186 codes can be used like with `:map`,
66fa8eabbd6e patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12267
diff changeset
187 e.g. "<C-Z>" for CTRL-Z.
12064
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
188
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
189 If you want to use more options use the |term_start()|
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
190 function.
12031
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
191
12160
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
192 When the buffer associated with the terminal is unloaded or wiped out the job
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
193 is killed, similar to calling `job_stop(job, "kill")`
11763
21f3930dfe6e Documentation updates.
Christian Brabandt <cb@256bit.org>
parents: 11659
diff changeset
194
12267
e3bde71afff0 patch 8.0.1013: terminal window behaves different from a buffer with changes
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
195 So long as the job is running the window behaves like it contains a modified
12311
66fa8eabbd6e patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12267
diff changeset
196 buffer. Trying to close the window with `CTRL-W :quit` fails. When using
66fa8eabbd6e patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12267
diff changeset
197 `CTRL-W :quit!` the job is ended. The text in the window is lost. The buffer
66fa8eabbd6e patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12267
diff changeset
198 still exists, but getting it in a window with `:buffer` will show an empty
66fa8eabbd6e patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12267
diff changeset
199 buffer.
66fa8eabbd6e patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12267
diff changeset
200
66fa8eabbd6e patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12267
diff changeset
201 Trying to close the window with `CTRL-W :close` also fails. Using
66fa8eabbd6e patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12267
diff changeset
202 `CTRL-W :close!` will close the window and make the buffer hidden.
12267
e3bde71afff0 patch 8.0.1013: terminal window behaves different from a buffer with changes
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
203
e3bde71afff0 patch 8.0.1013: terminal window behaves different from a buffer with changes
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
204 You can use `CTRL-W :hide` to close the terminal window and make the buffer
e3bde71afff0 patch 8.0.1013: terminal window behaves different from a buffer with changes
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
205 hidden, the job keeps running. The `:buffer` command can be used to turn the
e3bde71afff0 patch 8.0.1013: terminal window behaves different from a buffer with changes
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
206 current window into a terminal window. If there are unsaved changes this
e3bde71afff0 patch 8.0.1013: terminal window behaves different from a buffer with changes
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
207 fails, use ! to force, as usual.
12064
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
208
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
209 To have a background job run without a window, and open the window when it's
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
210 done, use options like this: >
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
211 :term ++hidden ++open make
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
212 Note that the window will open at an unexpected moment, this will interrupt
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
213 what you are doing.
407a475c67fd patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents: 12031
diff changeset
214
12160
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
215 *E947* *E948*
11967
12833414cc02 patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents: 11965
diff changeset
216 So long as the job is running, the buffer is considered modified and Vim
12833414cc02 patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents: 11965
diff changeset
217 cannot be quit easily, see |abandon|.
11914
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
218
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
219 When the job has finished and no changes were made to the buffer: closing the
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
220 window will wipe out the buffer.
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
221
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
222 Before changes can be made to a terminal buffer, the 'modifiable' option must
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
223 be set. This is only possible when the job has finished. At the first change
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
224 the buffer will become a normal buffer and the highlighting is removed.
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
225 You may want to change the buffer name with |:file| to be able to write, since
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
226 the buffer name will still be set to the command.
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
227
11763
21f3930dfe6e Documentation updates.
Christian Brabandt <cb@256bit.org>
parents: 11659
diff changeset
228
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
229 Resizing ~
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
230 *terminal-resizing*
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231 The size of the terminal can be in one of three modes:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233 1. The 'termsize' option is empty: The terminal size follows the window size.
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
234 The minimal size is 2 screen lines with 10 cells.
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
235
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236 2. The 'termsize' option is "rows*cols", where "rows" is the minimal number of
11774
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
237 screen rows and "cols" is the minimal number of cells.
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
238
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239 3. The 'termsize' option is "rowsXcols" (where the x is upper or lower case).
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
240 The terminal size is fixed to the specified number of screen lines and
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241 cells. If the window is bigger there will be unused empty space.
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
242
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
243 If the window is smaller than the terminal size, only part of the terminal can
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
244 be seen (the lower-left part).
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
245
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
246 The |term_getsize()| function can be used to get the current size of the
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
247 terminal. |term_setsize()| can be used only when in the first or second mode,
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
248 not when 'termsize' is "rowsXcols".
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
249
11763
21f3930dfe6e Documentation updates.
Christian Brabandt <cb@256bit.org>
parents: 11659
diff changeset
250
12031
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
251 Terminal-Job and Terminal-Normal mode ~
11866
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
252 *Terminal-mode*
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
253 When the job is running the contents of the terminal is under control of the
12031
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
254 job. That includes the cursor position. Typed keys are sent to the job.
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
255 The terminal contents can change at any time. This is called Terminal-Job
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
256 mode.
11866
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
257
12031
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
258 Use CTRL-W N (or 'termkey' N) to switch to Terminal-Normal mode. Now the
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
259 contents of the terminal window is under control of Vim, the job output is
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
260 suspended. CTRL-\ CTRL-N does the same.
12457
dfb8254aa735 patch 8.0.1108: cannot specify mappings for the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
261
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
262 Terminal-Job mode is where |:tmap| mappings are applied. Keys sent by
12457
dfb8254aa735 patch 8.0.1108: cannot specify mappings for the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
263 |term_sendkeys()| are not subject to tmap, but keys from |feedkeys()| are.
dfb8254aa735 patch 8.0.1108: cannot specify mappings for the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
264
11866
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
265 *E946*
12031
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
266 In Terminal-Normal mode you can move the cursor around with the usual Vim
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
267 commands, Visually mark text, yank text, etc. But you cannot change the
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
268 contents of the buffer. The commands that would start insert mode, such as
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
269 'i' and 'a', return to Terminal-Job mode. The window will be updated to show
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
270 the contents of the terminal. |:startinsert| is ineffective.
11866
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
271
12031
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
272 In Terminal-Normal mode the statusline and window title show "(Terminal)". If
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
273 the job ends while in Terminal-Normal mode this changes to
9897241c08b5 patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents: 11967
diff changeset
274 "(Terminal-finished)".
11866
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
275
12160
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
276 It is not possible to enter Insert mode from Terminal-Job mode.
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
277
11866
be40c8a9240d patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents: 11814
diff changeset
278
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
279 Cursor style ~
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
280 *terminal-cursor-style*
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
281 By default the cursor in the terminal window uses a not blinking block. The
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
282 normal xterm escape sequences can be used to change the blinking state and the
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
283 shape. Once focus leaves the terminal window Vim will restore the original
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
284 cursor.
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
285
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
286 An exception is when xterm is started with the "-bc" argument, or another way
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
287 that causes the cursor to blink. This actually means that the blinking flag
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
288 is inverted. Since Vim cannot detect this, the terminal window cursor
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
289 blinking will also be inverted.
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
290
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
291
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
292 Special keys ~
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
293 *terminal-special-keys*
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
294 Since the terminal emulator simulates an xterm, only escape sequences that
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
295 both Vim and xterm recognize will be available in the terminal window. If you
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
296 want to pass on other escape sequences to the job running in the terminal you
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
297 need to set up forwarding. Example: >
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
298 tmap <expr> <Esc>]b SendToTerm("\<Esc>]b")
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
299 func SendToTerm(what)
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
300 call term_sendkeys('', a:what)
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
301 return ''
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
302 endfunc
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
303
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
304
11763
21f3930dfe6e Documentation updates.
Christian Brabandt <cb@256bit.org>
parents: 11659
diff changeset
305 Unix ~
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
306 *terminal-unix*
11763
21f3930dfe6e Documentation updates.
Christian Brabandt <cb@256bit.org>
parents: 11659
diff changeset
307 On Unix a pty is used to make it possible to run all kinds of commands. You
21f3930dfe6e Documentation updates.
Christian Brabandt <cb@256bit.org>
parents: 11659
diff changeset
308 can even run Vim in the terminal! That's used for debugging, see below.
21f3930dfe6e Documentation updates.
Christian Brabandt <cb@256bit.org>
parents: 11659
diff changeset
309
11914
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
310 Environment variables are used to pass information to the running job:
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
311 TERM name of the terminal, 'term'
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
312 ROWS number of rows in the terminal initially
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
313 LINES same as ROWS
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
314 COLUMNS number of columns in the terminal initially
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
315 COLORS number of colors, 't_Co' (256*256*256 in the GUI)
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
316 VIM_SERVERNAME v:servername
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
317
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
318 The |client-server| feature can be used to communicate with the Vim instance
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
319 where the job was started. This only works when v:servername is not empty.
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
320 If needed you can set it with: >
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
321 call remote_startserver('vim-server')
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
322
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
323 In the job you can then do something like: >
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
324 vim --servername $VIM_SERVERNAME --remote +123 some_file.c
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
325 This will open the file "some_file.c" and put the cursor on line 123.
4f7081eb1e26 Updated runtime files
Christian Brabandt <cb@256bit.org>
parents: 11866
diff changeset
326
11763
21f3930dfe6e Documentation updates.
Christian Brabandt <cb@256bit.org>
parents: 11659
diff changeset
327
21f3930dfe6e Documentation updates.
Christian Brabandt <cb@256bit.org>
parents: 11659
diff changeset
328 MS-Windows ~
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
329 *terminal-ms-windows*
11774
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
330 On MS-Windows winpty is used to make it possible to run all kind of commands.
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
331 Obviously, they must be commands that run in a terminal, not open their own
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
332 window.
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
333
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
334 You need the following two files from winpty:
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
335
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
336 winpty.dll
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
337 winpty-agent.exe
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
338
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
339 You can download them from the following page:
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
340
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
341 https://github.com/rprichard/winpty
edf1a2a247fa patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11763
diff changeset
342
12160
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
343 Just put the files somewhere in your PATH. You can set the 'winptydll' option
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
344 to point to the right file, if needed. If you have both the 32-bit and 64-bit
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
345 version, rename to winpty32.dll and winpty64.dll to match the way Vim was
b80c0172d1a8 patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents: 12064
diff changeset
346 build.
11763
21f3930dfe6e Documentation updates.
Christian Brabandt <cb@256bit.org>
parents: 11659
diff changeset
347
12907
32531a3eab1f patch 8.0.1330: MS-Windows: job in terminal can't get back to Vim
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
348 Environment variables are used to pass information to the running job:
32531a3eab1f patch 8.0.1330: MS-Windows: job in terminal can't get back to Vim
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
349 VIM_SERVERNAME v:servername
32531a3eab1f patch 8.0.1330: MS-Windows: job in terminal can't get back to Vim
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
350
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
351 ==============================================================================
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
352 2. Remote testing *terminal-testing*
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
353
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
354 Most Vim tests execute a script inside Vim. For some tests this does not
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
355 work, running the test interferes with the code being tested. To avoid this
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
356 Vim is executed in a terminal window. The test sends keystrokes to it and
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
357 inspects the resulting screen state.
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
358
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
359 Functions ~
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
360
12457
dfb8254aa735 patch 8.0.1108: cannot specify mappings for the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
361 term_sendkeys() send keystrokes to a terminal (not subject to tmap)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
362 term_wait() wait for screen to be updated
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
363 term_scrape() inspect terminal screen
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
364
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
365
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
366 ==============================================================================
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
367 3. Diffing screen dumps *terminal-diff*
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
368
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
369 In some cases it can be bothersome to test that Vim displays the right
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
370 characters on the screen. E.g. with syntax highlighting. To make this
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
371 simpler it is possible to take a screen dump of a terminal and compare it to
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
372 an expected screen dump.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
373
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
374 Vim uses the window size, text, color and other attributes as displayed. The
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
375 Vim screen size, font and other properties do not matter. Therefore this
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
376 mechanism is portable across systems. A convential screenshot would reflect
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
377 all differences, including font size and family.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
378
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
379
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
380 Writing a screen dump test for Vim ~
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
381 *terminal-dumptest*
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
382 For an example see the Test_syntax_c() function in
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
383 src/testdir/test_syntax.vim. The main parts are:
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
384 - Write a file you want to test with. This is useful for testing syntax
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
385 highlighting. You can also start Vim with en empty buffer.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
386 - Run Vim in a terminal with a specific size. The default is 20 lines of 75
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
387 characters. This makes sure the dump is always this size. The function
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
388 RunVimInTerminal() takes care of this. Pass it the arguments for the Vim
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
389 command.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
390 - Send any commands to Vim using term_sendkeys(). For example: >
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
391 call term_sendkeys(buf, ":echo &lines &columns\<CR>")
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
392 - Check that the screen is now in the expected state, using
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
393 VerifyScreenDump(). This expects the reference screen dump to be in the
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
394 src/testdir/dumps/ directory. Pass the name without ".dump". It is
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
395 recommended to use the name of the test function and a sequence number, so
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
396 that we know what test is using the file.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
397 - Repeat sending commands and checking the state.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
398 - Finally stop Vim by calling StopVimInTerminal().
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
399
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
400 The first time you do this you won't have a screen dump yet. Create an empty
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
401 file for now, e.g.: >
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
402 touch src/testdir/dumps/Test_function_name_01.dump
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
403
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
404 The test will then fail, giving you the command to compare the reference dump
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
405 and the failed dump, e.g.: >
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
406 call term_dumpdiff("Test_func.dump.failed", "dumps/Test_func.dump")
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
407
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
408 Use this command in Vim, with the current directory set to src/testdir.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
409 Once you are satisfied with the test, move the failed dump in place of the
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
410 reference: >
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
411 :!mv Test_func.dump.failed dumps/Test_func.dump
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
412
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
413
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
414 Creating a screen dump ~
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
415 *terminal-screendump*
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
416
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
417 To create the screen dump, run Vim (or any other program) in a terminal and
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
418 make it show the desired state. Then use the term_dumpwrite() function to
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
419 create a screen dump file. For example: >
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
420 :call term_dumpwrite(77, "mysyntax.dump")
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
421
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
422 Here "77" is the buffer number of the terminal. Use `:ls!` to see it.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
423
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
424 You can view the screen dump with term_dumpload(): >
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
425 :call term_dumpload("mysyntax.dump")
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
426
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
427 To verify that Vim still shows exactly the same screen, run Vim again with
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
428 exactly the same way to show the desired state. Then create a screen dump
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
429 again, using a different file name: >
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
430 :call term_dumpwrite(88, "test.dump")
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
431
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
432 To assert that the files are exactly the same use assert_equalfile(): >
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
433 call assert_equalfile("mysyntax.dump", "test.dump")
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
434
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
435 If there are differences then v:errors will contain the error message.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
436
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
437
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
438 Comparing screen dumps ~
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
439 *terminal-diffscreendump*
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
440
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
441 assert_equalfile() does not make it easy to see what is different.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
442 To spot the problem use term_dumpdiff(): >
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
443 call term_dumpdiff("mysyntax.dump", "test.dump")
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
444
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
445 This will open a window consisting of three parts:
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
446 1. The contents of the first dump
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
447 2. The difference between the first and second dump
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
448 3. The contents of the second dump
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
449
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
450 You can usually see what differs in the second part. Use the 'ruler' to
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
451 relate it to the postion in the first or second dump.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
452
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
453 Alternatively, press "s" to swap the first and second dump. Do this everal
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
454 times so that you can spot the difference in the context of the text.
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
455
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
456 ==============================================================================
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
457 4. Debugging *terminal-debug*
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
458
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
459 The Terminal debugging plugin can be used to debug a program with gdb and view
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
460 the source code in a Vim window. Since this is completely contained inside
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
461 Vim this also works remotely over an ssh connection.
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
462
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
463
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
464 Starting ~
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
465 *termdebug-starting*
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
466 Load the plugin with this command: >
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
467 packadd termdebug
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
468 < *:Termdebug*
13051
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12907
diff changeset
469 To start debugging use `:Termdebug` followed by the command name, for example: >
12559
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
470 :Termdebug vim
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
471
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
472 This opens two windows:
13051
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12907
diff changeset
473
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
474 gdb window A terminal window in which "gdb vim" is executed. Here you
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
475 can directly interact with gdb. The buffer name is "!gdb".
13051
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12907
diff changeset
476
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
477 program window A terminal window for the executed program. When "run" is
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
478 used in gdb the program I/O will happen in this window, so
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
479 that it does not interfere with controlling gdb. The buffer
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
480 name is "gdb program".
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
481
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
482 The current window is used to show the source code. When gdb pauses the
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
483 source file location will be displayed, if possible. A sign is used to
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
484 highlight the current position (using highlight group debugPC).
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
485
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
486 If the buffer in the current window is modified, another window will be opened
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
487 to display the current gdb position.
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
488
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
489 Focus the terminal of the executed program to interact with it. This works
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
490 the same as any command running in a terminal window.
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
491
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
492 When the debugger ends, typically by typing "quit" in the gdb window, the two
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
493 opened windows are closed.
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
494
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
495
12559
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
496 Example session ~
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
497 *termdebug-example*
12559
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
498 Start in the Vim "src" directory and build Vim: >
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
499 % make
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
500 Start Vim: >
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
501 % ./vim
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
502 Load the termdebug plugin and start debugging Vim: >
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
503 :packadd termdebug
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
504 :Termdebug vim
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
505 You should now have three windows:
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
506 source - where you started, has a window toolbar with buttons
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
507 gdb - you can type gdb commands here
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
508 program - the executed program will use this window
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
509 You can use CTRL-W CTRL-W or the mouse to move focus between windows.
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
510 Put focus on the gdb window and type: >
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
511 break ex_help
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
512 run
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
513 Vim will start running in the program window. Put focus there and type: >
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
514 :help gui
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
515 Gdb will run into the ex_help breakpoint. The source window now shows the
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
516 ex_cmds.c file. A ">>" marker will appear where the breakpoint was set. The
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
517 line where the debugger stopped is highlighted. You can now step through the
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
518 program. Let's use the mouse: click on the "Next" button in the window
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
519 toolbar. You will see the highlighting move as the debugger executes a line
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
520 of source code.
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
521
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
522 Click "Next" a few times until the for loop is highlighted. Put the cursor on
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
523 the end of "eap->arg", then click "Eval" in the toolbar. You will see this
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
524 displayed:
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
525 "eap->arg": 0x555555e68855 "gui" ~
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
526 This way you can inspect the value of local variables. You can also focus the
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
527 gdb window and use a "print" command, e.g.: >
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
528 print *eap
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
529
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
530 Now go back to the source window and put the cursor on the first line after
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
531 the for loop, then type: >
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
532 :Break
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
533 You will see a ">>" marker appear, this indicates the new breakpoint. Now
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
534 click "Cont" in the toolbar and the code until the breakpoint will be
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
535 executed.
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
536
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
537 You can type more advanced commands in the gdb window. For example, type: >
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
538 watch curbuf
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
539 Now click "Cont" in the toolbar (or type "cont" in the gdb window). Execution
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
540 will now continue until the value of "curbuf" changes, which is in do_ecmd().
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
541 To remove this watchpoint again type in the gdb window: >
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
542 delete 3
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
543
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
544 You can see the stack by typing in the gdb window: >
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
545 where
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
546 Move through the stack frames, e.g. with: >
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
547 frame 3
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
548 The source window will show the code, at the point where the call was made to
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
549 a deeper level.
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
550
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
551
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
552 Stepping through code ~
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
553 *termdebug-stepping*
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
554 Put focus on the gdb window to type commands there. Some common ones are:
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
555 - CTRL-C interrupt the program
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
556 - next execute the current line and stop at the next line
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
557 - step execute the current line and stop at the next statement,
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
558 entering functions
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
559 - finish execute until leaving the current function
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
560 - where show the stack
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
561 - frame N go to the Nth stack frame
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
562 - continue continue execution
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
563
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
564 In the window showing the source code these commands can used to control gdb:
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
565 :Run [args] run the program with [args] or the previous arguments
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
566 :Arguments {args} set arguments for the next :Run
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
567
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
568 :Break set a breakpoint at the current line; a sign will be displayed
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
569 :Delete delete a breakpoint at the current line
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
570
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
571 :Step execute the gdb "step" command
13304
013c44d9dc09 patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
572 :Over execute the gdb "next" command (:Next is a Vim command)
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
573 :Finish execute the gdb "finish" command
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
574 :Continue execute the gdb "continue" command
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
575 :Stop interrupt the program
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
576
13051
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12907
diff changeset
577 If 'mouse' is set the plugin adds a window toolbar with these entries:
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
578 Step :Step
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
579 Next :Over
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
580 Finish :Finish
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
581 Cont :Continue
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
582 Stop :Stop
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
583 Eval :Evaluate
13051
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12907
diff changeset
584 This way you can use the mouse to perform the most common commands. You need
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12907
diff changeset
585 to have the 'mouse' option set to enable mouse clicks.
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
586
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
587
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
588 Inspecting variables ~
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
589 *termdebug-variables*
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
590 :Evaluate evaluate the expression under the cursor
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
591 K same
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
592 :Evaluate {expr} evaluate {expr}
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
593 :'<,'>Evaluate evaluate the Visually selected text
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
594
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
595 This is similar to using "print" in the gdb window.
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
596
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
597
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
598 Other commands ~
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
599 *termdebug-commands*
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
600 :Gdb jump to the gdb window
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
601 :Program jump to the window with the running program
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
602
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
603
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
604 Communication ~
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
605 *termdebug-communication*
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
606 There is another, hidden, buffer, which is used for Vim to communicate with
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
607 gdb. The buffer name is "gdb communication". Do not delete this buffer, it
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
608 will break the debugger.
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
609
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
610
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
611 Customizing ~
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
612 *termdebug-customizing*
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
613 To change the name of the gdb command, set the "termdebugger" variable before
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
614 invoking `:Termdebug`: >
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
615 let termdebugger = "mygdb"
12756
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 12559
diff changeset
616 < *gdb-version*
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
617 Only debuggers fully compatible with gdb will work. Vim uses the GDB/MI
12756
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 12559
diff changeset
618 interface. This probably requires gdb version 7.12. if you get this error:
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 12559
diff changeset
619 Undefined command: "new-ui". Try "help".~
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 12559
diff changeset
620 Then your gdb is too old.
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
621
13125
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13100
diff changeset
622 *hl-debugPC* *hl-debugBreakpoint*
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
623 The color of the signs can be adjusted with these highlight groups:
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
624 - debugPC the current position
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
625 - debugBreakpoint a breakpoint
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
626
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
627 The defaults are, when 'background' is "light":
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
628 hi debugPC term=reverse ctermbg=lightblue guibg=lightblue
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
629 hi debugBreakpoint term=reverse ctermbg=red guibg=red
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
630
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
631 When 'background' is "dark":
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
632 hi debugPC term=reverse ctermbg=darkblue guibg=darkblue
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12311
diff changeset
633 hi debugBreakpoint term=reverse ctermbg=red guibg=red
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12192
diff changeset
634
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
635 To change the width of the Vim window when debugging starts, and use a
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
636 vertical split: >
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
637 let g:termdebug_wide = 163
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
638 This will set &columns to 163 when :Termdebug is used. The value is restored
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
639 when quitting the debugger.
12559
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
640 If g:termdebug_wide is set and &Columns is already larger than
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
641 g:termdebug_wide then a vertical split will be used without changing &columns.
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
642 Set it to 1 to get a vertical split without every changing &columns (useful
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
643 for when the terminal can't be resized by Vim).
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
644
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
645
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
646
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
647 vim:tw=78:ts=8:ft=help:norl: