|
| 1 | +*terminal.txt* For Vim version 8.0. Last change: 2017 Jul 04 |
| 2 | + |
| 3 | + |
| 4 | + VIM REFERENCE MANUAL by Bram Moolenaar |
| 5 | + |
| 6 | + |
| 7 | +Terminal window support *terminal* |
| 8 | + |
| 9 | + |
| 10 | +WARNING: THIS IS ONLY PARTLY IMPLEMENTED, ANYTHING CAN STILL CHANGE |
| 11 | + |
| 12 | + |
| 13 | +1. Basic use |terminal-use| |
| 14 | +2. Remote testing |terminal-testing| |
| 15 | +3. Debugging |terminal-debug| |
| 16 | + |
| 17 | +{Vi does not have any of these commands} |
| 18 | + |
| 19 | +============================================================================== |
| 20 | +1. Basic use *terminal-use* |
| 21 | + |
| 22 | +This feature is for running a terminal emulator in a Vim window. A job can be |
| 23 | +started connected to the terminal emulator. For example, to run a shell: > |
| 24 | + :term bash |
| 25 | +
|
| 26 | +Or to run a debugger: > |
| 27 | + :term gdb vim |
| 28 | +
|
| 29 | +The job runs asynchronously from Vim, the window will be updated to show |
| 30 | +output from the job, also while editing in any other window. |
| 31 | + |
| 32 | +When the keyboard focus is in the terminal window, typed keys will be send to |
| 33 | +the job. This uses a pty when possible. |
| 34 | + |
| 35 | +Navigate between windows with CTRL-W commands (and mouse). |
| 36 | +E.g. CTRL-W CTRL-W moves focus to the next window. |
| 37 | + |
| 38 | +Option 'termkey' |
| 39 | +Specify key for Vim command in terminal window. local to window. |
| 40 | +Default is CTRL-W. |
| 41 | + |
| 42 | +Option 'termsize' |
| 43 | +Specify terminal size. Local to window. |
| 44 | +When empty the terminal gets the size from the window. |
| 45 | +When set (e.g., "24x80") the terminal size is fixed. If the window is smaller |
| 46 | +only the top-left part is displayed. (TODO: scrolling?) |
| 47 | + |
| 48 | +Syntax ~ |
| 49 | + *:ter* *:terminal* |
| 50 | +:terminal[!] [command] Open a new terminal window. |
| 51 | + |
| 52 | + If [command] is provided run it as a job and connect |
| 53 | + the input and output to the terminal. |
| 54 | + If [command] is not given the 'shell' option is used. |
| 55 | + |
| 56 | + A new buffer will be created, using [command] or |
| 57 | + 'shell' as the name. If a buffer by this name already |
| 58 | + exists a number is added in parenthesis. |
| 59 | + E.g. if "gdb" exists the second terminal buffer will |
| 60 | + use "gdb (1)". |
| 61 | + |
| 62 | + The window can be closed, in which case the buffer |
| 63 | + becomes hidden. The command will not be stopped. The |
| 64 | + `:buffer` command can be used to turn the current |
| 65 | + window into a terminal window, using the existing |
| 66 | + buffer. If there are unsaved changes this fails, use |
| 67 | + ! to force, as usual. |
| 68 | + |
| 69 | +Resizing ~ |
| 70 | + |
| 71 | +The size of the terminal can be in one of three modes: |
| 72 | + |
| 73 | +1. The 'termsize' option is empty: The terminal size follows the window size. |
| 74 | + The minimal size is 2 screen lines with 10 cells. |
| 75 | + |
| 76 | +2. The 'termsize' option is "rows*cols", where "rows" is the minimal number of |
| 77 | + screen rows and "cols" is the minial number of cells. |
| 78 | + |
| 79 | +3. The 'termsize' option is "rowsXcols" (where the x is upper or lower case). |
| 80 | + The terminal size is fixed to the specified number of screen lines and |
| 81 | + cells. If the window is bigger there will be unused empty space. |
| 82 | + |
| 83 | +If the window is smaller than the terminal size, only part of the terminal can |
| 84 | +be seen (the lower-left part). |
| 85 | + |
| 86 | +The |term_getsize()| function can be used to get the current size of the |
| 87 | +terminal. |term_setsize()| can be used only when in the first or second mode, |
| 88 | +not when 'termsize' is "rowsXcols". |
| 89 | + |
| 90 | +============================================================================== |
| 91 | +2. Remote testing *terminal-testing* |
| 92 | + |
| 93 | +Most Vim tests execute a script inside Vim. For some tests this does not |
| 94 | +work, running the test interferes with the code being tested. To avoid this |
| 95 | +Vim is executed in a terminal window. The test sends keystrokes to it and |
| 96 | +inspects the resulting screen state. |
| 97 | + |
| 98 | +Functions ~ |
| 99 | + |
| 100 | +term_sendkeys() send keystrokes to a terminal |
| 101 | +term_wait() wait for screen to be updated |
| 102 | +term_scrape() inspect terminal screen |
| 103 | + |
| 104 | + |
| 105 | +============================================================================== |
| 106 | +3. Debugging *terminal-debug* |
| 107 | + |
| 108 | +The Terminal debugging plugin can be used to debug a program with gdb and view |
| 109 | +the source code in a Vim window. For example: > |
| 110 | +
|
| 111 | + :TermDebug vim |
| 112 | +
|
| 113 | +This opens three windows: |
| 114 | +- A terminal window in which "gdb vim" is executed. Here you can directly |
| 115 | + interact with gdb. |
| 116 | +- A terminal window for the executed program. When "run" is used in gdb the |
| 117 | + program I/O will happen in this window, so that it does not interfere with |
| 118 | + controlling gdb. |
| 119 | +- A normal Vim window used to show the source code. When gdb jumps to a |
| 120 | + source file location this window will display the code, if possible. Values |
| 121 | + of variables can be inspected, breakpoints set and cleared, etc. |
| 122 | + |
| 123 | +This uses two terminal windows. To open the gdb window: > |
| 124 | + :term gdb [arguments] |
| 125 | +To open the terminal to run the tested program |term_open()| is used. |
| 126 | + |
| 127 | +TODO |
| 128 | + |
| 129 | + |
| 130 | + vim:tw=78:ts=8:ft=help:norl: |
0 commit comments