1. Introduction1.1 How to Start the GUI Version of VimFirst you must make sure you actually compile Vim with the GUI code included. You can check this with the ":version" command, it should include "+GUI_Motif" or "+GUI_Athena". Then you may run the GUI version of Vim in either of these ways:So if you call the executable "gvim", or make "gvim" a link to the executable, then the GUI version will automatically be used. You may also start up the GUI from within the terminal version by using one of these commands: When the GUI is started, it does a fork() and exits the current process. When gvim was started from a shell this makes the shell accept further commands. If you don't want this (e.g. when using gvim for a mail program that waits for gvim to exit), start gvim with "gvim -f" or use ":gui -f". If you want the GUI to run in the foreground always, include the 'f' flag in 'guioptions'. When the GUI starts up, the file ~/.gvimrc is sourced if it exists, and then the file ./.gvimrc. This file may contain commands to set up your own customised menus (see :menu) and initialise other things that you may want to set up differently from the terminal version. There are a number of options which only have meaning in the GUI version of Vim. These are 'guifont', 'quipty', and 'guioptions'. They are documented in vim_ref8.html with all the other options. If using the Motif or Athena version of the GUI (which is the only version at the moment), a number of X resources are available. You should use Vim's class "Vim" when setting these. They are as follows:
If any of these things are also set with Vim commands, eg with ":set guifont=Screen15", then this will override the X resources (currently 'guifont' is the only option that is supported). Here is an example of what you might put in your ~/.Xdefaults file:
2. ScrollbarsThere are vertical scrollbars and a horizontal scrollbars. You may configure which ones appear with the 'guioptions' option.The interface looks like this (with ":set guioptions=mlrb"): |
+------------------------------+ | File Edit Help | <- Menu bar (m) +-+--------------------------+-+ |^| |^| |#| Text area. |#| | | | | |v|__________________________|v| Normal status line -> |-+ File.c 5,2 +-| between Vim windows |^|""""""""""""""""""""""""""|^| | | | | | | Another file buffer. | | | | | | |#| |#| Left scrollbar (l) -> |#| |#| <- Right |#| |#| scrollbar (r) | | | | |v| |v| +-+--------------------------+-+ | |< #### >| | <- Bottom +-+--------------------------+-+ scrollbar (b)
|
Any of the scrollbar or menu components may be turned off by not putting the
appropriate letter in the 'guioptions' string. The bottom scrollbar is
only useful when 'nowrap' is set.
Each Vim window has a scrollbar next to it which may be scrolled up and down to move through the text in that buffer. The size of the scrollbar-thumb indicates the fraction of the buffer which can be seen in the window. When the scrollbar is dragged all the way down, the last line of the file will appear in the top of the window. The horizontal scrollbar (at the bottom of the Vim GUI) may be used to scroll text sideways when the 'wrap' option is turned off. The scrollbar-thumb size is such that the text of the current cursor line may be scrolled as far as possible left and right.
The mouse only works if the appropriate flag in the 'mouse' option is set. When the GUI is switched on the 'mouse' option is set to "a", enabling it for all modes except for the "hit return to continue" message. This can be changed from the "gvimrc" file. Click the left mouse button where you want the cursor to go, and it does! This works in normal mode (if 'mouse' contains 'n' or 'a'), visual mode (if 'mouse' contains 'v' or 'a') and insert mode (if 'mouse' contains 'i' or 'a'), if you click the mouse somewhere in a text buffer. You may use this with an operator such as 'd' to delete text from the current cursor position to the position you point to with the mouse. That is, you hit 'd' and then click the mouse somewhere. If you are on the ':' line (or '/' or '?'), then clicking the left or right mouse button will position the cursor on the ':' line (if 'mouse' contains 'c' or 'a'). In any situation the middle mouse button may be clicked to paste the current selection.
The right mouse button may be clicked somewhere to extend the visual selection to the position pointed to with the mouse. If already in visual mode then the closest end will be extended, otherwise visual mode is started and extends from the old cursor position to the new one. Double clicking may be done to make the selection word-wise, triple clicking makes it line-wise, and quadruple clicking makes it rectangular block-wise. Visual selection, however it is invoked, makes Vim the owner of the windowing system's primary selection, so that the highlighted text may be pasted into other windows. Similarly, selected text from other windows may be pasted into Vim in command mode, insert mode, or on the ':' line by clicking the middle mouse button.
When in Command line mode or at the hit-return prompt a different kind of
selection is used. It is more like what happens in an xterm. Let's call
this xterm-like selection. Any text in the Vim window can be selected.
Select the text by pressing the left mouse button at the start, drag to the
end and release. Right mouse button extends the selection. Middle mouse
button pasts the text.
Clicking the left or right mouse button on the status line below a Vim
window makes that window the current window. The mouse may then be dragged
up and down to move the status line, thus resizing the windows above and
below it.
3.6 Mouse MappingsThe mouse events, complete with modifiers, may be mapped. Eg:
Mouse mapping with modifiers does not work for xterm-like selection.
Note that when pasting text from one Vim into another separate Vim, the type of selection (character, line, or block) will also be copied. The default menus are quite simple at the moment. Power Vim users won't use them much. But the power is in adding your own menus and menu items. They are most useful for things that you can't remember what the key sequence was. Eventually I would like to expand the set of default menus to use pop up and other windows for confirmation, file selection etc. Maybe have a dialogue box for browsing and choosing buffers, etc.
This last one will create a new item in the menu bar called "Edit", holding
the mouse button down on this will pop up a menu containing the item
"Big Changes", which is a sub-menu containing the item "Delete All Spaces",
which when selected, performs the operation.
Note that hitting
This will remove the Paste item from the Edit menu for insert and
command-line modes.
Note that hitting
:nmenu Words.Add\\ Var wb"zye:menu! Words.<C-R>z <C-R>z<CR>
(<> notation: \\ is backslash, <C-R> is CTRL-R)
Alternatively a pseudo-tty can be used. Unfortunately, the implementation of
this is different on every Unix system. And many systems require root
permission. Still this might work better than pipes on some systems. To
see if this works better for you set the 'guipty' option on. Be prepared to
"kill" the started command or Vim, commands like ":r !cat" may hang!
|