mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
827 lines
37 KiB
Plaintext
827 lines
37 KiB
Plaintext
*gui_mac.txt* For Vim version 8.0. Last change: 2012 Jan 13
|
|
|
|
|
|
VIM REFERENCE MANUAL by Bjorn Winckler
|
|
|
|
|
|
The MacVim Graphical User Interface *macvim* *gui-macvim*
|
|
|
|
1. MacVim differences |macvim-differences|
|
|
2. Starting MacVim |macvim-start|
|
|
3. Preferences |macvim-preferences|
|
|
4. Special colors |macvim-colors|
|
|
5. Menus |macvim-menus|
|
|
6. Toolbar |macvim-toolbar|
|
|
7. Dialogs |macvim-dialogs|
|
|
8. System services |macvim-services|
|
|
9. mvim:// URL handler |macvim-url-handler|
|
|
10. Keyboard shortcuts |macvim-shortcuts|
|
|
11. Trackpad gestures |macvim-gestures|
|
|
12. International |macvim-international|
|
|
13. Known bugs/missing features |macvim-todo|
|
|
14. Hints |macvim-hints|
|
|
|
|
Other relevant documentation:
|
|
|gui.txt| For generic items of the GUI.
|
|
|
|
{Vi does not have a GUI}
|
|
|
|
==============================================================================
|
|
1. MacVim differences *macvim-differences*
|
|
|
|
One of the goals of MacVim is to make Vim behave like a proper Mac OS X
|
|
application. For this reason MacVim behaves slightly different from other GUI
|
|
ports of Vim. Most of the modifications are provided in the system gvimrc
|
|
file; you can quickly open this file and look at it yourself by typing: >
|
|
:tabe $VIM/gvimrc
|
|
Note that this file will be overwritten each time you update MacVim, so it is
|
|
best to keep your own modifications inside "~/.gvimrc".
|
|
|
|
*macvim-windows*
|
|
There is some confusion regarding the term "window" in MacVim since it means
|
|
one thing to Vim and another to MacVim. A "window" in Vim is what opens up
|
|
when you type ":sp", whereas a "window" in MacVim is the GUI window which
|
|
contains the text view, scrollbars, toolbar and tabline. To avoid confusion,
|
|
the former is referred to as a Vim-window, whereas the latter is simply called
|
|
a window.
|
|
|
|
*macvim-encoding*
|
|
It is not possible to modify 'termencoding' in MacVim; this option is forcibly
|
|
set to "utf-8". The option 'encoding' also defaults to "utf-8" (as opposed to
|
|
"latin1" in the other GUI ports).
|
|
|
|
Note: UTF-8 can represent all characters defined in Unicode, which includes
|
|
all characters in all other standard encodings, so it should be perfectly safe
|
|
to edit files in any encoding while 'encoding' is set to "utf-8". Of course,
|
|
you may need to set 'fileencodings' to auto-detect the encoding of the files
|
|
you edit, or force the detection with |++enc| on the command line.
|
|
|
|
However, if you are editing files that use multiple encodings (container
|
|
formats like MIME or Unix mbox files) or no standard encoding (binary data,
|
|
see also |edit-binary|), you may want to prevent MacVim from re-encoding the
|
|
file at all. In this situation, you will need to set both 'encoding' and
|
|
'fileencodings' to a simple single-byte encoding such as Latin1 so that when
|
|
the file is read into memory, the original bytes are left untouched.
|
|
|
|
*macvim-shift-movement*
|
|
Text editors on Mac OS X lets the user hold down shift+movement key to extend
|
|
the selection. Also, pressing a printable key whilst selecting replaces the
|
|
current selection with that character. MacVim can emulate this kind of
|
|
behaviour (by providing key bindings and by setting 'keymodel' and
|
|
'selectmode' to non-default values) although it is not enabled by default. To
|
|
make MacVim behave more like TextEdit and less like Vim, add the following
|
|
lines to your "~/.vimrc" (not .gvimrc) file: >
|
|
if has("gui_macvim")
|
|
let macvim_hig_shift_movement = 1
|
|
endif
|
|
<
|
|
*macvim-drag-n-drop*
|
|
Dragging files and dropping them on a window opens those files in tabs in that
|
|
window, unless Vim is in command-line mode. In command-line mode the names of
|
|
the files are added to the command line. Holding down modifier keys whilst
|
|
dragging is not supported.
|
|
|
|
If a file is dropped on the Dock icon, it is always opened in a new tab
|
|
regardless of the mode Vim is currently in. The same holds if you
|
|
double-click on a file in the Finder.
|
|
|
|
The "Open files from applications" preference in the General preference pane
|
|
gives more options on how dropped files should open, in case tabs are not
|
|
desired.
|
|
|
|
*macvim-default-menu*
|
|
The default menu in MacVim has been changed to conform better with the Apple
|
|
Human Interface Guidelines (HIG). At the moment this breaks the localized
|
|
menus, so only English menus are supported.
|
|
|
|
Note: The menus are a work in progress. If you know something about the HIG
|
|
and want to contribute to MacVim you could do so by making the menus better.
|
|
|
|
*macvim-window-title*
|
|
The default window title does not include the argument list because it looks
|
|
really bad once you start using tabs. For example, dropping two files, then
|
|
dropping two more, and switching back to the first tab would cause weird
|
|
strings like "((3) of 2)" to appear in the window title.
|
|
|
|
*macvim-tablabel*
|
|
Tab labels only show the tail of the file name to make the tabs more readable
|
|
when editing files in deeply nested folders. Add the line "set guitablabel="
|
|
to your .gvimrc file to revert back to the default Vim tab label.
|
|
|
|
*macvim-options*
|
|
These are the non-standard options that MacVim supports:
|
|
'antialias' 'blurradius' 'fullscreen'
|
|
'fuoptions' 'macligatures' 'macmeta' 'macthinstrokes'
|
|
'toolbariconsize' 'transparency'
|
|
|
|
*macvim-commands*
|
|
These are the non-standard commands that MacVim supports:
|
|
|:macaction| |:macmenu|
|
|
|
|
*macvim-find*
|
|
Whenever you search for something in Vim (e.g. using "/") the search query is
|
|
copied to the OS X "Find Pasteboard". The idea is that if you search for
|
|
something and switch to another application, then you can hit <D-g> (or <D-G>)
|
|
to repeat the search in the new app. The same feature works if you search in
|
|
some app, switch to MacVim and hit <D-g>.
|
|
|
|
Note that the command |n| is not the same as <D-g>. The former will repeat
|
|
the last search made in Vim, whereas the latter searches for the string on the
|
|
OS X Find Pasteboard using the action findNext: (see |:macaction|).
|
|
|
|
The <D-g> key equivalent is a great way to bring a search from one window to
|
|
another in MacVim. Simply search for something in one window (using "/") then
|
|
switch to another (e.g. with <D-`>) and hit <D-g> and the search will be
|
|
repeated in the new window.
|
|
|
|
*macvim-backspace* *macvim-delete*
|
|
The 'backspace' option is set in the system vimrc to make the delete key
|
|
behave in a more familiar way to new users. If you dislike this non-default
|
|
behaviour, then add the line "set backspace&" to your "~/.vimrc" file.
|
|
|
|
==============================================================================
|
|
2. Starting MacVim *macvim-start*
|
|
|
|
The easiest way to start MacVim is by double-clicking its icon in the Finder,
|
|
but most users will probably prefer to use the Terminal. First some Finder
|
|
related ways of starting MacVim are described, then Terminal is discussed.
|
|
Note that you can put MacVim anywhere on your hard drive, but in this help
|
|
file it is assumed that you have put it inside your /Applications folder.
|
|
|
|
MacVim automatically registers itself as an editor of several standard file
|
|
formats. This enables you to double-click a file to open it with MacVim (if
|
|
it is not associated with another program), or to right-click a file to bring
|
|
up the "Open with" menu. You can also drag and drop files onto the Dock icon
|
|
to open them in tabs in a new window, or you can drop them in an already open
|
|
window to open the files in tabs in that specific window (it is possible to
|
|
have files open in e.g. splits by changing the "Open files from applications"
|
|
option in the General preference pane). Finally, you can use Mac OS X System
|
|
Services to open files in MacVim, see |macvim-services|.
|
|
|
|
There are essentially two ways to start MacVim from Terminal: either call the
|
|
Vim binary with the -g switch >
|
|
/Applications/MacVim.app/Contents/MacOS/Vim -g file ...
|
|
or use the "open" command (this method can not be used to pass parameters to
|
|
Vim) >
|
|
open -a MacVim file ...
|
|
The advantage of using the latter method is that the settings relating to file
|
|
opening in the preferences panel are respected, and files open instantly if
|
|
|Quickstart| is enabled.
|
|
|
|
To save yourself from having to type the entire path to the Vim binary each
|
|
time you start MacVim, you could create an alias such as >
|
|
alias gvim='/Applications/MacVim.app/Contents/MacOS/Vim -g'
|
|
and add that to "~/.profile".
|
|
|
|
Note: Do NOT call the MacVim binary inside the app bundle to start MacVim.
|
|
|
|
*mvim*
|
|
A more flexible way to start MacVim is to use the shell script "mvim" which
|
|
comes bundled with MacVim. Put this script in a folder in your path and then
|
|
simply type "mvim" to start MacVim. This script will try to find MacVim.app
|
|
in various typical folders such as >
|
|
~/Applications ~/Applications/vim
|
|
/Applications /Applications/vim
|
|
/Applications/Utilities /Applications/Utilities/vim
|
|
If you would rather put MacVim.app in some other directory then that is also
|
|
possible, simply set the environment variable VIM_APP_DIR to whatever folder
|
|
you have placed MacVim.app in.
|
|
|
|
The "mvim" script can be symlinked to in order to start up MacVim in different
|
|
modes as follows (assuming you placed "mvim" in "/usr/local/bin"): >
|
|
* Diff: ln -s /usr/local/bin/mvim mvimdiff
|
|
* Read-only: ln -s /usr/local/bin/mvim mview
|
|
* Ex: ln -s /usr/local/bin/mvim mex
|
|
* Restricted: ln -s /usr/local/bin/mvim rmvim
|
|
If the symlink destination starts with "m" (or "g"), Vim will start in GUI
|
|
mode. Removing the initial "m" from the above destination names makes Vim
|
|
start without the GUI. (In the last case, the destination name can be
|
|
"rmvim", "rgvim" or "rvim".)
|
|
|
|
Note: Starting MacVim by creating a symlink to >
|
|
.../MacVim.app/Contents/MacOS/Vim
|
|
with 'ln -s' does not work.
|
|
|
|
Once in terminal Vim it is possible to start MacVim by using the following
|
|
command:
|
|
:gui [++opt] [+cmd] [-f|-b] [files...]
|
|
Note: Forking ("-b") currently does not work.
|
|
|
|
*Quickstart*
|
|
Quickstart ensures that new windows open instantaneously e.g. when <D-n> is
|
|
pressed. This feature can be enabled from the Advanced preferences pane (it
|
|
is disabled by default). Note that this setting does not affect the speed
|
|
with which windows open when using the |mvim| command.
|
|
|
|
Note that any changes to runtime files that are kept in a non-standard
|
|
location (i.e. not in ~/.vim) will not be picked up for the first window that
|
|
opens after any changes. Also, there are some issues related to reading and
|
|
writing of the |viminfo| file which can lead to the command line history
|
|
appearing to be lost (as well as any other information stored in the |viminfo|
|
|
file). For example, if you open a window, edit some files then close the
|
|
window, then the next window that opens will not have the same command line
|
|
history as the window you just closed (however the next window you open will).
|
|
For these reasons Quickstart is disabled by default.
|
|
|
|
*odbeditor* *external-editor*
|
|
MacVim can act as an 'external editor' for Mac OS X applications that support
|
|
the ODB Editor Protocol (or the 'external editor' protocol). Each application
|
|
has different ways of configuring this option, check the application's
|
|
documentation. Once configured properly MacVim can be used to open files in
|
|
such an application.
|
|
|
|
A technical note: MacVim handles file open, modified and closed events. In
|
|
the open event the FTok and Burl parameters are parsed (the latter is ignored
|
|
at the moment though). In the modified and closed events the Tokn parameter
|
|
is sent back to the server application.
|
|
|
|
==============================================================================
|
|
3. Preferences *macvim-prefs* *macvim-preferences*
|
|
|
|
Some settings are global to the MacVim application and would not make sense as
|
|
Vim options. These settings are stored in the user defaults database and can
|
|
be accessed via the "MacVim.Preferences..." menu item.
|
|
|
|
*macvim-user-defaults*
|
|
Not all entries in the user defaults database are exposed via the preference
|
|
panel, usually because they should not be changed by the user under normal
|
|
circumstances. These options can still be changed with the "defaults" command
|
|
by opening Terminal and typing >
|
|
defaults write org.vim.MacVim KEY VALUE
|
|
Check the man page on "defaults" for more information on this command as well
|
|
as general information regarding Mac OS X user defaults.
|
|
|
|
Here is a list of relevant dictionary entries:
|
|
|
|
KEY VALUE ~
|
|
MMCellWidthMultiplier width of a normal glyph in em units [float]
|
|
MMDialogsTrackPwd open/save dialogs track the Vim pwd [bool]
|
|
MMFullScreenFadeTime fade delay for non-native fullscreen [float]
|
|
MMLoginShellArgument login shell parameter [string]
|
|
MMLoginShellCommand which shell to use to launch Vim [string]
|
|
MMNoFontSubstitution disable automatic font substitution [bool]
|
|
MMNoTitleBarWindow hide title bar [bool]
|
|
MMShowAddTabButton enable "add tab" button on tabline [bool]
|
|
MMTabMaxWidth maximum width of a tab [int]
|
|
MMTabMinWidth minimum width of a tab [int]
|
|
MMTabOptimumWidth default width of a tab [int]
|
|
MMTextInsetBottom text area offset in pixels [int]
|
|
MMTextInsetLeft text area offset in pixels [int]
|
|
MMTextInsetRight text area offset in pixels [int]
|
|
MMTextInsetTop text area offset in pixels [int]
|
|
MMTexturedWindow use brushed metal window (Tiger only) [bool]
|
|
MMTranslateCtrlClick interpret ctrl-click as right-click [bool]
|
|
MMUseMouseTime use mousetime to detect multiple clicks [bool]
|
|
MMVerticalSplit files open in vertical splits [bool]
|
|
MMZoomBoth zoom button maximizes both directions [bool]
|
|
|
|
As an example, if you have more than one mouse button and would wish to free
|
|
up Ctrl-click so you can bind it to something else, then the appropriate
|
|
command is: >
|
|
defaults write org.vim.MacVim MMTranslateCtrlClick 0
|
|
|
|
If you wish to restore all user defaults to their starting values, open
|
|
Terminal and type: >
|
|
defaults delete org.vim.MacVim
|
|
<
|
|
*macvim-login-shell*
|
|
Applications opened from the Finder do not automatically source the user's
|
|
environment variables (which are typically set in .profile or .bashrc). This
|
|
presents a problem when using |:!| to execute commands in the shell since e.g.
|
|
$PATH might not be set properly. To work around this problem MacVim starts
|
|
new Vim processes via a login shell so that all environment variables are set.
|
|
|
|
By default MacVim uses the $SHELL environment variable to determine which
|
|
shell to use (if $SHELL is not set "/bin/bash" is used). It is possible to
|
|
override this choice by setting the user default MMLoginShellCommand to the
|
|
shell that should be used (e.g. "/bin/tcsh"). MacVim tries to make the shell
|
|
a login shell by prepending argv[0] with a dash. If you use an exotic shell
|
|
and need to pass it a parameter to make it a login shell then you can set the
|
|
user default MMLoginShellArgument (e.g. to "-l"). Finally, if the "bash"
|
|
shell is used, then "-l" is automatically added as an argument. To override
|
|
this behaviour set MMLoginShellArgument to "--".
|
|
|
|
==============================================================================
|
|
4. Special colors *macvim-colors*
|
|
|
|
The colors in MacVim are defined in two dictionaries inside the "Resources"
|
|
folder of the application bundle (MacVim.app/Contents/Resources). It is
|
|
possible to add more colors by modifying these files. Color names are case
|
|
insensitive when accessed from Vim, but in the dictionary they must be
|
|
lowercase.
|
|
|
|
*SystemColors.plist*
|
|
There are only a few system colors that can be accessed from Vim. These
|
|
colors are defined in the dictionary "SystemColors.plist". This dictionary
|
|
stores (key, value) pairs where the key is the name of the color and the
|
|
value is an NSColor selector name.
|
|
|
|
The most useful system colors are: >
|
|
MacSelectedTextBackgroundColor
|
|
MacSecondarySelectedColor
|
|
The former is the "Highlight Color" which can be changed in the "Appearance"
|
|
section of the System Preferences. The latter is the selection color used by
|
|
a Cocoa application when it is not in focus.
|
|
|
|
*Colors.plist*
|
|
Apart from the system colors, it is also possible to use the standard X11
|
|
color names (see http://en.wikipedia.org/wiki/X11_color_names) which usually
|
|
come in a file called "rgb.txt". MacVim does not have such a file, instead it
|
|
keeps these colors in a dictionary called "Colors.plist". The key in this
|
|
dictionary is the name of the color and the value is an RGB value on the form
|
|
#rrggbb stored as an integer.
|
|
|
|
*macvim-colorscheme*
|
|
MacVim ships with a custom color scheme that is used instead of the default
|
|
Vim color scheme. The color scheme can be changed with >
|
|
:colorscheme macvim
|
|
If you prefer a dark background color, then type >
|
|
:set bg=dark
|
|
after having loaded the "macvim" color scheme.
|
|
|
|
Use the |:colorscheme| command if you want to use another color scheme. Note
|
|
that if you want to set syntax highlight colors manually, then you must either
|
|
create your own color scheme or add the line >
|
|
let macvim_skip_colorscheme=1
|
|
to your ~/.vimrc (~/.gvimrc will not work). Otherwise the "macvim" color
|
|
scheme will be loaded when the system gvimrc file is sourced and mess up your
|
|
changes.
|
|
|
|
The color scheme uses the system "Highlight Color", which can be changed in
|
|
the "Appearance" pane of the System Preferences. It also changes the
|
|
highlight color when a window becomes inactive.
|
|
|
|
==============================================================================
|
|
5. Menus *macvim-menus*
|
|
|
|
Menus in Mac OS X behave slightly different from other platforms. For that
|
|
reason two new commands have been added to Vim. To understand what these
|
|
commands do you must first understand how menus work on OS X.
|
|
|
|
Each entry in a menu is called a "menu item". With each menu item is
|
|
associated: a title, a key equivalent and an action message. When a menu is
|
|
displayed the title is shown on the left and the key equivalent (if any) is
|
|
shown on the right. Key equivalents enable you to access a menu item using
|
|
the keyboard instead of having to use the mouse. When a menu item is clicked
|
|
it will send it's associated action message. Actions can be used to instruct
|
|
MacVim to paste some text (paste:), open a new window (newWindow:), etc.
|
|
Certain actions are standard throughout OS X which is why MacVim must be able
|
|
to set these for each menu item. (E.g. the menu item "Edit.Paste" must be
|
|
bound to the action "paste:" otherwise pasting won't work in dialogs since
|
|
that is the action that instructs them to paste something.)
|
|
|
|
Menus are configured using the |:macmenu| command and the |:macaction| command
|
|
can be used to send action messages.
|
|
|
|
*:maca* *:macaction*
|
|
:maca[ction] {action:} Send the message "action:" to the first responder.
|
|
The list of allowed actions can be seen by typing
|
|
:maca <C-d>
|
|
An attempt to send an action not listed here will
|
|
result in an error. This list is specified in a
|
|
property list file called |Actions.plist|.
|
|
|
|
*:macm* *:macmenu*
|
|
:macm[enu] {menu} {key}={arg} ...
|
|
Set Mac specific properties for {menu}. The
|
|
properties that can be set are:
|
|
action the action this menu sends
|
|
alt "yes" if alternate of previous menu
|
|
key the key equivalent of this menu
|
|
This command must be used in a startup file, for
|
|
example in "~/.gvimrc". It has no effect otherwise.
|
|
|
|
For convenience, a menu with "action=name:" which is
|
|
bound to <Nop> will act as if bound to
|
|
":maca name:<CR>". Thus, if "Menu.Item" is given by
|
|
:an Menu.Item <Nop>
|
|
:macm Menu.Item action=name:
|
|
then ":emenu Menu.Item" is equivalent to
|
|
":maca name:".
|
|
|
|
The key equivalent is specified with the <D-..>
|
|
syntax. This is case-sensitive, so <D-a> means Cmd-a
|
|
whereas <D-A> means Cmd-Shift-a.
|
|
Note that key equivalents must contain the Cmd
|
|
modifier flag (<D-..>), and they take precedence over
|
|
normal mappings.
|
|
Use the syntax "key=<nop>" to clear the key equivalent
|
|
of a menu. This can be used to free up a key
|
|
combination that is set in the system gvimrc so that
|
|
it may be mapped to using ":map".
|
|
|
|
Recognised values of "alt" are "0", "no", "1", and
|
|
"yes". The default is "no". An alternate menu must
|
|
have the same key equivalent as the previous menu,
|
|
except the modifier flags must differ. The alternate
|
|
menu is by default hidden and only shows up when the
|
|
modifier is held down.
|
|
|
|
Here are some examples on how to use these commands:
|
|
|
|
1. Create a menu item with title "New Window" under the "File" menu, with key
|
|
equivalent Cmd-n, which opens a new window when selected: >
|
|
:an 10.290 File.New\ Window <Nop>
|
|
:macm File.New\ Window action=newWindow: key=<D-n>
|
|
2. Change the key equivalent to cycle through tabs to Cmd-Left/Right: >
|
|
:macm Window.Previous\ Tab key=<D-Left>
|
|
:macm Window.Next\ Tab key=<D-Right>
|
|
3. Create a mapping in normal mode which closes the current tab/window: >
|
|
:map <C-w> :maca performClose:<CR>
|
|
4. Free up Cmd-t and remap it to open a file browser in a split view: >
|
|
macm File.New\ Tab key=<nop>
|
|
nmap <D-t> :sp .<CR>
|
|
Note: These two lines must be added to .gvimrc else the first line will fail.
|
|
The second line is case sensitive, so <D-T> (Cmd-Shift-t) is not the same as
|
|
<D-t> (Cmd-t)!
|
|
|
|
The default menus are set up in "$VIMRUNTIME/menu.vim". Take a look at that
|
|
file for more examples on how to set up menus. Note: When no window is open a
|
|
minimal default menu is used. The default menu is set up in MainMenu.nib
|
|
which resides in "Resources/English.lproj/" folder inside the app bundle.
|
|
|
|
*Actions.plist*
|
|
Some action messages would not be suitable to call from within Vim, so there
|
|
is a dictionary called "Actions.plist" (in the Resources folder of the
|
|
application bundle) which contains all actions that may be called. The key in
|
|
this dictionary is the name of the action message (case sensitive), the value
|
|
is not used.
|
|
|
|
Hint: The |:macaction| command supports command-line completion so you can
|
|
enter ":maca<Space><C-d>" to see a list of all available actions.
|
|
|
|
Here is a random assortment of actions from Actions.plist which might be
|
|
useful.
|
|
|
|
Action Description ~
|
|
fileOpen: Show "File Open" dialog
|
|
findNext: Search forward using the "Find Pasteboard"
|
|
findPrevious: Search backward using the "Find Pasteboard"
|
|
fontSizeDown: Decrease font size
|
|
fontSizeUp: Increase font size
|
|
hide: Hide MacVim
|
|
miniaturizeAll: Minimize all windows to the dock
|
|
newWindow: Open a new (empty) window
|
|
orderFrontCharacterPalette: Show the the "Special Characters" dialog
|
|
orderFrontFontPanel: Show the Font panel
|
|
orderFrontPreferencePanel: Show the Preferences panel
|
|
performMiniaturize: Minimize window to the dock
|
|
performZoom: Zoom window (same as clicking the green blob)
|
|
terminate: Quit MacVim
|
|
zoomAll: Zoom all windows
|
|
_cycleWindows: Select next window (similar to <D-`>)
|
|
_cycleWindowsBackwards: Select previous window (similar to <D-S-`>)
|
|
|
|
==============================================================================
|
|
6. Toolbar *macvim-toolbar*
|
|
|
|
The toolbar in MacVim works just like in the other GUIs (see |gui-toolbar|),
|
|
with the addition of two separator items (see |menu-separator|). You can use
|
|
them as follows: >
|
|
:an ToolBar.-space1- <Nop>
|
|
:an ToolBar.-flexspace2- <Nop>
|
|
The first example creates an empty space on the toolbar, the second creates an
|
|
empty space which will shink or expand so that the items to the right of it
|
|
are right-aligned. A space (flexspace) will be created for any toolbar item
|
|
whose name begins with "-space" ("-flexspace") and ends with "-"
|
|
|
|
Toolbar icons should be tiff, png or icns, of dimension 32x32 or 24x24 pixels.
|
|
The larger size is used when 'tbis' is "medium" or "large", otherwise the
|
|
smaller size is used (which is the default). If the icon file only contains
|
|
one dimension then Mac OS X will scale the icon to the appropriate dimension
|
|
if necessary. To avoid this, use a file format which supports multiple
|
|
resolutions (such as icns) and provide both 32x32 and 24x24 versions of the
|
|
icon.
|
|
|
|
Note: Only a subset of the builtin toolbar items presently have icons. If no
|
|
icon can be found a warning triangle is displayed instead.
|
|
|
|
==============================================================================
|
|
7. Dialogs *macvim-dialogs*
|
|
|
|
Dialogs can be controlled with the keyboard in two ways. By default each
|
|
button in a dialog is bound to a key. The button that is highlighted by blue
|
|
is bound to Enter, any button with the title "Cancel" is bound to Escape, and
|
|
any button with the title "Don't Save" is bound to <D-d>. Other buttons are
|
|
usually bound to the first letter in the title of the button. There is no
|
|
visual feedback to indicate which letter a button is bound to, so sometimes
|
|
some experimentation might be required in order to figure out which key to
|
|
press.
|
|
|
|
The second way of controlling dialogs with the keyboard is to enable "Full
|
|
keyboard access" in the "Keyboard" pane of the System Preferences (you can
|
|
also toggle this on or off by pressing Ctrl-F7). Once keyboard access is
|
|
enabled it is possible to move between buttons with Tab and pressing Space to
|
|
select the current button. The current button is indicated with a blue
|
|
outline.
|
|
|
|
==============================================================================
|
|
8. System services *macvim-services*
|
|
|
|
MacVim supports two system services. These can be accessed from the MacVim
|
|
submenu in the Services menu or by right-clicking a selection. For services
|
|
to work, MacVim.app should be located in the /Applications folder. (You might
|
|
have to logout and then login again before Mac OS X detects the MacVim
|
|
services.)
|
|
|
|
These are the currently supported services:
|
|
* New MacVim Buffer With Selection: Create a new buffer and paste the
|
|
currently selected text.
|
|
* New MacVim Buffer Here: Create a new buffer and set the current
|
|
directory to the file or folder that is selected in the Finder.
|
|
|
|
The services respect the "Open files from applications" setting in the general
|
|
preferences.
|
|
|
|
==============================================================================
|
|
9. mvim:// URL handler *mvim://* *macvim-url-handler*
|
|
|
|
MacVim supports a custom URL handler for "mvim://" URLs. The handler is
|
|
supposed to be compatible to TextMate's URL scheme as documented at >
|
|
http://blog.macromates.com/2007/the-textmate-url-scheme/.
|
|
|
|
Currently, this means that the format is >
|
|
mvim://open?<arguments>
|
|
where "arguments" can be:
|
|
* url — the actual file to open (i.e. a file://... URL), if you leave
|
|
out this argument, the frontmost document is implied
|
|
* line — line number to go to (one based)
|
|
* column — column number to go to (one based)
|
|
|
|
For example, the link >
|
|
mvim://open?url=file:///etc/profile&line=20
|
|
will open the file /etc/profile on line 20 when clicked in a web browser.
|
|
|
|
Note that url has to be a file:// url pointing to an existing local file.
|
|
|
|
==============================================================================
|
|
10. Keyboard shortcuts *macvim-shortcuts*
|
|
|
|
Most keyboard shortcuts in MacVim are bound to menu items and can be
|
|
discovered by looking through the menus (see |macvim-menus| on how to create
|
|
your own menu shortcuts, see |cmd-key| on how to map your own commands to
|
|
Cmd-key shortcuts). The remaining shortcuts are listed here:
|
|
|
|
*Cmd-.* *<D-.>*
|
|
Cmd-. Interrupt Vim. Unlike Ctrl-C which is sent as normal
|
|
keyboard input (and hence has to be received and then
|
|
interpreted) this sends a SIGINT signal to the Vim
|
|
process. Use this shortcut if the Vim process appears
|
|
to have locked up and is not responding to key presses.
|
|
This Cmd-key combination cannot be unmapped.
|
|
|
|
*Cmd-`* *<D-`>*
|
|
Cmd-` Cycle to the next window. On an American keyboard the
|
|
`-key is located under the Esc-key. On European
|
|
keyboards this key is often adjacent to the left
|
|
Shift-key and it may be not even be marked with "`".
|
|
This Cmd-key combination can only be unmapped via the
|
|
"Keyboard" System Preferences.
|
|
|
|
*Cmd-Left* *<D-Left>*
|
|
Cmd-Left Move cursor to the beginning of the line
|
|
(see |cmd-movement|).
|
|
|
|
*Cmd-Right* *<D-Right>*
|
|
Cmd-Right Move cursor to the end of the line (see |cmd-movement|).
|
|
|
|
*Cmd-Up* *<D-Up>*
|
|
Cmd-Up Move cursor to the first line (see |cmd-movement|).
|
|
|
|
*Cmd-Down* *<D-Down>*
|
|
Cmd-Down Move cursor to the last line (see |cmd-movement|).
|
|
|
|
*Alt-Left* *<M-Left>*
|
|
Alt-Left Move cursor to the beginning of the previous word
|
|
(see |alt-movement|).
|
|
|
|
*Alt-Right* *<M-Right>*
|
|
Alt-Right Move cursor to the beginning of the next word
|
|
(see |alt-movement|).
|
|
|
|
*Alt-Up* *<M-Up>*
|
|
Alt-Up Move cursor one paragraph forward (see |alt-movement|).
|
|
|
|
*Alt-Down* *<M-Down>*
|
|
Alt-Down Move cursor to the previous paragraph
|
|
(see |alt-movement|).
|
|
|
|
*cmd-movement* *alt-movement*
|
|
The above mappings involving Cmd/Alt + arrow key are enabled by default in the
|
|
system gvimrc file "$VIM/gvimrc". You can quickly disable all of these by
|
|
adding the following lines to your "~/.vimrc" (not .gvimrc) file: >
|
|
if has("gui_macvim")
|
|
let macvim_skip_cmd_opt_movement = 1
|
|
endif
|
|
Note: These are the only key mappings that MacVim makes (not counting menu key
|
|
equivalents which are not set up with :map).
|
|
|
|
See |macvim-shift-movement| if you want Shift to select text when used in
|
|
conjunction with the above Cmd/Alt movement shortcuts.
|
|
|
|
*cmd-key* *cmd-shortcuts*
|
|
Creating key mappings that involve the Cmd key (<D-..> in Vim notation) can
|
|
sometimes be slightly involved. Here are all the things you need to consider:
|
|
|
|
- Make sure the shortcut is not used by a menu item by looking through the
|
|
menus. If it is then you need to unbind it before you can map to it. This
|
|
is described under the help for the |:macmenu| command.
|
|
- Bindings to <D-..> are case sensitive: <D-d> is not the same as <D-D>. If
|
|
you want to map something to Cmd+Shift+d, then you need to use <D-D>, not
|
|
<D-S-d> or <D-S-D>.
|
|
- Some command key shortcuts are reserved by Mac OS X and cannot be mapped to
|
|
(e.g. <D-Tab>). However, some of these shortcuts can be freed up in the
|
|
System Preferences under Keyboard (e.g. Cmd+Space).
|
|
- A few command key mappings are set up by MacVim, see |cmd-movement|.
|
|
|
|
==============================================================================
|
|
11. Trackpad gestures *macvim-gestures*
|
|
|
|
MacVim supports trackpad swipe gestures. By default this can be used to
|
|
navigate back/forward in the help (try it!).
|
|
|
|
Each gesture generates one of the following Vim pseudo keys:
|
|
|
|
*<SwipeLeft>* *<SwipeRight>*
|
|
Generated when swiping three fingers across the trackpad in a
|
|
horizontal direction. The Apple Magic Mouse generates these
|
|
events when swiping two fingers in a horizontal direction.
|
|
|
|
*<SwipeUp>* *<SwipeDown>*
|
|
Generated when swiping three fingers across the trackpad in a
|
|
vertical direction. (Not supported by the Apple Magic Mouse.)
|
|
|
|
You can map these keys like with any other key using the |:map| family of
|
|
commands. For example, the following commands map left/right swipe to change
|
|
to the previous/next tab in normal mode: >
|
|
|
|
nmap <SwipeLeft> gT
|
|
nmap <SwipeRight> gt
|
|
|
|
As another example, here is how to switch buffers by swiping left/right: >
|
|
|
|
nmap <SwipeLeft> :bN<CR>
|
|
nmap <SwipeRight> :bn<CR>
|
|
|
|
See the section on |key-mapping| for more help on how to map keys.
|
|
|
|
==============================================================================
|
|
12. International *macvim-international*
|
|
|
|
When editing non-English text it may be convenient to keep separate keyboard
|
|
layouts for normal and insert mode. This is supported via the 'imd' option on
|
|
Mac OS X 10.5 or later (on 10.4 the 'imd' option support is not as useful as
|
|
it only switches between Roman and non-Roman input sources and it has been
|
|
known not to work very reliably).
|
|
|
|
For example: When 'noimd' is enabled (i.e. IM is enabled) the input source is
|
|
saved when toggling between normal and insert mode, so you can use a US layout
|
|
in normal mode then switch to insert mode and choose a Swedish layout. When
|
|
you go back to normal mode the US layout will be selected and when you enter
|
|
insert mode the Swedish layout is selected. This also works when searching
|
|
for text etc. see 'imc', 'imi', 'ims'.
|
|
|
|
Note that the layout used in normal mode is the layout used when 'noimd' is
|
|
set (i.e when IM is enabled). If you find that MacVim switches to the
|
|
wrong layout when going back to normal mode, then select the layout you want
|
|
to use in normal mode and type ":set imd" followed by ":set noimd".
|
|
|
|
==============================================================================
|
|
13. Known bugs/missing features *macvim-todo*
|
|
|
|
This list is by no means exhaustive, it only enumerates some of the more
|
|
prominent bugs/missing features.
|
|
|
|
- Localized menus are not supported. Choosing anything but "English" in the
|
|
"International" pane of "System Prefences" may break the menus (and
|
|
toolbar).
|
|
- Some Unicode characters are not handled well (e.g. nonspacing marks)
|
|
- Sometimes multibyte characters look "too wide", i.e. they overlap the
|
|
following character. It might help to change 'ambiwidth', or override the
|
|
automatic font substitution by setting 'guifontwide' manually.
|
|
- Printing. As a temporary solution <D-p> creates a PostScript file which is
|
|
then opened in Preview where it may be printed.
|
|
- The toolbar looks ugly and is not very useful.
|
|
|
|
If you find new bugs then please post your findings to the vim_mac mailing
|
|
list: *vim_mac* >
|
|
http://groups.google.com/group/vim_mac
|
|
|
|
This is also the best place for making feature requests as well as for asking
|
|
general questions about MacVim.
|
|
|
|
==============================================================================
|
|
14. Hints *macvim-hints*
|
|
|
|
In this section some general (not necessarily MacVim specific) hints are
|
|
given.
|
|
|
|
Scenario: ~
|
|
You try opening a bunch of files in tabs but not all files get opened in their
|
|
own tab.
|
|
Solution: ~
|
|
To get around this, set 'tabpagemax' to something big in your .gvimrc file
|
|
(e.g. ":set tabpagemax=100").
|
|
|
|
Scenario: ~
|
|
You want to open a file in a tab in an already opened window, but typing "mvim
|
|
filename" in Terminal opens it up in a separate window.
|
|
Solution: ~
|
|
Use the |--remote-tab| switch. If you have several windows open you might
|
|
have to specify which window you want the file to open in by using the
|
|
|--servername| switch. The title of a window usually ends in something like
|
|
"VIM" or "VIM3" --- this is the server name of that window. So to open a file
|
|
named "foobar.txt" in a window whose title ends in "VIM3" you would type (the
|
|
order of the arguments matters): >
|
|
mvim --servername VIM3 --remote-tab foobar.txt
|
|
For more information, consult the |client-server| manual page.
|
|
|
|
Scenario: ~
|
|
You like to be able to select text by holding down shift and pressing the
|
|
arrow keys and find the Vim way of selecting text strange.
|
|
Solution: ~
|
|
See |macvim-shift-movement|.
|
|
|
|
Scenario: ~
|
|
You do not want MacVim to set up any key mappings.
|
|
Solution: ~
|
|
See |cmd-movement|.
|
|
|
|
Scenario: ~
|
|
Enabling localized menus breaks the toolbar and the menus as well.
|
|
Solution: ~
|
|
This is a known problem, see |macvim-todo|.
|
|
|
|
Scenario: ~
|
|
When you click the (green) zoom button you want the window to maximize
|
|
horizontally as well as vertically.
|
|
Solution: ~
|
|
Hold down Cmd and click the zoom button. If you prefer this to be the default
|
|
action, then set the user default MMZoomBoth (see |macvim-prefs|).
|
|
|
|
Scenario: ~
|
|
Typing feels sluggish when the cursor is just before a right bracket (i.e.
|
|
')', '}', or ']').
|
|
Solution: ~
|
|
Disable the "matchparen" plugin (see |matchparen|) by typing :NoMatchParen.
|
|
If that helps, then you can permanently disable "matchparen" by adding the
|
|
following line to your "~/.vimrc": >
|
|
let loaded_matchparen=1
|
|
<
|
|
Scenario: ~
|
|
You want to use MacVim as an editor for some external application.
|
|
Solution: ~
|
|
If the external application lets you set a program to execute then something
|
|
like "mvim -f" might be all you need (the "-f" switch ensures that the "mvim"
|
|
script returns only after you close the editor window, otherwise "mvim"
|
|
returns immediately). If the external program honors the EDITOR environment
|
|
variable (e.g Git does this) then you may get away by adding the following
|
|
line to your "~/.profile": >
|
|
export EDITOR='mvim -f'
|
|
If you have not installed the "mvim" script in your path you can provide the
|
|
path to the Vim binary instead. Thus, if "MacVim.app" resides in the
|
|
Applications folder then you would use the following line: >
|
|
export EDITOR='/Applications/MacVim.app/Contents/MacOS/Vim -g -f'
|
|
|
|
Scenario: ~
|
|
You have set MacVim to open from an external program and when you finish
|
|
editing (by closing the MacVim window) you want the external program to regain
|
|
focus.
|
|
Solution: ~
|
|
Use the VimLeave autocommand to hide MacVim when the window closes: >
|
|
au VimLeave * maca hide:
|
|
Assuming your external program has a setting for which command to execute to
|
|
bring up an editor, you would set that option to something like: >
|
|
mvim -f -c "au VimLeave * maca hide:"
|
|
(See the above Scenario for an explanation of the "-f" switch.)
|
|
|
|
Scenario: ~
|
|
You would like to remap Caps Lock to Esc.
|
|
Solution: ~
|
|
The app "PCKeyboardHack" can be used to remap Caps Lock. It is available as a
|
|
free download from: >
|
|
http://pqrs.org/macosx/keyremap4macbook/extra.html
|
|
On some Apple keyboards the Caps Lock key doesn't immediately register and
|
|
this makes Caps Lock "drop" key presses. To work around this problem go into
|
|
the "Keyboard" System Preference and remap Caps Lock to Ctrl first (click the
|
|
"Modifier Keys..." button). This trick may also be necessary if the Caps Lock
|
|
light turns on/off despite having remapped to Esc.
|
|
|
|
Scenario: ~
|
|
You have problems creating custom mappings involving the Cmd key.
|
|
Solution: ~
|
|
To bind to a key involving Cmd you use the "<D-..>" syntax. Many Cmd-key
|
|
mappings are already used by the menus so if your mapping doesn't work then
|
|
the solution is usually to first unmap the menu binding (see |macvim-menus|,
|
|
in particular read the end of that section). Also see the section on
|
|
|macvim-shortcuts| for some Cmd-key combinations which are not used by the
|
|
menus but still need to be freed up before they can be used in custom bindings.
|
|
|
|
Scenario: ~
|
|
You can't find the information on MacVim you thought should be in this manual
|
|
page.
|
|
Solution: ~
|
|
Post your question on the |vim_mac| mailing list and wait for an answer.
|
|
|
|
vim:tw=78:sw=4:ts=8:ft=help:norl:
|