Updated help files
[MacVim/jjgod.git] / runtime / doc / gui_mac.txt
blob98b703426ede1383428c6f11445c055fbdeec9cd
1 *gui_mac.txt*   For Vim version 7.1.  Last change: 2007 Nov 11
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              |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: >
47         :tabe $VIM/gvimrc
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".
51                                                         *macvim-windows*
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
57 a window.
59                                                         *macvim-encoding*
60 It is not possible to modify 'termencoding' in MacVim; this option is forcibly
61 set to "utf-8".  The option 'encoding' also defaults to "utf-8" (as opposed to
62 "latin1" in the other GUI ports).
64 Note: UTF-8 can represent all characters defined in Unicode, which includes
65 all characters in all other standard encodings, so it should be perfectly safe
66 to edit files in any encoding while 'encoding' is set to "utf-8".  Of course,
67 you may need to set 'fileencodings' to auto-detect the encoding of the files
68 you edit, or force the detection with |++enc| on the command line.
70 However, if you are editing files that use multiple encodings (container
71 formats like MIME or Unix mbox files) or no standard encoding (binary data,
72 see also |edit-binary|), you may want to prevent MacVim from re-encoding the
73 file at all. In this situation, you will need to set both 'encoding' and
74 'fileencodings' to a simple single-byte encoding such as Latin1 so that when
75 the file is read into memory, the original bytes are left untouched.
77                                                         *macvim-movement*
78 Some Mac OS X standard key mappings involving Cmd or Option and an arrow key
79 are set up by default in "$VIM/gvimrc".  You can quickly disable all of these
80 by adding the following lines to your "~/.vimrc" (not .gvimrc) file: >
81         if has("gui_macvim")
82           let macvim_skip_cmd_opt_movement = 1
83         endif
84 Note: These are the only key mappings that MacVim make (not counting menu key
85 equivalents which are not set up with :map).
87                                                         *macvim-shift-movement*
88 Text editors on Mac OS X lets the user hold down shift+movement key to extend
89 the selection.  Also, pressing a printable key whilst selecting replaces the
90 current selection with that character.  MacVim can emulate this kind of
91 behaviour (by providing key bindings and by setting 'keymodel' and
92 'selectmode' to non-default values) although it is not enabled by default.  To
93 make MacVim behave more like TextEdit and less like Vim, add the following
94 lines to your "~/.vimrc" (not .gvimrc) file: >
95         if has("gui_macvim")
96           let macvim_hig_shift_movement = 1
97         endif
99                                                         *macvim-drag-n-drop*
100 Dragging files and dropping them on a window opens those files in tabs in that
101 window, unless Vim is in command-line mode.  In command-line mode the names of
102 the files are added to the command line.  Holding down modifier keys whilst
103 dragging is not supported.
105                                                         *macvim-default-menu*
106 The default menu in MacVim has been changed to conform better with the Apple
107 Human Interface Guidelines (HIG).  At the moment this breaks the localized
108 menus, so only English menus are supported.
110 Note: The menus are a work in progress.  If you know something about the HIG
111 and want to contribute to MacVim you could do so by making the menus better.
113                                                         *macvim-window-title*
114 The default window title does not include the argument list because it looks
115 really bad once you start using tabs.  For example, dropping two files, then
116 dropping two more, and switching back to the first tab would cause weird
117 strings like "((3) of 2)" to appear in the window title.
119                                                         *macvim-options*
120 These are the non-standard options that MacVim supports:
121         'fullscreen' 'toolbariconsize' 'transparency'
123 ==============================================================================
124 2. Starting MacVim                                      *macvim-start*
126 The easiest way to start MacVim is by double-clicking its icon in the Finder,
127 but most users will probably prefer to use the Terminal.  First some Finder
128 related ways of starting MacVim are described, then Terminal is discussed.
129 Note that you can put MacVim anywhere on your hard drive, but in this help
130 file it is assumed that you have put it inside your /Applications folder.
132 MacVim automatically registers itself as an editor of several standard file
133 formats.  This enables you to double-click a file to open it with MacVim (if
134 it is not associated with another program), or to right-click a file to bring
135 up the "Open with" menu.  You can also drag and drop files onto the Dock icon
136 to open them in tabs in a new window, or you can drop them in an already open
137 window to open the files in tabs in that specific window.  Finally, you can
138 use Mac OS X System Services to open files in MacVim, see |macvim-services|.
140 There are essentially two ways to start MacVim from Terminal: either call the
141 Vim binary with the -g switch >
142         /Applications/MacVim.app/Contents/MacOS/Vim -g file ...
143 or use the "open" command (which is of limited use since it cannot be used to
144 pass parameters to Vim) >
145         open -a MacVim file ...
147                                                         *mvim*
148 To save yourself from having to type the entire path to the Vim binary each
149 time you start MacVim, you could create an alias such as >
150         alias gvim='/Applications/MacVim.app/Contents/MacOS/Vim -g'
151 and add that to "~/.profile".  A more flexible way to start MacVim is to use
152 the shell script "mvim" which comes bundled with MacVim.  Put this script in a
153 folder in your path and then simply type "mvim" to start MacVim.  This script
154 will try to find MacVim.app in various typical folders such as >
155         ~/Applications              ~/Applications/vim
156         /Applications               /Applications/vim
157         /Applications/Utilities     /Applications/Utilities/vim
158 If you would rather put MacVim.app in some other directory then that is also
159 possible, simply set the environment variable VIM_APP_DIR to whatever folder
160 you have placed MacVim.app in.
162 Once in terminal Vim it is possible to start MacVim by using the following
163 command:
164         :gui [++opt] [+cmd] [-f|-b] [files...]
165 Note: Forking ("-b") currently does not work.
167 ==============================================================================
168 3. Special colors                                       *macvim-colors*
170 The colors in MacVim are defined in two dictionaries inside the "Resources"
171 folder of the application bundle (MacVim.app/Contents/Resources).  It is
172 possible to add more colors by modifying these files.  Color names are case
173 insensitive when accessed from Vim, but in the dictionary they must be
174 lowercase.
176                                                         *SystemColors.plist*
177 There are only a few system colors that can be accessed from Vim.  These
178 colors are defined in the dictionary "SystemColors.plist".  This dictionary
179 stores (key, value) pairs where the key is the name of the color and the
180 value is an NSColor selector name.
182 The most useful system colors are: >
183         MacSelectedTextBackgroundColor
184         MacSecondarySelectedColor
185 The former is the "Highlight Color" which can be changed in the "Appearance"
186 section of the System Preferences.  The latter is the selection color used by
187 a Cocoa application when it is not in focus.
189                                                         *Colors.plist*
190 Apart from the system colors, it is also possible to use the standard X11
191 color names (see http://en.wikipedia.org/wiki/X11_color_names) which usually
192 come in a file called "rgb.txt".  MacVim does not have such a file, instead it
193 keeps these colors in a dictionary called "Colors.plist". The key in this
194 dictionary is the name of the color and the value is an RGB value on the form
195 #rrggbb stored as an integer.
197                                                         *macvim-colorscheme*
198 MacVim ships with a custom colorscheme that can be used as an alternative to
199 the default Vim colorscheme.  You can try it out by typing: >
200         :colorscheme macvim
201 The colorscheme uses the the system "Highlight Color", which can be changed in
202 the "Appearance" pane of the System Preferences.  It also changes the
203 highlight color when a window becomes inactive.
205 If you have any comments regarding this colorscheme (is it better or worse
206 than the default?) then post them to vim_mac.
208 ==============================================================================
209 4. Menus                                                *macvim-menus*
211                                                 *:macm* *:macmenukey*
212 MacVim has a special way of binding keys to menu items that differs from other
213 Vim GUI ports.  A menu binding is called a "key equivalent" in Mac OS X
214 terminology, this is displayed on the right side of a menu item.  The
215 ":macmenukey" command is used to set the key equivalent of a menu item.  This
216 command takes two parameters, the first names the menu item to bind to, the
217 second gives the key combination.  For example: >
218         :macmenukey File.New\ Tab <D-t>
219 This sets the key equivalent of the "New Tab" menu item under the "File" menu
220 to Cmd+t.
222 Note that key equivalents:
223         * must contain the Cmd modifier flag (<D-...>)
224         * take precedence over normal mappings made with ":map"
225         * can only be modified during startup (e.g. in .gvimrc)
227 It is possible to reset a key equivalent by calling :macmenukey with a menu
228 name but no key.  This is so that the default key equivalents can be reset in
229 "~/.gvimrc".  For example, if you would like to free up <D-s> (which is the
230 key equivalent of "File.Save") then add the following line to "~/.gvimrc": >
231         macmenukey File.Save
232 Now you can use :map to bind <D-s> to whatever you like.
234 It is not necessary to reset a key equivalent if all you want to do is to
235 change the key equivalent of a menu item.  For example, say you want to use
236 <D-M-Right> as the key equivalent for "Next Tab", then add the following line
237 to "~/.gvimrc": >
238         macmenukey Window.Next\ Tab <D-M-Right>
240                                                 *:maca* *:macaction*
241 It is typical for menu items in Cocoa applications to bind to Objective-C
242 selectors.  To support this, MacVim introduces the ":macaction" command.  This
243 command takes the name of an action message as its only parameter.  (An action
244 message is an Objective-C message with "void" return type and a single
245 parameter of type "id".)  For example, the "New Window" menu item on the
246 "File" menu is created in the following manner: >
247         :an 10.290 File.New\ Window :macaction newWindow:<CR>
249 Note 1: A menu item which is bound to ":macaction" will automatically be bound
250 to that action in all modes (as if ":an" was used).  It is not possible to
251 bind to ":macaction" in one mode only.
252 Note 2: The action is "nil-targeted", which means it is passed down the first
253 responder chain.
255                                                         *Actions.plist*
256 Some action messages would not be suitable to call from within Vim, so there
257 is a dictionary called "Actions.plist" (in the Resources folder of the
258 application bundle) which contains all actions that may be called.  The key in
259 this dictionary is the name of the action message (case sensitive), the value
260 is not used.
262 Here is a random assortment of actions from Actions.plist which might be
263 useful.
265 Action                          Description ~
266 fontSizeDown:                   Decrease font size
267 fontSizeUp:                     Increase font size
268 newWindow:                      Open a new (empty) window
269 orderFrontCharacterPalette:     Show the the "Special Characters" dialog
270 orderFrontFontPanel:            Show the Font panel
271 performZoom:                    Zoom window (same as clicking the green blob)
272 selectNextWindow:               Select next window (similar to <D-`>)
273 selectPreviousWindow:           Select previous window (similar to <S-D-`>)
275 As an example, to map <C-z> to performZoom: you could do something like this: >
276         :map <silent> <C-z> :macaction performZoom:<CR>
277 A better way to map to performZoom: would be to set the key equivalent of the
278 menu item "Window.Zoom" to the above action.  This can be done by adding the
279 following line to "~/.gvimrc": >
280         macmenukey Window.Zoom <D-C-z>
281 (Note that key equivalents must contain the 'D' flag.)
283 ==============================================================================
284 5. Toolbar                                              *macvim-toolbar*
286 The toolbar in MacVim works just like in the other GUIs (see |gui-toolbar|),
287 with the addition of two separator items (see |menu-separator|).  You can use
288 them as follows: >
289         :an ToolBar.-space1-        <Nop>
290         :an ToolBar.-flexspace2-    <Nop>
291 The first example creates an empty space on the toolbar, the second creates an
292 empty space which will shink or expand so that the items to the right of it
293 are right-aligned.  A space (flexspace) will be created for any toolbar item
294 whose name begins with "-space" ("-flexspace") and ends with "-"
296 Note: Only a subset of the builtin toolbar items presently have icons.  If no
297 icon can be found a warning triangle is displayed instead.
299 ==============================================================================
300 6. Dialogs                                              *macvim-dialogs*
302 Dialogs can be controlled with the keyboard in two ways.  By default each
303 button in a dialog is bound to a key.  The button that is highlighted by blue
304 is bound to Enter, and any button with the title "Cancel" is bound to Escape.
305 Other buttons are usually bound to the first letter in the title of the
306 button.  There is no visual feedback to indicate which letter a button is
307 bound to, so sometimes some experimentation might be required in order to
308 figure out which key to press.
310 The second way of controlling dialogs with the keyboard is to enable "Full
311 keyboard access" in the "Keyboard & Mouse" pane of the System Preferences (you
312 can also toggle this on or off by pressing Ctrl-F7).  Once keyboard access is
313 enabled it is possible to move between buttons with Tab and pressing Space to
314 select the current button.  The current button is indicated with a blue
315 outline.
317 ==============================================================================
318 7. System services                                      *macvim-services*
320 MacVim supports a few system services.  These can be accessed from the MacVim
321 submenu in the Services menu.  For services to work, MacVim.app should be
322 located in the /Applications folder.  (You might have to logout and then login
323 again before Mac OS X detects the MacVim services.)
325 These are the currently supported services:
326 * New Tab Containing Selection: Opens a new tab in the topmost window and
327   pastes the currently selected text in that tab.  A new window will be
328   opened if necessary.
329 * Open Selected File in Tab: If the selected text represents a file
330   name, then the corresponding file is opened in a new tab in the topmost
331   window.
332 * Open Selected File in Window: Same as the above, but always open in a new
333   window.
335 ==============================================================================
336 8. Known bugs/missing features                          *macvim-todo*
338 Here are some of the bigger bugs in MacVim.  Of course there are others, but
339 these are ones that are know and/or which were judged major.
341 - Localized menus are not supported.  Choosing anything but "English" in the
342   "International" pane of "System Prefences" may break the menus (and
343   toolbar).
344 - Some Unicode characters are not handled well (e.g. nonspacing marks)
345 - Sometimes multibyte characters look "too wide", i.e. they overlap the
346   following character.  It might help to change 'ambiwidth', or override the
347   automatic font substitution by setting 'guifontwide' manually.
348 - Printing
349 - No find/replace dialog
351 If you find new bugs then add a new issue at http://code.google.com/p/macvim/
352 or post your findings to the vim_mac mailing list.  If you are missing feature
353 X in MacVim then voice your opinion on the vim_mac mailing list; it might be
354 simple to implement, but unless somebody asks for a particular feature then
355 there is little incentive to add it.
357 ==============================================================================
358 9. Hints                                                *macvim-hints*
360 In this section some general (not necessarily MacVim specific) hints are
361 given.
363 Scenario: ~
364 You try opening a bunch of files in tabs but not all files get
365 opened in their own tab.
366 Solution: ~
367 To get around this, set 'tabpagemax' to something big in your
368 .gvimrc file (e.g. ":set tabpagemax=100").
370 Scenario: ~
371 You want to open a file in a tab in an already opened window, but typing
372 "mvim filename" in Terminal opens it up in a separate window.
373 Solution: ~
374 Use the |--remote-tab| switch.  If you have several windows open you
375 might have to specify which window you want the file to open in by using the
376 |--servername| switch.  The title of a window usually ends in something like
377 "VIM" or "VIM3" --- this is the server name of that window.  So to open a file
378 named "foobar.txt" in a window whose title ends in "VIM3" you would type (the
379 order of the arguments matters): >
380         mvim --servername VIM3 --remote-tab foobar.txt
381 For more information, consult the |client-server| manual page.
383 Scenario: ~
384 You like to be able to select text by holding down shift and
385 pressing the arrow keys and find the Vim way of selecting text strange.
386 Solution: ~
387 See |macvim-shift-movement|.
389 Scenario: ~
390 You do not want MacVim to set up any key mappings.
391 Solution: ~
392 See |macvim-movement|.
394 Scenario: ~
395 Enabling localized menus breaks the toolbar and the menus as well.
396 Solution: ~
397 This is a know problem, see |macvim-todo|.
399 Scenario: ~
400 You dislike the default font (DejaVu Sans Mono).
401 Solution: ~
402 The standard fixed width font on other Mac OS X applications is
403 Monaco.  If you prefer this font then add the following line to your
404 "~/.gvimrc" (note that Monaco does not come in italic and bold variants): >
405         set guifont=Monaco:h10
406 The suffix ":h10" specifies the point size of the font should be "10" (see
407 'guifont' for more information on how to set the font).
409 Scenario: ~
410 When you click the (green) zoom button you want the window to maximize
411 horizontally as well as vertically.
412 Solution: ~
413 Hold down Cmd and click the zoom button.
415 Scenario: ~
416 Typing feels sluggish when the cursor is just before a right bracket (i.e. ')',
417 '}', or ']').
418 Solution: ~
419 Disable the "matchparen" plugin (see |matchparen|) by typing :NoMatchParen.
420 If that helps, then you can permanently disable "matchparen" by adding the
421 following line to your "~/.vimrc": >
422         let loaded_matchparen=1
425 Scenario: ~
426 You can't find the information on MacVim you thought should be in
427 this manual page.
428 Solution: ~
429 Post your question on the vim_mac mailing list and wait for an
430 answer.
432  vim:tw=78:sw=4:ts=8:ft=help:norl: