Add user default to toggle the "add tab" button
[MacVim.git] / runtime / doc / gui_mac.txt
blob2d450f20180bd43f3191c1de90ed0c8a28761e93
1 *gui_mac.txt*   For Vim version 7.2.  Last change: 2009 Jan 04
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. Preferences                 |macvim-preferences|
13  4. Special colors              |macvim-colors|
14  5. Menus                       |macvim-menus|
15  6. Toolbar                     |macvim-toolbar|
16  7. Dialogs                     |macvim-dialogs|
17  8. System services             |macvim-services|
18  9. mvim:// URL handler         |macvim-url-handler|
19 10. Keyboard shortcuts          |macvim-shortcuts|
20 11. Known bugs/missing features |macvim-todo|
21 12. Hints                       |macvim-hints|
23 Other relevant documentation:
24 |gui.txt|       For generic items of the GUI.
26 {Vi does not have a GUI}
28 ==============================================================================
29 0. Important!                                           *macvim-important*
31 MacVim is still under development...this is not the finished product!  If you
32 have problems with MacVim then make it known either by adding an issue report
33 on the MacVim project page >
34         http://code.google.com/p/macvim
35 or by posting to the vim_mac mailing list               *vim_mac*  >
36         http://groups.google.com/group/vim_mac
38 Remember to keep checking the project page for new snapshots or use the
39 automatic updating feature which can be enabled in the preferences pane.  (If
40 you downloaded this copy from somewhere else, you might want to go there now
41 to make sure that you have got the latest version.)
43 ==============================================================================
44 1. MacVim differences                                   *macvim-differences*
46 One of the goals of MacVim is to make Vim behave like a proper Mac OS X
47 application.  For this reason MacVim behaves slightly different from other GUI
48 ports of Vim.  Most of the modifications are provided in the system gvimrc
49 file; you can quickly open this file and look at it yourself by typing: >
50         :tabe $VIM/gvimrc
51 Note that this file will be overwritten each time you update MacVim, so it is
52 better to keep your own modifications inside "~/.gvimrc".
54                                                         *macvim-windows*
55 There is some confusion regarding the term "window" in MacVim since it means
56 one thing to Vim and another to MacVim.  A "window" in Vim is what opens up
57 when you type ":sp", whereas a "window" in MacVim is the GUI window which
58 contains the text view, scrollbars, toolbar and tabline.  To avoid confusion,
59 the former is referred to as a Vim-window, whereas the latter is simply called
60 a window.
62                                                         *macvim-encoding*
63 It is not possible to modify 'termencoding' in MacVim; this option is forcibly
64 set to "utf-8".  The option 'encoding' also defaults to "utf-8" (as opposed to
65 "latin1" in the other GUI ports).
67 Note: UTF-8 can represent all characters defined in Unicode, which includes
68 all characters in all other standard encodings, so it should be perfectly safe
69 to edit files in any encoding while 'encoding' is set to "utf-8".  Of course,
70 you may need to set 'fileencodings' to auto-detect the encoding of the files
71 you edit, or force the detection with |++enc| on the command line.
73 However, if you are editing files that use multiple encodings (container
74 formats like MIME or Unix mbox files) or no standard encoding (binary data,
75 see also |edit-binary|), you may want to prevent MacVim from re-encoding the
76 file at all. In this situation, you will need to set both 'encoding' and
77 'fileencodings' to a simple single-byte encoding such as Latin1 so that when
78 the file is read into memory, the original bytes are left untouched.
80                                                         *macvim-shift-movement*
81 Text editors on Mac OS X lets the user hold down shift+movement key to extend
82 the selection.  Also, pressing a printable key whilst selecting replaces the
83 current selection with that character.  MacVim can emulate this kind of
84 behaviour (by providing key bindings and by setting 'keymodel' and
85 'selectmode' to non-default values) although it is not enabled by default.  To
86 make MacVim behave more like TextEdit and less like Vim, add the following
87 lines to your "~/.vimrc" (not .gvimrc) file: >
88         if has("gui_macvim")
89           let macvim_hig_shift_movement = 1
90         endif
92                                                         *macvim-drag-n-drop*
93 Dragging files and dropping them on a window opens those files in tabs in that
94 window, unless Vim is in command-line mode.  In command-line mode the names of
95 the files are added to the command line.  Holding down modifier keys whilst
96 dragging is not supported.
98 If a file is dropped on the Dock icon, it is always opened in a new tab
99 regardless of the mode Vim is currently in.  The same holds if you
100 double-click on a file in the Finder.
102 The "Open files from applications" preference in the General preference pane
103 gives more options on how dropped files should open, in case tabs are not
104 desired.
106                                                         *macvim-default-menu*
107 The default menu in MacVim has been changed to conform better with the Apple
108 Human Interface Guidelines (HIG).  At the moment this breaks the localized
109 menus, so only English menus are supported.
111 Note: The menus are a work in progress.  If you know something about the HIG
112 and want to contribute to MacVim you could do so by making the menus better.
114                                                         *macvim-window-title*
115 The default window title does not include the argument list because it looks
116 really bad once you start using tabs.  For example, dropping two files, then
117 dropping two more, and switching back to the first tab would cause weird
118 strings like "((3) of 2)" to appear in the window title.
120                                                         *macvim-options*
121 These are the non-standard options that MacVim supports:
122         'antialias'     'fullscreen'            'fuoptions'
123         'macmeta'       'toolbariconsize'       'transparency'
125                                                         *macvim-commands*
126 These are the non-standard commands that MacVim supports:
127         |:macaction|    |:macmenu|
129                                                         *macvim-find*
130 Whenever you search for something in Vim (e.g. using "/") the search query is
131 copied to the OS X "Find Pasteboard".  The idea is that if you search for
132 something and switch to another application, then you can hit <D-g> (or <D-G>)
133 to repeat the search in the new app.  The same feature works if you search in
134 some app, switch to MacVim and hit <D-g>.
136 Note that the command |n| is not the same as <D-g>.  The former will repeat
137 the last search made in Vim, whereas the latter searches for the string on the
138 OS X Find Pasteboard using the action findNext: (see |:macaction|).
140 The <D-g> key equivalent is a great way to bring a search from one window to
141 another in MacVim.  Simply search for something in one window (using "/") then
142 switch to another (e.g. with <D-`>) and hit <D-g> and the search will be
143 repeated in the new window.
145                                         *macvim-backspace* *macvim-delete*
146 The 'backspace' option is set in the system vimrc to make the delete key
147 behave in a more familiar way to new users.  If you dislike this non-default
148 behaviour, then add the line "set backspace&" to your "~/.vimrc" file.
150 ==============================================================================
151 2. Starting MacVim                                      *macvim-start*
153 The easiest way to start MacVim is by double-clicking its icon in the Finder,
154 but most users will probably prefer to use the Terminal.  First some Finder
155 related ways of starting MacVim are described, then Terminal is discussed.
156 Note that you can put MacVim anywhere on your hard drive, but in this help
157 file it is assumed that you have put it inside your /Applications folder.
159 MacVim automatically registers itself as an editor of several standard file
160 formats.  This enables you to double-click a file to open it with MacVim (if
161 it is not associated with another program), or to right-click a file to bring
162 up the "Open with" menu.  You can also drag and drop files onto the Dock icon
163 to open them in tabs in a new window, or you can drop them in an already open
164 window to open the files in tabs in that specific window (it is possible to
165 have files open in e.g. splits by changing the "Open files from applications"
166 option in the General preference pane).  Finally, you can use Mac OS X System
167 Services to open files in MacVim, see |macvim-services|.
169 There are essentially two ways to start MacVim from Terminal: either call the
170 Vim binary with the -g switch >
171         /Applications/MacVim.app/Contents/MacOS/Vim -g file ...
172 or use the "open" command (this method can not be used to pass parameters to
173 Vim) >
174         open -a MacVim file ...
175 The advantage of using the latter method is that the settings relating to file
176 opening in the preferences panel are respected, and files open instantly if
177 |Quickstart| is enabled.
179 To save yourself from having to type the entire path to the Vim binary each
180 time you start MacVim, you could create an alias such as >
181         alias gvim='/Applications/MacVim.app/Contents/MacOS/Vim -g'
182 and add that to "~/.profile".
184                                                         *mvim*
185 A more flexible way to start MacVim is to use the shell script "mvim" which
186 comes bundled with MacVim.  Put this script in a folder in your path and then
187 simply type "mvim" to start MacVim.  This script will try to find MacVim.app
188 in various typical folders such as >
189         ~/Applications              ~/Applications/vim
190         /Applications               /Applications/vim
191         /Applications/Utilities     /Applications/Utilities/vim
192 If you would rather put MacVim.app in some other directory then that is also
193 possible, simply set the environment variable VIM_APP_DIR to whatever folder
194 you have placed MacVim.app in.
196 The "mvim" script can be symlinked to in order to start up MacVim in different
197 modes as follows (assuming you placed "mvim" in "/usr/local/bin"): >
198         * Diff:         ln -s /usr/local/bin/mvim mvimdiff
199         * Read-only:    ln -s /usr/local/bin/mvim mview
200         * Ex:           ln -s /usr/local/bin/mvim mex
201         * Restricted:   ln -s /usr/local/bin/mvim rmvim
202 If the symlink destination starts with "m" (or "g"), Vim will start in GUI
203 mode.  Removing the initial "m" from the above destination names makes Vim
204 start without the GUI.  (In the last case, the destination name can be
205 "rmvim", "rgvim" or "rvim".)
207 Note: Starting MacVim by creating a symlink to >
208         .../MacVim.app/Contents/MacOS/Vim
209 with 'ln -s' does not work.
211 Once in terminal Vim it is possible to start MacVim by using the following
212 command:
213         :gui [++opt] [+cmd] [-f|-b] [files...]
214 Note: Forking ("-b") currently does not work.
216                                                         *Quickstart*
217 Quickstart ensures that new windows open instantaneously e.g. when <D-n> is
218 pressed.  This feature can be enabled from the Advanced preferences pane (it
219 is disabled by default).  Note that this setting does not affect the speed
220 with which windows open when using the |mvim| command.
222 The main reason why this feature is not enabled by default is because on OS X
223 10.4 changes to runtime files (e.g. those in "~/.vim") are not detected.  For
224 example, if you install a new plugin and then press <D-n> to open a new
225 window, then that first window will not notice the plugin (but any consecutive
226 windows after the first one will).  On OS X 10.5 and later all modifications
227 to runtime files in "~/.vim" are detected, so unless you keep runtime files in
228 another folder there should be no problems.
230                                                 *odbeditor* *external-editor*
231 MacVim can act as an 'external editor' for Mac OS X applications that support
232 the ODB Editor Protocol (or the 'external editor' protocol).  Each application
233 has different ways of configuring this option, check the application's
234 documentation.  Once configured properly MacVim can be used to open files in
235 such an application.
237 A technical note: MacVim handles file open, modified and closed events.  In
238 the open event the FTok and Burl parameters are parsed (the latter is ignored
239 at the moment though).  In the modified and closed events the Tokn parameter
240 is sent back to the server application.
242 ==============================================================================
243 3. Preferences                              *macvim-prefs* *macvim-preferences*
245 Some settings are global to the MacVim application and would not make sense as
246 Vim options.  These settings are stored in a user default database and can be
247 accessed via the "MacVim.Preferences..." menu item.
249                                                         *macvim-user-defaults*
250 Not all entries in the user defaults database are exposed via the preference
251 panel, usually because they should not be changed by the user under normal
252 circumstances.  These options can still be changed with the "defaults" command
253 by opening Terminal and typing >
254         defaults write org.vim.MacVim KEY VALUE
255 Check the man page on "defaults" for more information on this command as well
256 as general information regarding Mac OS X user defaults.
258 Here is a list of relevant dictionary entries:
260 KEY                             VALUE ~
261 MMCellWidthMultiplier           width of a normal glyph in em units [float]
262 MMDialogsTrackPwd               open/save dialogs track the Vim pwd [bool]
263 MMLoginShellArgument            login shell parameter [string]
264 MMLoginShellCommand             which shell to use to launch Vim [string]
265 MMNoFontSubstitution            disable automatic font substitution [bool]
266 MMShowAddTabButton              enable "add tab" button on tabline [bool]
267 MMTabMaxWidth                   maximum width of a tab [int]
268 MMTabMinWidth                   minimum width of a tab [int]
269 MMTabOptimumWidth               default width of a tab [int]
270 MMTextInsetBottom               text area offset in pixels [int]
271 MMTextInsetLeft                 text area offset in pixels [int]
272 MMTextInsetRight                text area offset in pixels [int]
273 MMTextInsetTop                  text area offset in pixels [int]
274 MMTexturedWindow                use brushed metal window (Tiger only) [bool]
275 MMTranslateCtrlClick            interpret ctrl-click as right-click [bool]
276 MMVerticalSplit                 files open in vertical splits [bool]
277 MMZoomBoth                      zoom button maximizes both directions [bool]
279 As an example, if you have more than one mouse button and would wish to free
280 up Ctrl-click so you can bind it to something else, then the appropriate
281 command is: >
282         defaults write org.vim.MacVim MMTranslateCtrlClick 0
284 If you wish to restore all user defaults to their starting values, open
285 Terminal and type: >
286         defaults delete org.vim.MacVim
288                                                         *macvim-login-shell*
289 Applications opened from the Finder do not automatically source the user's
290 environment variables (which are typically set in .profile or .bashrc).  This
291 presents a problem when using |:!| to execute commands in the shell since e.g.
292 $PATH might not be set properly.  To work around this problem MacVim starts
293 new Vim processes via a login shell so that all environment variables are set.
295 By default MacVim uses the $SHELL environment variable to determine which
296 shell to use (if $SHELL is not set "/bin/bash" is used).  It is possible to
297 override this choice by setting the user default MMLoginShellCommand to the
298 shell that should be used (e.g. "/bin/tcsh").  MacVim tries to make the shell
299 a login shell by prepending argv[0] with a dash.  If you use an exotic shell
300 and need to pass it a parameter to make it a login shell then you can set the
301 user default MMLoginShellArgument (e.g. to "-l").  Finally, if the "bash"
302 shell is used, then "-l" is automatically added as an argument.  To override
303 this behaviour set MMLoginShellArgument to "--".
305 ==============================================================================
306 4. Special colors                                       *macvim-colors*
308 The colors in MacVim are defined in two dictionaries inside the "Resources"
309 folder of the application bundle (MacVim.app/Contents/Resources).  It is
310 possible to add more colors by modifying these files.  Color names are case
311 insensitive when accessed from Vim, but in the dictionary they must be
312 lowercase.
314                                                         *SystemColors.plist*
315 There are only a few system colors that can be accessed from Vim.  These
316 colors are defined in the dictionary "SystemColors.plist".  This dictionary
317 stores (key, value) pairs where the key is the name of the color and the
318 value is an NSColor selector name.
320 The most useful system colors are: >
321         MacSelectedTextBackgroundColor
322         MacSecondarySelectedColor
323 The former is the "Highlight Color" which can be changed in the "Appearance"
324 section of the System Preferences.  The latter is the selection color used by
325 a Cocoa application when it is not in focus.
327                                                         *Colors.plist*
328 Apart from the system colors, it is also possible to use the standard X11
329 color names (see http://en.wikipedia.org/wiki/X11_color_names) which usually
330 come in a file called "rgb.txt".  MacVim does not have such a file, instead it
331 keeps these colors in a dictionary called "Colors.plist". The key in this
332 dictionary is the name of the color and the value is an RGB value on the form
333 #rrggbb stored as an integer.
335                                                         *macvim-colorscheme*
336 MacVim ships with a custom color scheme that is used instead of the default
337 Vim color scheme.  The color scheme can be changed with >
338         :colorscheme macvim
339 If you prefer a dark background color, then type >
340         :set bg=dark
341 after having loaded the "macvim" color scheme.
343 The color scheme uses the the system "Highlight Color", which can be changed in
344 the "Appearance" pane of the System Preferences.  It also changes the
345 highlight color when a window becomes inactive.
347 If you have any comments regarding this colors cheme (is it better or worse
348 than the default?) then post them to |vim_mac|.
350 ==============================================================================
351 5. Menus                                                *macvim-menus*
353 Menus in Mac OS X behave slightly different from other platforms.  For that
354 reason two new commands have been added to Vim.  To understand what these
355 commands do you must first understand how menus work on OS X.
357 Each entry in a menu is called a "menu item".  With each menu item is
358 associated: a title, a key equivalent and an action message.  When a menu is
359 displayed the title is shown on the left and the key equivalent (if any) is
360 shown on the right.  Key equivalents enable you to access a menu item using
361 the keyboard instead of having to use the mouse.  When a menu item is clicked
362 it will send it's associated action message.  Actions can be used to instruct
363 MacVim to paste some text (paste:), open a new window (newWindow:), etc.
364 Certain actions are standard throughout OS X which is why MacVim must be able
365 to set these for each menu item.  (E.g. the menu item "Edit.Paste" must be
366 bound to the action "paste:" otherwise pasting won't work in dialogs since
367 that is the action that instructs them to paste something.)
369 Menus are configured using the |:macmenu| command and the |:macaction| command
370 can be used to send action messages.
372                                                 *:maca* *:macaction*
373 :maca[ction] {action:}  Send the message "action:" to the first responder.
374                         The list of allowed actions can be seen by typing
375                             :maca <C-d>
376                         An attempt to send an action not listed here will
377                         result in an error.  This list is specified in a
378                         property list file called |Actions.plist|.
380                                                 *:macm* *:macmenu*
381 :macm[enu] {menu} {key}={arg} ...
382                         Set Mac specific properties for {menu}.  The
383                         properties that can be set are:
384                             action      the action this menu sends
385                             alt         "yes" if alternate of previous menu
386                             key         the key equivalent of this menu
387                         This command must be used in a startup file, for
388                         example in "~/.gvimrc".  It has no effect otherwise.
390                         For convenience, a menu with "action=name:" which is
391                         bound to <Nop> will act as if bound to
392                         ":maca name:<CR>".  Thus, if "Menu.Item" is given by
393                             :an Menu.Item <Nop>
394                             :macm Menu.Item action=name:
395                         then ":emenu Menu.Item" is equivalent to
396                         ":maca name:".
398                         The key equivalent is specified with the <D-..>
399                         syntax.  This is case-sensitive, so <D-a> means Cmd-a
400                         whereas <D-A> means Cmd-Shift-a.
401                         Note that key equivalents must contain the Cmd
402                         modifier flag (<D-..>), and they take precedence over
403                         normal mappings.
404                         Use the syntax "key=<nop>" to clear the key equivalent
405                         of a menu.  This can be used to free up a key
406                         combination that is set in the system gvimrc so that
407                         it may be mapped to using ":map".
409                         Recognised values of "alt" are "0", "no", "1", and
410                         "yes".  The default is "no".  An alternate menu must
411                         have the same key equivalent as the previous menu,
412                         except the modifier flags must differ.  The alternate
413                         menu is by default hidden and only shows up when the
414                         modifier is held down.
416 Here are some examples on how to use these commands:
418 1. Create a menu item with title "New Window" under the "File" menu, with key
419 equivalent Cmd-n, which opens a new window when selected: >
420         :an 10.290 File.New\ Window <Nop>
421         :macm File.New\ Window action=newWindow: key=<D-n>
422 2. Change the key equivalent to cycle through tabs to Cmd-Left/Right: >
423         :macm Window.Previous\ Tab  key=<D-Left>
424         :macm Window.Next\ Tab      key=<D-Right>
425 3. Create a mapping in normal mode which closes the current tab/window: >
426         :map <C-w> :maca performClose:<CR>
427 4. Free up Cmd-t and remap it to open a file browser in a split view: >
428         macm File.New\ Tab key=<nop>
429         nmap <D-t> :sp .<CR>
430 Note: These two lines must be added to .gvimrc else the first line will fail.
431 The second line is case sensitive, so <D-T> (Cmd-Shift-t) is not the same as
432 <D-t> (Cmd-t)!
434 The standard Vim menus are modified in "$VIM/gvimrc".  Take a look at that
435 file for more examples on how to set up menus.  Note: When no window is open a
436 minimal default menu is used.  The default menu is set up in MainMenu.nib
437 which resides in "Resources/English.lproj/" folder inside the app bundle.
439                                                         *Actions.plist*
440 Some action messages would not be suitable to call from within Vim, so there
441 is a dictionary called "Actions.plist" (in the Resources folder of the
442 application bundle) which contains all actions that may be called.  The key in
443 this dictionary is the name of the action message (case sensitive), the value
444 is not used.
446 Hint: The |:macaction| command supports command-line completion so you can
447 enter ":maca<Space><C-d>" to see a list of all available actions.
449 Here is a random assortment of actions from Actions.plist which might be
450 useful.  
452 Action                          Description ~
453 fileOpen:                       Show "File Open" dialog
454 findNext:                       Search forward using the "Find Pasteboard"
455 findPrevious:                   Search backward using the "Find Pasteboard"
456 fontSizeDown:                   Decrease font size
457 fontSizeUp:                     Increase font size
458 hide:                           Hide MacVim
459 miniaturizeAll:                 Minimize all windows to the dock
460 newWindow:                      Open a new (empty) window
461 orderFrontCharacterPalette:     Show the the "Special Characters" dialog
462 orderFrontFontPanel:            Show the Font panel
463 orderFrontPreferencePanel:      Show the Preferences panel
464 performMiniaturize:             Minimize window to the dock
465 performZoom:                    Zoom window (same as clicking the green blob)
466 terminate:                      Quit MacVim
467 zoomAll:                        Zoom all windows
468 _cycleWindows:                  Select next window (similar to <D-`>)
469 _cycleWindowsBackwards:         Select previous window (similar to <D-S-`>)
471 ==============================================================================
472 6. Toolbar                                              *macvim-toolbar*
474 The toolbar in MacVim works just like in the other GUIs (see |gui-toolbar|),
475 with the addition of two separator items (see |menu-separator|).  You can use
476 them as follows: >
477         :an ToolBar.-space1-        <Nop>
478         :an ToolBar.-flexspace2-    <Nop>
479 The first example creates an empty space on the toolbar, the second creates an
480 empty space which will shink or expand so that the items to the right of it
481 are right-aligned.  A space (flexspace) will be created for any toolbar item
482 whose name begins with "-space" ("-flexspace") and ends with "-"
484 Toolbar icons should be tiff, png or icns, of dimension 32x32 or 24x24 pixels.
485 The larger size is used when 'tbis' is "medium" or "large", otherwise the
486 smaller size is used (which is the default).  If the icon file only contains
487 one dimension then Mac OS X will scale the icon to the appropriate dimension
488 if necessary.  To avoid this, use a file format which supports multiple
489 resolutions (such as icns) and provide both 32x32 and 24x24 versions of the
490 icon.
492 Note: Only a subset of the builtin toolbar items presently have icons.  If no
493 icon can be found a warning triangle is displayed instead.
495 ==============================================================================
496 7. Dialogs                                              *macvim-dialogs*
498 Dialogs can be controlled with the keyboard in two ways.  By default each
499 button in a dialog is bound to a key.  The button that is highlighted by blue
500 is bound to Enter, any button with the title "Cancel" is bound to Escape, and
501 any button with the title "Don't Save" is bound to <D-d>.  Other buttons are
502 usually bound to the first letter in the title of the button.  There is no
503 visual feedback to indicate which letter a button is bound to, so sometimes
504 some experimentation might be required in order to figure out which key to
505 press.
507 The second way of controlling dialogs with the keyboard is to enable "Full
508 keyboard access" in the "Keyboard & Mouse" pane of the System Preferences (you
509 can also toggle this on or off by pressing Ctrl-F7).  Once keyboard access is
510 enabled it is possible to move between buttons with Tab and pressing Space to
511 select the current button.  The current button is indicated with a blue
512 outline.
514 ==============================================================================
515 8. System services                                      *macvim-services*
517 MacVim supports a few system services.  These can be accessed from the MacVim
518 submenu in the Services menu.  For services to work, MacVim.app should be
519 located in the /Applications folder.  (You might have to logout and then login
520 again before Mac OS X detects the MacVim services.)
522 These are the currently supported services:
523         * New Document Containing Selection: Open a new window and paste the
524           currently selected text.
525         * New Document Here: Open a new window and set the current directory
526           to that of the selected text.  This is intended to be used from a
527           Finder window to open an empty document in the currently selected
528           folder.
529         * Open Selected File: If the selected text represents a file name,
530           then the corresponding file is opened in a new window.
532 If new files are set to open in the current window (in the General preference
533 pane) then the above services will also reuse the topmost window, instead of
534 opening a new window.
536 ==============================================================================
537 9. mvim:// URL handler                          *mvim://* *macvim-url-handler*
539 MacVim supports a custom URL handler for "mvim://" URLs. The handler is
540 supposed to be compatible to TextMate's URL scheme as documented at
541         http://blog.macromates.com/2007/the-textmate-url-scheme/.
543 Currently, this means that the format is >
544         mvim://open?<arguments>
545 where "arguments" can be:
546         * url — the actual file to open (i.e. a file://... URL), if you leave
547                 out this argument, the frontmost document is implied
548         * line — line number to go to (one based)
549         * column — column number to go to (one based)
551 For example, the link >
552         mvim://open?url=file:///etc/profile&line=20
553 will open the file /etc/profile on line 20 when clicked in a web browser.
555 Note that url has to be a file:// url pointing to an existing local file.
557 ==============================================================================
558 10. Keyboard shortcuts                                  *macvim-shortcuts*
560 Most keyboard shortcuts in MacVim are bound to menu items and can be
561 discovered by looking through the menus (see |macvim-menus| on how to create
562 your own menu shortcuts).  The remaining shortcuts are listed here:
564                                                         *Cmd-.* *<D-.>*
565 Cmd-.                   Interrupt Vim.  This is synonymous with CTRL-C and can
566                         hence be used instead of Esc to exit insert mode (in
567                         case you find Esc a bit hard to reach).
569                                                         *Cmd-`* *<D-`>*
570 Cmd-`                   Cycle to the next window.  On an American keyboard the
571                         `-key is located under the Esc-key.  On European
572                         keyboards this key is often adjacent to the left
573                         Shift-key and it may be not even be marked with "`".
575                                                         *Cmd-Left*  *<D-Left>*
576 Cmd-Left                Move cursor to the beginning of the line
577                         (see |cmd-movement|).
579                                                         *Cmd-Right* *<D-Right>*
580 Cmd-Right               Move cursor to the end of the line (see |cmd-movement|).
582                                                         *Cmd-Up*    *<D-Up>*
583 Cmd-Up                  Move cursor to the first line (see |cmd-movement|).
585                                                         *Cmd-Down*  *<D-Down>*
586 Cmd-Down                Move cursor to the last line (see |cmd-movement|).
588                                                         *Alt-Left*  *<M-Left>*
589 Alt-Left                Move cursor to the beginning of the previous word
590                         (see |alt-movement|).
592                                                         *Alt-Right* *<M-Right>*
593 Alt-Right               Move cursor to the beginning of the next word
594                         (see |alt-movement|).
596                                                         *Alt-Up*    *<M-Up>*
597 Alt-Up                  Move cursor one paragraph forward (see |alt-movement|).
599                                                         *Alt-Down*  *<M-Down>*
600 Alt-Down                Move cursor to the previous paragraph
601                         (see |alt-movement|).
603                                                 *cmd-movement* *alt-movement*
604 The above mappings involving Cmd/Alt + arrow key are enabled by default in the
605 system gvimrc file "$VIM/gvimrc".  You can quickly disable all of these by
606 adding the following lines to your "~/.vimrc" (not .gvimrc) file: >
607         if has("gui_macvim")
608           let macvim_skip_cmd_opt_movement = 1
609         endif
610 Note: These are the only key mappings that MacVim makes (not counting menu key
611 equivalents which are not set up with :map).
613 See |macvim-shift-movement| if you want Shift to select text when used in
614 conjunction with the above Cmd/Alt movement shortcuts.
616 ==============================================================================
617 11. Known bugs/missing features                         *macvim-todo*
619 This list is by no means exhaustive, it only enumerates some of the more
620 prominent bugs/missing features.
622 - Localized menus are not supported.  Choosing anything but "English" in the
623   "International" pane of "System Prefences" may break the menus (and
624   toolbar).
625 - Some Unicode characters are not handled well (e.g. nonspacing marks)
626 - Sometimes multibyte characters look "too wide", i.e. they overlap the
627   following character.  It might help to change 'ambiwidth', or override the
628   automatic font substitution by setting 'guifontwide' manually.
629 - Printing.  As a temporary solution <D-p> creates a PostScript file which is
630   then opened in Preview where it may be printed.
631 - The toolbar looks ugly and is not very useful.
633 If you find new bugs then add a new issue at http://code.google.com/p/macvim/
634 or post your findings to the |vim_mac| mailing list.  If you are missing
635 feature X in MacVim then voice your opinion on the |vim_mac| mailing list; it
636 might be simple to implement, but unless somebody asks for a particular
637 feature then there is little incentive to add it.
639 ==============================================================================
640 12. Hints                                               *macvim-hints*
642 In this section some general (not necessarily MacVim specific) hints are
643 given.
645 Scenario: ~
646 You try opening a bunch of files in tabs but not all files get opened in their
647 own tab.
648 Solution: ~
649 To get around this, set 'tabpagemax' to something big in your .gvimrc file
650 (e.g. ":set tabpagemax=100").
652 Scenario: ~
653 You want to open a file in a tab in an already opened window, but typing "mvim
654 filename" in Terminal opens it up in a separate window.
655 Solution: ~
656 Use the |--remote-tab| switch.  If you have several windows open you might
657 have to specify which window you want the file to open in by using the
658 |--servername| switch.  The title of a window usually ends in something like
659 "VIM" or "VIM3" --- this is the server name of that window.  So to open a file
660 named "foobar.txt" in a window whose title ends in "VIM3" you would type (the
661 order of the arguments matters): >
662         mvim --servername VIM3 --remote-tab foobar.txt
663 For more information, consult the |client-server| manual page.
665 Scenario: ~
666 You like to be able to select text by holding down shift and pressing the
667 arrow keys and find the Vim way of selecting text strange.
668 Solution: ~
669 See |macvim-shift-movement|.
671 Scenario: ~
672 You do not want MacVim to set up any key mappings.
673 Solution: ~
674 See |cmd-movement|.
676 Scenario: ~
677 Enabling localized menus breaks the toolbar and the menus as well.
678 Solution: ~
679 This is a known problem, see |macvim-todo|.
681 Scenario: ~
682 You dislike the default font (DejaVu Sans Mono).
683 Solution: ~
684 The standard fixed width font on other Mac OS X applications is Monaco.  If
685 you prefer this font then add the following line to your "~/.gvimrc" (note
686 that Monaco does not come in italic and bold variants): >
687         set guifont=Monaco:h10
688 The suffix ":h10" specifies the point size of the font should be "10" (see
689 'guifont' for more information on how to set the font).
691 Scenario: ~
692 When you click the (green) zoom button you want the window to maximize
693 horizontally as well as vertically.
694 Solution: ~
695 Hold down Cmd and click the zoom button.  If you prefer this to be the default
696 action, then set the user default MMZoomBoth (see |macvim-prefs|).
698 Scenario: ~
699 Typing feels sluggish when the cursor is just before a right bracket (i.e.
700 ')', '}', or ']').
701 Solution: ~
702 Disable the "matchparen" plugin (see |matchparen|) by typing :NoMatchParen.
703 If that helps, then you can permanently disable "matchparen" by adding the
704 following line to your "~/.vimrc": >
705         let loaded_matchparen=1
707 Scenario: ~
708 You want to use MacVim as an editor for some external application.
709 Solution: ~
710 If the external application lets you set a program to execute then something
711 like "mvim -f" might be all you need (the "-f" switch ensures that the "mvim"
712 script returns only after you close the editor window, otherwise "mvim"
713 returns immediately). If the external program honors the EDITOR environment
714 variable (e.g Git does this) then you may get away by adding the following
715 line to your "~/.profile": >
716         export EDITOR='mvim -f'
717 If you have not installed the "mvim" script in your path you can provide the
718 path to the Vim binary instead.  Thus, if "MacVim.app" resides in the
719 Applications folder then you would use the following line: >
720         export EDITOR='/Applications/MacVim.app/Contents/MacOS/Vim -g -f'
722 Scenario: ~
723 You have set MacVim to open from an external program and when you finish
724 editing (by closing the MacVim window) you want the external program to regain
725 focus.
726 Solution: ~
727 Use the VimLeave autocommand to hide MacVim when the window closes: >
728         au VimLeave * maca hide:
729 Assuming your external program has a setting for which command to execute to
730 bring up an editor, you would set that option to something like: >
731         mvim -f -c "au VimLeave * maca hide:"
732 (See the above Scenario for an explanation of the "-f" switch.)
734 Scenario: ~
735 You would like to remap Caps Lock to Esc.
736 Solution: ~
737 The free app "PCKeyboardHack" can be used to remap Caps Lock.  It is available
738 as a free download from:
739         http://www.pqrs.org/tekezo/macosx/keyremap4macbook/extra.html
740 On some Apple keyboards the Caps Lock key doesn't immediately register and
741 this makes Caps Lock "drop" key presses.  To work around this problem go into
742 the "Keyboard & Mouse" System Preference and remap Caps Lock to Ctrl first
743 (click the "Modifier Keys..." button).
745 Scenario: ~
746 You can't find the information on MacVim you thought should be in this manual
747 page.
748 Solution: ~
749 Post your question on the |vim_mac| mailing list and wait for an answer.
751  vim:tw=78:sw=4:ts=8:ft=help:norl: