Cmd-. sends SIGINT
[MacVim.git] / runtime / doc / gui_mac.txt
blob00cf919e5da8b3006a24ac48716f1ad3aa381d09
1 *gui_mac.txt*   For Vim version 7.2.  Last change: 2009 Jan 08
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 MMLoadDefaultFont               load font (disable for faster startup) [bool]
264 MMLoginShellArgument            login shell parameter [string]
265 MMLoginShellCommand             which shell to use to launch Vim [string]
266 MMNoFontSubstitution            disable automatic font substitution [bool]
267 MMShowAddTabButton              enable "add tab" button on tabline [bool]
268 MMTabMaxWidth                   maximum width of a tab [int]
269 MMTabMinWidth                   minimum width of a tab [int]
270 MMTabOptimumWidth               default width of a tab [int]
271 MMTextInsetBottom               text area offset in pixels [int]
272 MMTextInsetLeft                 text area offset in pixels [int]
273 MMTextInsetRight                text area offset in pixels [int]
274 MMTextInsetTop                  text area offset in pixels [int]
275 MMTexturedWindow                use brushed metal window (Tiger only) [bool]
276 MMTranslateCtrlClick            interpret ctrl-click as right-click [bool]
277 MMVerticalSplit                 files open in vertical splits [bool]
278 MMZoomBoth                      zoom button maximizes both directions [bool]
280 As an example, if you have more than one mouse button and would wish to free
281 up Ctrl-click so you can bind it to something else, then the appropriate
282 command is: >
283         defaults write org.vim.MacVim MMTranslateCtrlClick 0
285 If you wish to restore all user defaults to their starting values, open
286 Terminal and type: >
287         defaults delete org.vim.MacVim
289                                                         *macvim-login-shell*
290 Applications opened from the Finder do not automatically source the user's
291 environment variables (which are typically set in .profile or .bashrc).  This
292 presents a problem when using |:!| to execute commands in the shell since e.g.
293 $PATH might not be set properly.  To work around this problem MacVim starts
294 new Vim processes via a login shell so that all environment variables are set.
296 By default MacVim uses the $SHELL environment variable to determine which
297 shell to use (if $SHELL is not set "/bin/bash" is used).  It is possible to
298 override this choice by setting the user default MMLoginShellCommand to the
299 shell that should be used (e.g. "/bin/tcsh").  MacVim tries to make the shell
300 a login shell by prepending argv[0] with a dash.  If you use an exotic shell
301 and need to pass it a parameter to make it a login shell then you can set the
302 user default MMLoginShellArgument (e.g. to "-l").  Finally, if the "bash"
303 shell is used, then "-l" is automatically added as an argument.  To override
304 this behaviour set MMLoginShellArgument to "--".
306 ==============================================================================
307 4. Special colors                                       *macvim-colors*
309 The colors in MacVim are defined in two dictionaries inside the "Resources"
310 folder of the application bundle (MacVim.app/Contents/Resources).  It is
311 possible to add more colors by modifying these files.  Color names are case
312 insensitive when accessed from Vim, but in the dictionary they must be
313 lowercase.
315                                                         *SystemColors.plist*
316 There are only a few system colors that can be accessed from Vim.  These
317 colors are defined in the dictionary "SystemColors.plist".  This dictionary
318 stores (key, value) pairs where the key is the name of the color and the
319 value is an NSColor selector name.
321 The most useful system colors are: >
322         MacSelectedTextBackgroundColor
323         MacSecondarySelectedColor
324 The former is the "Highlight Color" which can be changed in the "Appearance"
325 section of the System Preferences.  The latter is the selection color used by
326 a Cocoa application when it is not in focus.
328                                                         *Colors.plist*
329 Apart from the system colors, it is also possible to use the standard X11
330 color names (see http://en.wikipedia.org/wiki/X11_color_names) which usually
331 come in a file called "rgb.txt".  MacVim does not have such a file, instead it
332 keeps these colors in a dictionary called "Colors.plist". The key in this
333 dictionary is the name of the color and the value is an RGB value on the form
334 #rrggbb stored as an integer.
336                                                         *macvim-colorscheme*
337 MacVim ships with a custom color scheme that is used instead of the default
338 Vim color scheme.  The color scheme can be changed with >
339         :colorscheme macvim
340 If you prefer a dark background color, then type >
341         :set bg=dark
342 after having loaded the "macvim" color scheme.
344 The color scheme uses the the system "Highlight Color", which can be changed in
345 the "Appearance" pane of the System Preferences.  It also changes the
346 highlight color when a window becomes inactive.
348 If you have any comments regarding this colors cheme (is it better or worse
349 than the default?) then post them to |vim_mac|.
351 ==============================================================================
352 5. Menus                                                *macvim-menus*
354 Menus in Mac OS X behave slightly different from other platforms.  For that
355 reason two new commands have been added to Vim.  To understand what these
356 commands do you must first understand how menus work on OS X.
358 Each entry in a menu is called a "menu item".  With each menu item is
359 associated: a title, a key equivalent and an action message.  When a menu is
360 displayed the title is shown on the left and the key equivalent (if any) is
361 shown on the right.  Key equivalents enable you to access a menu item using
362 the keyboard instead of having to use the mouse.  When a menu item is clicked
363 it will send it's associated action message.  Actions can be used to instruct
364 MacVim to paste some text (paste:), open a new window (newWindow:), etc.
365 Certain actions are standard throughout OS X which is why MacVim must be able
366 to set these for each menu item.  (E.g. the menu item "Edit.Paste" must be
367 bound to the action "paste:" otherwise pasting won't work in dialogs since
368 that is the action that instructs them to paste something.)
370 Menus are configured using the |:macmenu| command and the |:macaction| command
371 can be used to send action messages.
373                                                 *:maca* *:macaction*
374 :maca[ction] {action:}  Send the message "action:" to the first responder.
375                         The list of allowed actions can be seen by typing
376                             :maca <C-d>
377                         An attempt to send an action not listed here will
378                         result in an error.  This list is specified in a
379                         property list file called |Actions.plist|.
381                                                 *:macm* *:macmenu*
382 :macm[enu] {menu} {key}={arg} ...
383                         Set Mac specific properties for {menu}.  The
384                         properties that can be set are:
385                             action      the action this menu sends
386                             alt         "yes" if alternate of previous menu
387                             key         the key equivalent of this menu
388                         This command must be used in a startup file, for
389                         example in "~/.gvimrc".  It has no effect otherwise.
391                         For convenience, a menu with "action=name:" which is
392                         bound to <Nop> will act as if bound to
393                         ":maca name:<CR>".  Thus, if "Menu.Item" is given by
394                             :an Menu.Item <Nop>
395                             :macm Menu.Item action=name:
396                         then ":emenu Menu.Item" is equivalent to
397                         ":maca name:".
399                         The key equivalent is specified with the <D-..>
400                         syntax.  This is case-sensitive, so <D-a> means Cmd-a
401                         whereas <D-A> means Cmd-Shift-a.
402                         Note that key equivalents must contain the Cmd
403                         modifier flag (<D-..>), and they take precedence over
404                         normal mappings.
405                         Use the syntax "key=<nop>" to clear the key equivalent
406                         of a menu.  This can be used to free up a key
407                         combination that is set in the system gvimrc so that
408                         it may be mapped to using ":map".
410                         Recognised values of "alt" are "0", "no", "1", and
411                         "yes".  The default is "no".  An alternate menu must
412                         have the same key equivalent as the previous menu,
413                         except the modifier flags must differ.  The alternate
414                         menu is by default hidden and only shows up when the
415                         modifier is held down.
417 Here are some examples on how to use these commands:
419 1. Create a menu item with title "New Window" under the "File" menu, with key
420 equivalent Cmd-n, which opens a new window when selected: >
421         :an 10.290 File.New\ Window <Nop>
422         :macm File.New\ Window action=newWindow: key=<D-n>
423 2. Change the key equivalent to cycle through tabs to Cmd-Left/Right: >
424         :macm Window.Previous\ Tab  key=<D-Left>
425         :macm Window.Next\ Tab      key=<D-Right>
426 3. Create a mapping in normal mode which closes the current tab/window: >
427         :map <C-w> :maca performClose:<CR>
428 4. Free up Cmd-t and remap it to open a file browser in a split view: >
429         macm File.New\ Tab key=<nop>
430         nmap <D-t> :sp .<CR>
431 Note: These two lines must be added to .gvimrc else the first line will fail.
432 The second line is case sensitive, so <D-T> (Cmd-Shift-t) is not the same as
433 <D-t> (Cmd-t)!
435 The standard Vim menus are modified in "$VIM/gvimrc".  Take a look at that
436 file for more examples on how to set up menus.  Note: When no window is open a
437 minimal default menu is used.  The default menu is set up in MainMenu.nib
438 which resides in "Resources/English.lproj/" folder inside the app bundle.
440                                                         *Actions.plist*
441 Some action messages would not be suitable to call from within Vim, so there
442 is a dictionary called "Actions.plist" (in the Resources folder of the
443 application bundle) which contains all actions that may be called.  The key in
444 this dictionary is the name of the action message (case sensitive), the value
445 is not used.
447 Hint: The |:macaction| command supports command-line completion so you can
448 enter ":maca<Space><C-d>" to see a list of all available actions.
450 Here is a random assortment of actions from Actions.plist which might be
451 useful.  
453 Action                          Description ~
454 fileOpen:                       Show "File Open" dialog
455 findNext:                       Search forward using the "Find Pasteboard"
456 findPrevious:                   Search backward using the "Find Pasteboard"
457 fontSizeDown:                   Decrease font size
458 fontSizeUp:                     Increase font size
459 hide:                           Hide MacVim
460 miniaturizeAll:                 Minimize all windows to the dock
461 newWindow:                      Open a new (empty) window
462 orderFrontCharacterPalette:     Show the the "Special Characters" dialog
463 orderFrontFontPanel:            Show the Font panel
464 orderFrontPreferencePanel:      Show the Preferences panel
465 performMiniaturize:             Minimize window to the dock
466 performZoom:                    Zoom window (same as clicking the green blob)
467 terminate:                      Quit MacVim
468 zoomAll:                        Zoom all windows
469 _cycleWindows:                  Select next window (similar to <D-`>)
470 _cycleWindowsBackwards:         Select previous window (similar to <D-S-`>)
472 ==============================================================================
473 6. Toolbar                                              *macvim-toolbar*
475 The toolbar in MacVim works just like in the other GUIs (see |gui-toolbar|),
476 with the addition of two separator items (see |menu-separator|).  You can use
477 them as follows: >
478         :an ToolBar.-space1-        <Nop>
479         :an ToolBar.-flexspace2-    <Nop>
480 The first example creates an empty space on the toolbar, the second creates an
481 empty space which will shink or expand so that the items to the right of it
482 are right-aligned.  A space (flexspace) will be created for any toolbar item
483 whose name begins with "-space" ("-flexspace") and ends with "-"
485 Toolbar icons should be tiff, png or icns, of dimension 32x32 or 24x24 pixels.
486 The larger size is used when 'tbis' is "medium" or "large", otherwise the
487 smaller size is used (which is the default).  If the icon file only contains
488 one dimension then Mac OS X will scale the icon to the appropriate dimension
489 if necessary.  To avoid this, use a file format which supports multiple
490 resolutions (such as icns) and provide both 32x32 and 24x24 versions of the
491 icon.
493 Note: Only a subset of the builtin toolbar items presently have icons.  If no
494 icon can be found a warning triangle is displayed instead.
496 ==============================================================================
497 7. Dialogs                                              *macvim-dialogs*
499 Dialogs can be controlled with the keyboard in two ways.  By default each
500 button in a dialog is bound to a key.  The button that is highlighted by blue
501 is bound to Enter, any button with the title "Cancel" is bound to Escape, and
502 any button with the title "Don't Save" is bound to <D-d>.  Other buttons are
503 usually bound to the first letter in the title of the button.  There is no
504 visual feedback to indicate which letter a button is bound to, so sometimes
505 some experimentation might be required in order to figure out which key to
506 press.
508 The second way of controlling dialogs with the keyboard is to enable "Full
509 keyboard access" in the "Keyboard & Mouse" pane of the System Preferences (you
510 can also toggle this on or off by pressing Ctrl-F7).  Once keyboard access is
511 enabled it is possible to move between buttons with Tab and pressing Space to
512 select the current button.  The current button is indicated with a blue
513 outline.
515 ==============================================================================
516 8. System services                                      *macvim-services*
518 MacVim supports a few system services.  These can be accessed from the MacVim
519 submenu in the Services menu.  For services to work, MacVim.app should be
520 located in the /Applications folder.  (You might have to logout and then login
521 again before Mac OS X detects the MacVim services.)
523 These are the currently supported services:
524         * New Document Containing Selection: Open a new window and paste the
525           currently selected text.
526         * New Document Here: Open a new window and set the current directory
527           to that of the selected text.  This is intended to be used from a
528           Finder window to open an empty document in the currently selected
529           folder.
530         * Open Selected File: If the selected text represents a file name,
531           then the corresponding file is opened in a new window.
533 If new files are set to open in the current window (in the General preference
534 pane) then the above services will also reuse the topmost window, instead of
535 opening a new window.
537 ==============================================================================
538 9. mvim:// URL handler                          *mvim://* *macvim-url-handler*
540 MacVim supports a custom URL handler for "mvim://" URLs. The handler is
541 supposed to be compatible to TextMate's URL scheme as documented at
542         http://blog.macromates.com/2007/the-textmate-url-scheme/.
544 Currently, this means that the format is >
545         mvim://open?<arguments>
546 where "arguments" can be:
547         * url — the actual file to open (i.e. a file://... URL), if you leave
548                 out this argument, the frontmost document is implied
549         * line — line number to go to (one based)
550         * column — column number to go to (one based)
552 For example, the link >
553         mvim://open?url=file:///etc/profile&line=20
554 will open the file /etc/profile on line 20 when clicked in a web browser.
556 Note that url has to be a file:// url pointing to an existing local file.
558 ==============================================================================
559 10. Keyboard shortcuts                                  *macvim-shortcuts*
561 Most keyboard shortcuts in MacVim are bound to menu items and can be
562 discovered by looking through the menus (see |macvim-menus| on how to create
563 your own menu shortcuts).  The remaining shortcuts are listed here:
565                                                         *Cmd-.* *<D-.>*
566 Cmd-.                   Interrupt Vim.  Unlike Ctrl-C which is sent as normal
567                         keyboard input (and hence has to be received and then
568                         interpreted) this sends a SIGINT signal to the Vim
569                         process.  Use this shortcut if the Vim process appears
570                         to have locked up and is not responding to key presses.
572                                                         *Cmd-`* *<D-`>*
573 Cmd-`                   Cycle to the next window.  On an American keyboard the
574                         `-key is located under the Esc-key.  On European
575                         keyboards this key is often adjacent to the left
576                         Shift-key and it may be not even be marked with "`".
578                                                         *Cmd-Left*  *<D-Left>*
579 Cmd-Left                Move cursor to the beginning of the line
580                         (see |cmd-movement|).
582                                                         *Cmd-Right* *<D-Right>*
583 Cmd-Right               Move cursor to the end of the line (see |cmd-movement|).
585                                                         *Cmd-Up*    *<D-Up>*
586 Cmd-Up                  Move cursor to the first line (see |cmd-movement|).
588                                                         *Cmd-Down*  *<D-Down>*
589 Cmd-Down                Move cursor to the last line (see |cmd-movement|).
591                                                         *Alt-Left*  *<M-Left>*
592 Alt-Left                Move cursor to the beginning of the previous word
593                         (see |alt-movement|).
595                                                         *Alt-Right* *<M-Right>*
596 Alt-Right               Move cursor to the beginning of the next word
597                         (see |alt-movement|).
599                                                         *Alt-Up*    *<M-Up>*
600 Alt-Up                  Move cursor one paragraph forward (see |alt-movement|).
602                                                         *Alt-Down*  *<M-Down>*
603 Alt-Down                Move cursor to the previous paragraph
604                         (see |alt-movement|).
606                                                 *cmd-movement* *alt-movement*
607 The above mappings involving Cmd/Alt + arrow key are enabled by default in the
608 system gvimrc file "$VIM/gvimrc".  You can quickly disable all of these by
609 adding the following lines to your "~/.vimrc" (not .gvimrc) file: >
610         if has("gui_macvim")
611           let macvim_skip_cmd_opt_movement = 1
612         endif
613 Note: These are the only key mappings that MacVim makes (not counting menu key
614 equivalents which are not set up with :map).
616 See |macvim-shift-movement| if you want Shift to select text when used in
617 conjunction with the above Cmd/Alt movement shortcuts.
619 ==============================================================================
620 11. Known bugs/missing features                         *macvim-todo*
622 This list is by no means exhaustive, it only enumerates some of the more
623 prominent bugs/missing features.
625 - Localized menus are not supported.  Choosing anything but "English" in the
626   "International" pane of "System Prefences" may break the menus (and
627   toolbar).
628 - Some Unicode characters are not handled well (e.g. nonspacing marks)
629 - Sometimes multibyte characters look "too wide", i.e. they overlap the
630   following character.  It might help to change 'ambiwidth', or override the
631   automatic font substitution by setting 'guifontwide' manually.
632 - Printing.  As a temporary solution <D-p> creates a PostScript file which is
633   then opened in Preview where it may be printed.
634 - The toolbar looks ugly and is not very useful.
636 If you find new bugs then add a new issue at http://code.google.com/p/macvim/
637 or post your findings to the |vim_mac| mailing list.  If you are missing
638 feature X in MacVim then voice your opinion on the |vim_mac| mailing list; it
639 might be simple to implement, but unless somebody asks for a particular
640 feature then there is little incentive to add it.
642 ==============================================================================
643 12. Hints                                               *macvim-hints*
645 In this section some general (not necessarily MacVim specific) hints are
646 given.
648 Scenario: ~
649 You try opening a bunch of files in tabs but not all files get opened in their
650 own tab.
651 Solution: ~
652 To get around this, set 'tabpagemax' to something big in your .gvimrc file
653 (e.g. ":set tabpagemax=100").
655 Scenario: ~
656 You want to open a file in a tab in an already opened window, but typing "mvim
657 filename" in Terminal opens it up in a separate window.
658 Solution: ~
659 Use the |--remote-tab| switch.  If you have several windows open you might
660 have to specify which window you want the file to open in by using the
661 |--servername| switch.  The title of a window usually ends in something like
662 "VIM" or "VIM3" --- this is the server name of that window.  So to open a file
663 named "foobar.txt" in a window whose title ends in "VIM3" you would type (the
664 order of the arguments matters): >
665         mvim --servername VIM3 --remote-tab foobar.txt
666 For more information, consult the |client-server| manual page.
668 Scenario: ~
669 You like to be able to select text by holding down shift and pressing the
670 arrow keys and find the Vim way of selecting text strange.
671 Solution: ~
672 See |macvim-shift-movement|.
674 Scenario: ~
675 You do not want MacVim to set up any key mappings.
676 Solution: ~
677 See |cmd-movement|.
679 Scenario: ~
680 Enabling localized menus breaks the toolbar and the menus as well.
681 Solution: ~
682 This is a known problem, see |macvim-todo|.
684 Scenario: ~
685 You dislike the default font (DejaVu Sans Mono).
686 Solution: ~
687 The standard fixed width font on other Mac OS X applications is Monaco.  If
688 you prefer this font then add the following line to your "~/.gvimrc" (note
689 that Monaco does not come in italic and bold variants): >
690         set guifont=Monaco:h10
691 The suffix ":h10" specifies the point size of the font should be "10" (see
692 'guifont' for more information on how to set the font).
694 Scenario: ~
695 When you click the (green) zoom button you want the window to maximize
696 horizontally as well as vertically.
697 Solution: ~
698 Hold down Cmd and click the zoom button.  If you prefer this to be the default
699 action, then set the user default MMZoomBoth (see |macvim-prefs|).
701 Scenario: ~
702 Typing feels sluggish when the cursor is just before a right bracket (i.e.
703 ')', '}', or ']').
704 Solution: ~
705 Disable the "matchparen" plugin (see |matchparen|) by typing :NoMatchParen.
706 If that helps, then you can permanently disable "matchparen" by adding the
707 following line to your "~/.vimrc": >
708         let loaded_matchparen=1
710 Scenario: ~
711 You want to use MacVim as an editor for some external application.
712 Solution: ~
713 If the external application lets you set a program to execute then something
714 like "mvim -f" might be all you need (the "-f" switch ensures that the "mvim"
715 script returns only after you close the editor window, otherwise "mvim"
716 returns immediately). If the external program honors the EDITOR environment
717 variable (e.g Git does this) then you may get away by adding the following
718 line to your "~/.profile": >
719         export EDITOR='mvim -f'
720 If you have not installed the "mvim" script in your path you can provide the
721 path to the Vim binary instead.  Thus, if "MacVim.app" resides in the
722 Applications folder then you would use the following line: >
723         export EDITOR='/Applications/MacVim.app/Contents/MacOS/Vim -g -f'
725 Scenario: ~
726 You have set MacVim to open from an external program and when you finish
727 editing (by closing the MacVim window) you want the external program to regain
728 focus.
729 Solution: ~
730 Use the VimLeave autocommand to hide MacVim when the window closes: >
731         au VimLeave * maca hide:
732 Assuming your external program has a setting for which command to execute to
733 bring up an editor, you would set that option to something like: >
734         mvim -f -c "au VimLeave * maca hide:"
735 (See the above Scenario for an explanation of the "-f" switch.)
737 Scenario: ~
738 You would like to remap Caps Lock to Esc.
739 Solution: ~
740 The free app "PCKeyboardHack" can be used to remap Caps Lock.  It is available
741 as a free download from:
742         http://www.pqrs.org/tekezo/macosx/keyremap4macbook/extra.html
743 On some Apple keyboards the Caps Lock key doesn't immediately register and
744 this makes Caps Lock "drop" key presses.  To work around this problem go into
745 the "Keyboard & Mouse" System Preference and remap Caps Lock to Ctrl first
746 (click the "Modifier Keys..." button).
748 Scenario: ~
749 You can't find the information on MacVim you thought should be in this manual
750 page.
751 Solution: ~
752 Post your question on the |vim_mac| mailing list and wait for an answer.
754  vim:tw=78:sw=4:ts=8:ft=help:norl: