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