1 *gui_mac.txt* For Vim version 7.1. Last change: 2007 Sep 18
4 VIM REFERENCE MANUAL by Bjorn Winckler
7 The MacVim Graphical User Interface *macvim* *gui-macvim*
9 0. Important! |macvim-important|
10 1. MacVim differences |macvim-differences|
11 2. Starting MacVim |gui-macvim-start|
12 3. Special colors |macvim-colors|
13 4. Menus |macvim-menus|
14 5. Toolbar |macvim-toolbar|
15 6. Dialogs |macvim-dialogs|
16 7. System services |macvim-services|
17 8. Known bugs/missing features |macvim-todo|
18 9. Hints |macvim-hints|
20 Other relevant documentation:
21 |gui.txt| For generic items of the GUI.
22 |os_mac.txt| For Mac specific items.
24 {Vi does not have a GUI}
26 ==============================================================================
27 0. Important! *macvim-important*
29 MacVim is still under development...this is not the finished product! If you
30 have problems with MacVim then make it known either by adding an issue report
31 on the MacVim project page >
32 http://code.google.com/p/macvim
33 or by posting to the vim_mac mailing list >
34 http://groups.google.com/group/vim_mac
36 Remember to keep checking the project page for new snapshots. (If you
37 downloaded this copy from somewhere else, you might want to go there now to
38 make sure that you have got the latest version.)
40 ==============================================================================
41 1. MacVim differences *macvim-differences*
43 One of the goals of MacVim is to make Vim behave like a proper Mac OS X
44 application. For this reason MacVim behaves slightly different from other GUI
45 ports of Vim. Most of the modifications are provided in the system gvimrc
46 file; you can quickly open this file and look at it yourself by typing: >
48 Note that this file will be overwritten each time you update MacVim, so it is
49 better to keep your own modifications inside "~/.gvimrc".
52 There is some confusion regarding the term "window" in MacVim since it means
53 one thing to Vim and another to MacVim. A "window" in Vim is what opens up
54 when you type ":sp", whereas a "window" in MacVim is the GUI window which
55 contains the text view, scrollbars, toolbar and tabline. To avoid confusion,
56 the former is referred to as a Vim-window, whereas the latter is simply called
60 It is not possible to modify 'termencoding' in MacVim; this option is forcibly
61 set to "utf-8". The most natural value for 'encoding' is "utf-8" as well, but
62 this is not the default for reasons explained in the help for 'encoding'. If
63 you want to edit files with non-English characters you should add the
64 following line to "~/.gvimrc": >
67 *macvim-shift-movement*
68 Text editors on Mac OS X lets the user hold down shift+movement key to extend
69 the selection. Also, pressing a printable key whilst selecting replaces the
70 current selection with that character. MacVim can emulate this kind of
71 behaviour (by providing key bindings and by setting 'keymodel' and
72 'selectmode' to non-default values) although it is not enabled by default. To
73 make MacVim behave more like TextEdit and less like Vim, add the following
74 lines to your "~/.vimrc" (not .gvimrc) file: >
76 let macvim_hig_shift_movement = 1
80 Dragging files and dropping them on a window opens those files in tabs in that
81 window, unless Vim is in command-line mode. In command-line mode the names of
82 the files are added to the command line. Holding down modifier keys whilst
83 dragging is not supported.
86 The default menu in MacVim has been changed to conform better with the Apple
87 Human Interface Guidelines (HIG). At the moment this breaks the localized
88 menus, so only English menus are supported.
90 Note: The menus are a work in progress. If you know something about the HIG
91 and want to contribute to MacVim you could do so by making the menus better.
93 ==============================================================================
94 2. Starting MacVim *gui-macvim-start*
96 The easiest way to start MacVim is by double-clicking its icon in the Finder,
97 but most users will probably prefer to use the Terminal. First some Finder
98 related ways of starting MacVim are described, then Terminal is discussed.
99 Note that you can put MacVim anywhere on your hard drive, but in this help
100 file it is assumed that you have put it inside your /Applications folder.
102 MacVim automatically registers itself as an editor of several standard file
103 formats. This enables you to double-click a file to open it with MacVim (if
104 it is not associated with another program), or to right-click a file to bring
105 up the "Open with" menu. You can also drag and drop files onto the Dock icon
106 to open them in tabs in a new window, or you can drop them in an already open
107 window to open the files in tabs in that specific window. Finally, you can
108 use Mac OS X System Services to open files in MacVim, see |macvim-services|.
110 There are essentially two ways to start MacVim from Terminal: either call the
111 Vim binary with the -g switch >
112 /Applications/MacVim.app/Contents/MacOS/Vim -g file ...
113 or use the "open" command (which is of limited use since it cannot be used to
114 pass parameters to Vim) >
115 open -a MacVim file ...
117 In order to save you from having to type the entire path every time you start
118 MacVim, add the following alias to "~/.profile": >
119 alias gvim='/Applications/MacVim.app/Contents/MacOS/Vim -g'
121 Once in terminal Vim it is possible to start MacVim by using the following
123 :gui [++opt] [+cmd] [-f|-b] [files...]
124 Note: Forking ("-b") currently does not work.
126 ==============================================================================
127 3. Special colors *macvim-colors*
129 The colors in MacVim are defined in two dictionaries inside the "Resources"
130 folder of the application bundle (MacVim.app/Contents/Resources). It is
131 possible to add more colors by modifying these files. Color names are case
132 insensitive when accessed from Vim, but in the dictionary they must be
136 There are only a few system colors that can be accessed from Vim. These
137 colors are defined in the dictionary "SystemColors.plist". This dictionary
138 stores (key, value) pairs where the key is the name of the color and the
139 value is an NSColor selector name.
141 The most useful system colors are: >
142 MacSelectedTextBackgroundColor
143 MacSecondarySelectedColor
144 The former is the "Highlight Color" which can be changed in the "Appearance"
145 section of the System Preferences. The latter is the selection color used by
146 a Cocoa application when it is not in focus.
149 Apart from the system colors, it is also possible to use the standard X11
150 color names (see http://en.wikipedia.org/wiki/X11_color_names) which usually
151 come in a file called "rgb.txt". MacVim does not have such a file, instead it
152 keeps these colors in a dictionary called "Colors.plist". The key in this
153 dictionary is the name of the color and the value is an RGB value on the form
154 #rrggbb stored as an integer.
157 MacVim ships with a custom colorscheme that can be used as an alternative to
158 the default Vim colorscheme. You can try it out by typing: >
160 The colorscheme uses the the system "Highlight Color", which can be changed in
161 the "Appearance" pane of the System Preferences. It also changes the
162 highlight color when a window becomes inactive.
164 If you have any comments regarding this colorscheme (is it better or worse
165 than the default?) then post them to vim_mac.
167 ==============================================================================
168 4. Menus *macvim-menus*
171 MacVim has a special way of binding keys to menu items that differs from other
172 Vim GUI ports. A menu binding is called a "key equivalent" in Mac OS X
173 terminology, this is displayed on the right side of a menu item. The
174 ":menukeyequiv" command is used to set the key equivalent of a menu item.
175 This command takes two parameters, the first names the menu item to bind to,
176 the second gives the key combination. For example: >
177 :menukeyequiv File.New\ Tab <D-t>
178 This sets the key equivalent of the "New Tab" menu item under the "File" menu
181 Note that key equivalents:
182 * must contain the Cmd modifier flag (<D-...>)
183 * take precedence over normal mappings made with ":map"
184 * can only be modified during startup (e.g. in .gvimrc)
186 It is possible to reset a key equivalent by calling :menukeyequiv with a menu
187 name but no key. This is so that the default key equivalents can be reset in
188 "~/.gvimrc". For example, if you would like to free up <D-s> (which is the
189 key equivalent of "File.Save") then add the following line to "~/.gvimrc": >
190 menukeyequiv File.Save
191 Now you can use :map to bind <D-s> to whatever you like.
193 It is not necessary to reset a key equivalent if all you want to do is to
194 change the key equivalent of a menu item. For example, say you want to use
195 <D-M-Right> as the key equivalent for "Next Tab", then add the following line
197 menukeyequiv Window.Next\ Tab <D-M-Right>
200 It is typical for menu items in Cocoa applications to bind to Objective-C
201 selectors. To support this, MacVim introduces the ":action" command. This
202 command takes the name of an action message as its only parameter. (An action
203 message is an Objective-C message with "void" return type and a single
204 parameter of type "id".) For example, the "New Window" menu item on the
205 "File" menu is created in the following manner: >
206 :an 10.290 File.New\ Window :action newWindow:<CR>
208 Note 1: A menu item which is bound to ":action" will automatically be bound to
209 that action in all modes (as if ":an" was used). It is not possible to bind
210 to ":action" in one mode only.
211 Note 2: The action is "nil-targeted", which means it is passed down the first
215 Some action messages would not be suitable to call from within Vim, so there
216 is a dictionary called "Actions.plist" (in the Resources folder of the
217 application bundle) which contains all actions that may be called. The key in
218 this dictionary is the name of the action message (case sensitive), the value
221 Here is a random assortment of actions from Actions.plist which might be
225 newWindow: Open a new (empty) window
226 orderFrontCharacterPalette: Show the the "Special Characters" dialog
227 orderFrontFontPanel: Show the Font panel
228 performZoom: Zoom window (same as clicking the green blob)
229 selectNextWindow: Select next window (similar to <D-`>)
230 selectPreviousWindow: Select previous window (similar to <S-D-`>)
232 As an example, to map <C-z> to performZoom: you could do something like this: >
233 :map <silent> <C-z> :action performZoom:<CR>
234 A better way to map to performZoom: would be to set the key equivalent of the
235 menu item "Window.Zoom" to the above action. This can be done by adding the
236 following line to "~/.gvimrc": >
237 menukeyequiv Window.Zoom <D-C-z>
238 (Note that key equivalents must contain the 'D' flag.)
240 ==============================================================================
241 5. Toolbar *macvim-toolbar*
243 The toolbar in MacVim works just like in the other GUIs (see |gui-toolbar|),
244 with the addition of two separator items (see |menu-separator|). You can use
246 :an ToolBar.-space1- <Nop>
247 :an ToolBar.-flexspace2- <Nop>
248 The first example creates an empty space on the toolbar, the second creates an
249 empty space which will shink or expand so that the items to the right of it
250 are right-aligned. A space (flexspace) will be created for any toolbar item
251 whose name begins with "-space" ("-flexspace") and ends with "-"
253 Note: Only a subset of the builtin toolbar items presently have icons. If no
254 icon can be found a warning triangle is displayed instead.
256 ==============================================================================
257 6. Dialogs *macvim-dialogs*
259 Dialogs can be controlled with the keyboard in two ways. By default each
260 button in a dialog is bound to a key. The button that is highlighted by blue
261 is bound to Enter, and any button with the title "Cancel" is bound to Escape.
262 Other buttons are usually bound to the first letter in the title of the
263 button. There is no visual feedback to indicate which letter a button is
264 bound to, so sometimes some experimentation might be required in order to
265 figure out which key to press.
267 The second way of controlling dialogs with the keyboard is to enable "Full
268 keyboard access" in the "Keyboard & Mouse" pane of the System Preferences (you
269 can also toggle this on or off by pressing Ctrl-F7). Once keyboard access is
270 enabled it is possible to move between buttons with Tab and pressing Space to
271 select the current button. The current button is indicated with a blue
274 ==============================================================================
275 7. System services *macvim-services*
277 MacVim supports a few system services. These can be accessed from the MacVim
278 submenu in the Services menu. For services to work, MacVim.app should be
279 located in the /Applications folder. (You might have to logout and then login
280 again before Mac OS X detects the MacVim services.)
282 These are the currently supported services:
283 * New Tab Containing Selection: Opens a new tab in the topmost window and
284 pastes the currently selected text in that tab. A new window will be
286 * Open Selected File in Tab: If the selected text represents a file
287 name, then the corresponding file is opened in a new tab in the topmost
289 * Open Selected File in Window: Same as the above, but always open in a new
292 ==============================================================================
293 8. Known bugs/missing features *macvim-todo*
295 Here are some of the bigger bugs in MacVim. Of course there are others, but
296 these are ones that are know and/or which were judged major.
298 - Localized menus are not supported. Choosing anything but "English" in the
299 "International" pane of "System Prefences" may break the menus (and
301 - Composing characters are not supported, they will mess up the display
302 - Sometimes multibyte characters look "too wide", i.e. they overlap the
303 following character. It might help to change 'ambiwidth'.
305 - No find/replace dialog
307 If you find new bugs then add a new issue at http://code.google.com/p/macvim/
308 or post your findings to the vim_mac mailing list. If you are missing feature
309 X in MacVim then voice your opinion on the vim_mac mailing list; it might be
310 simple to implement, but unless somebody asks for a particular feature then
311 there is little incentive to add it.
313 ==============================================================================
314 9. Hints *macvim-hints*
316 In this section some general (not necessarily MacVim specific) hints are
320 You open a file which contain non-English characters, and all you see is lots
321 of upside-down question marks.
323 Set the 'encoding' option to "utf-8". To make Vim remember this setting
324 between sessions, add the following line to your "~/.gvimrc": >
326 Be aware that changing 'encoding' has certain side-effects which are
327 documented in the help for 'encoding'.
330 You try opening a bunch of files in tabs but not all files get
331 opened in their own tab.
333 To get around this, set 'tabpagemax' to something big in your
334 .gvimrc file (e.g. ":set tabpagemax=100").
337 You want to open a file in a tab in an already opened window, but
338 typing "gvim filename" in Terminal opens it up in a separate window.
340 Use the |--remote-tab| switch. If you have several windows open you
341 might have to specify which window you want the file to open in by using the
342 |--servername| switch. The title of a window usually ends in something like
343 "VIM" or "VIM3" --- this is the server name of that window. So to open a file
344 named "foobar.txt" in a window whose title ends in "VIM3" you would type (the
345 order of the arguments matters): >
346 gvim --servername VIM3 --remote-tab foobar.txt
347 For more information, consult the |client-server| manual page.
350 You like to be able to select text by holding down shift and
351 pressing the arrow keys and find the Vim way of selecting text strange.
353 See |macvim-shift-movement|.
356 Enabling localized menus breaks the toolbar and the menus as well.
358 This is a know problem, see |macvim-todo|.
361 You dislike the default font (Bitstream Vera).
363 The standard fixed width font on other Mac OS X applications is
364 Monaco. If you prefer this font then add the following line to your
365 "~/.gvimrc" (note that Monaco does not come in italic and bold variants): >
366 set guifont=Monaco:h10
367 The suffix ":h10" specifies the point size of the font should be "10" (see
368 'guifont' for more information on how to set the font).
371 When you click the (green) zoom button you want the window to maximize
372 horizontally as well as vertically.
374 Hold down Cmd and click the zoom button.
377 You can't find the information on MacVim you thought should be in
380 Post your question on the vim_mac mailing list and wait for an
383 vim:tw=78:sw=4:ts=8:ft=help:norl: