neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

usr_09.txt (10358B)


      1 *usr_09.txt*	Nvim
      2 
      3 
      4 	     VIM USER MANUAL	by Bram Moolenaar
      5 
      6 
      7 			Using the GUI
      8 
      9 
     10 Vim works in an ordinary terminal, while gVim has a Graphical User Interface
     11 (GUI).  It can do the same things and a few more.  The GUI offers menus, a
     12 toolbar, scrollbars and other items.  This chapter is about these extra things
     13 that the GUI offers.
     14 
     15 |09.1|	Parts of the GUI
     16 |09.2|	Using the mouse
     17 |09.3|	The clipboard
     18 |09.4|	Select mode
     19 
     20     Next chapter: |usr_10.txt|  Making big changes
     21 Previous chapter: |usr_08.txt|  Splitting windows
     22 Table of contents: |usr_toc.txt|
     23 
     24 ==============================================================================
     25 *09.1*	Parts of the GUI
     26 
     27 You might have an icon on your desktop that starts gvim.  Otherwise, one of
     28 these commands should do it: >
     29 
     30 gvim file.txt
     31 vim -g file.txt
     32 
     33 If this doesn't work you don't have a version of Vim with GUI support.  You
     34 will have to install one first.
     35   Vim will open a window and display "file.txt" in it.  What the window looks
     36 like depends on the version of Vim.  It should resemble the following picture
     37 (for as far as this can be shown in ASCII!).
     38 
     39 +----------------------------------------------------+
     40 | file.txt + (~/dir) - VIM			   X |	<- window title
     41 +----------------------------------------------------+
     42 | File	Edit  Tools  Syntax  Buffers  Window  Help   |	<- menubar
     43 +----------------------------------------------------+
     44 | aaa  bbb  ccc  ddd  eee  fff	ggg  hhh  iii  jjj   |	<- toolbar
     45 | aaa  bbb  ccc  ddd  eee  fff	ggg  hhh  iii  jjj   |
     46 +----------------------------------------------------+
     47 | file text					 | ^ |
     48 | ~						 | # |
     49 | ~						 | # |	<- scrollbar
     50 | ~						 | # |
     51 | ~						 | # |
     52 | ~						 | # |
     53 |						 | V |
     54 +----------------------------------------------------+
     55 
     56 The largest space is occupied by the file text.  This shows the file in the
     57 same way as in a terminal.  With some different colors and another font
     58 perhaps.
     59 
     60 
     61 THE WINDOW TITLE
     62 
     63 At the very top is the window title.  This is drawn by your window system.
     64 Vim will set the title to show the name of the current file.  First comes the
     65 name of the file.  Then some special characters and the directory of the file
     66 in parens.  These special characters can be present:
     67 
     68 • -	The file cannot be modified (e.g., a help file)
     69 • +	The file contains changes
     70 • =	The file is read-only
     71 • =+	The file is read-only, contains changes anyway
     72 
     73 If nothing is shown you have an ordinary, unchanged file.
     74 
     75 
     76 THE MENUBAR
     77 
     78 You know how menus work, right?  Vim has the usual items, plus a few more.
     79 Browse them to get an idea of what you can use them for.  A relevant submenu
     80 is Edit/Global Settings.  You will find these entries:
     81 
     82 Toggle Toolbar		make the toolbar appear/disappear
     83 Toggle Bottom Scrollbar	make a scrollbar appear/disappear at the bottom
     84 Toggle Left Scrollbar	make a scrollbar appear/disappear at the left
     85 Toggle Right Scrollbar	make a scrollbar appear/disappear at the right
     86 
     87 
     88 THE TOOLBAR
     89 
     90 This contains icons for the most often used actions.  Hopefully the icons are
     91 self-explanatory.  There are tooltips to get an extra hint (move the mouse
     92 pointer to the icon without clicking and don't move it for a second).
     93 
     94 The "Edit/Global Settings/Toggle Toolbar" menu item can be used to make the
     95 toolbar disappear.  If you never want a toolbar, use this command in your
     96 vimrc file: >
     97 
     98 :set guioptions-=T
     99 
    100 This removes the 'T' flag from the 'guioptions' option.  Other parts of the
    101 GUI can also be enabled or disabled with this option.  See the help for it.
    102 
    103 
    104 THE SCROLLBARS
    105 
    106 By default there is one scrollbar on the right.  It does the obvious thing.
    107 When you split the window, each window will get its own scrollbar.
    108   You can make a horizontal scrollbar appear with the menu item
    109 Edit/Global Settings/Toggle Bottom Scrollbar.  This is useful in diff mode, or
    110 when the 'wrap' option has been reset (more about that later).
    111 
    112 When there are vertically split windows, only the windows on the right side
    113 will have a scrollbar.  However, when you move the cursor to a window on the
    114 left, it will be this one that the scrollbar controls.  This takes a bit of
    115 time to get used to.
    116   When you work with vertically split windows, consider adding a scrollbar on
    117 the left.  This can be done with a menu item, or with the 'guioptions' option:
    118 >
    119 :set guioptions+=l
    120 
    121 This adds the 'l' flag to 'guioptions'.
    122 
    123 ==============================================================================
    124 *09.2*	Using the mouse
    125 
    126 Standards are wonderful.  In Microsoft Windows, you can use the mouse to
    127 select text in a standard manner.  The X Window system also has a standard
    128 system for using the mouse.  Unfortunately, these two standards are not the
    129 same. Fortunately, you can customize Vim.
    130 
    131 The following commands makes the mouse work more like a Microsoft Windows
    132 mouse: >
    133 
    134 set selection=exclusive
    135 set selectmode=mouse,key
    136 set keymodel=startsel,stopsel
    137 
    138 The mouse can be further tuned.  Check out these options if you want to change
    139 the way how the mouse works:
    140 
    141 'mouse'			in which mode the mouse is used by Vim
    142 'mousemodel'		what effect a mouse click has
    143 'mousetime'		time between clicks for a double-click
    144 'mousehide'		hide the mouse while typing
    145 'selectmode'		whether the mouse starts Visual or Select mode
    146 
    147 ==============================================================================
    148 *09.3*	The clipboard
    149 
    150 In section |04.7| the basic use of the clipboard was explained.  There is one
    151 essential thing to explain about X-windows: There are actually two places to
    152 exchange text between programs.  MS-Windows doesn't have this.
    153 
    154 In X-Windows there is the "current selection".  This is the text that is
    155 currently highlighted.  In Vim this is the Visual area (this assumes you are
    156 using the default option settings).  You can paste this selection in another
    157 application without any further action.
    158   For example, in this text select a few words with the mouse.  Vim will
    159 switch to Visual mode and highlight the text.  Now start another gvim, without
    160 a file name argument, so that it displays an empty window.  Click the middle
    161 mouse button.  The selected text will be inserted.
    162 
    163 The "current selection" will only remain valid until some other text is
    164 selected.  After doing the paste in the other gvim, now select some characters
    165 in that window.  You will notice that the words that were previously selected
    166 in the other gvim window are displayed differently.  This means that it no
    167 longer is the current selection.
    168 
    169 You don't need to select text with the mouse, using the keyboard commands for
    170 Visual mode works just as well.
    171 
    172 
    173 THE REAL CLIPBOARD
    174 
    175 Now for the other place with which text can be exchanged.  We call this the
    176 "real clipboard", to avoid confusion.  Often both the "current selection" and
    177 the "real clipboard" are called clipboard, you'll have to get used to that.
    178   To put text on the real clipboard, select a few different words in one of
    179 the gvims you have running.  Then use the Edit/Copy menu entry.  Now the text
    180 has been copied to the real clipboard.  You can't see this, unless you have
    181 some application that shows the clipboard contents (e.g., KDE's Klipper).
    182   Now select the other gvim, position the cursor somewhere and use the
    183 Edit/Paste menu.  You will see the text from the real clipboard is inserted.
    184 
    185 
    186 USING BOTH
    187 
    188 This use of both the "current selection" and the "real clipboard" might sound
    189 a bit confusing.  But it is very useful.  Let's show this with an example.
    190 Use one gvim with a text file and perform these actions:
    191 
    192 -  Select two words in Visual mode.
    193 -  Use the Edit/Copy menu to get these words onto the clipboard.
    194 -  Select one other word in Visual mode.
    195 -  Use the Edit/Paste menu item.  What will happen is that the single selected
    196   word is replaced with the two words from the clipboard.
    197 -  Move the mouse pointer somewhere else and click the middle button.  You
    198   will see that the word you just overwrote with the clipboard is inserted
    199   here.
    200 
    201 If you use the "current selection" and the "real clipboard" with care, you can
    202 do a lot of useful editing with them.
    203 
    204 
    205 USING THE KEYBOARD
    206 
    207 If you don't like using the mouse, you can access the current selection and
    208 the real clipboard with two registers.  The "* register is for the current
    209 selection.
    210   To make text become the current selection, use Visual mode.  For example,
    211 to select a whole line just press "V".
    212   To insert the current selection before the cursor: >
    213 
    214 "*P
    215 
    216 Notice the uppercase "P".  The lowercase "p" puts the text after the cursor.
    217 
    218 The "+ register is used for the real clipboard.  For example, to copy the text
    219 from the cursor position until the end of the line to the clipboard: >
    220 
    221 "+y$
    222 
    223 Remember, "y" is yank, which is Vim's copy command.
    224   To insert the contents of the real clipboard before the cursor: >
    225 
    226 "+P
    227 
    228 It's the same as for the current selection, but uses the plus (+) register
    229 instead of the star "*" register.
    230 
    231 ==============================================================================
    232 *09.4*	Select mode
    233 
    234 And now something that is used more often on MS-Windows than on X-Windows.
    235 But both can do it.  You already know about Visual mode.  Select mode is like
    236 Visual mode, because it is also used to select text.  But there is an obvious
    237 difference: When typing text, the selected text is deleted and the typed text
    238 replaces it.
    239 
    240 To start working with Select mode, you must first enable it (for MS-Windows
    241 it is probably already enabled, but you can do this anyway): >
    242 
    243 :set selectmode+=mouse
    244 
    245 Now use the mouse to select some text.  It is highlighted like in Visual mode.
    246 Now press a letter.  The selected text is deleted, and the single letter
    247 replaces it.  You are in Insert mode now, thus you can continue typing.
    248 
    249 Since typing normal text causes the selected text to be deleted, you can not
    250 use the normal movement commands "hjkl", "w", etc.  Instead, use the shifted
    251 function keys.  <S-Left> (shifted cursor left key) moves the cursor left.  The
    252 selected text is changed like in Visual mode.  The other shifted cursor keys
    253 do what you expect.  <S-End> and <S-Home> also work.
    254 
    255 You can tune the way Select mode works with the 'selectmode' option.
    256 
    257 ==============================================================================
    258 
    259 Next chapter: |usr_10.txt|  Making big changes
    260 
    261 Copyright: see |manual-copyright|  vim:tw=78:ts=8:noet:ft=help:norl: