18

I'd like to remove some of the default icons and maybe add one or two icons of my own. For example, it would be nice if there were icons for the NerdTree and the Taglist.

2 Answers 2

11

Ludwig's answer got me started, but it was not really the kind of answer I hoped for. So I made the question community-wiki and leave this answer with what I found out. The answer will be improved as I go along.

Find out what the toolbar currently consists of

:tmenu ToolBar

This will give you a listing of the commands currently on your toolbar. It will list the position, name and tooltip for each entry.

Delete something from the default toolbar

You can use your .gvimrc to delete entries from your default toolbar. For example, to get rid of the make command:

:aunmenu ToolBar.Make

You need to specify the menu ("ToolBar") and the name of the command ("Make").

Add a new entry to your toolbar

To add a new command to the toolbar, use the tmenu and amenu command. For example, the following commands will add an icon that will toggle the display of the taglist (of course, you need to install the taglist plugin first):

:tmenu ToolBar.taglist Toggle display of the Taglist
:amenu ToolBar.taglist :TlistToggle<CR>

Again, you need to specify the name of the menu ("ToolBar") and the name of your new menu entry ("taglist"). The name of the new entry will also be used to search for an icon. You can place the icon in your ~/.vim/bitmaps/ directory (simply create it if it doesn't exist yet). Supposedly, you need a .bmp on Windows and a .xpm everywhere else. The icon's size needs to be 18 x 18 pixels.

tmenu is responsible for the tooltip displayed when hovering the icon. Use amenu to decide what should happen when the icon is clicked.

1
  • Just to add, you can create a menu entry by replacing ToolBar with your own menu title.
    – TiCL
    Sep 24, 2011 at 6:17
6

I found this tutorial helpful. The most interesting part is quoted below:

:tmenu 1.190 ToolBar.b2u beta2unicode
:imenu ToolBar.b2u <Esc>:source ~/.vim/scripts/beta2unicode<CR>

In the first line 1.190 indicates a position on the toolbar. In ToolBar.b2u “b2u” is the name of the image (without the bmp extension). The last item on the first line is a short description of the action associated with the icon (or button, as you want to call it) on the toolbar.

In the second line, ToolBar.b2u follows the same logic as on in the first line. The last part,

:source ~/.vim/scripts/beta2unicode.vim

starts with a change of the Vim mode to the command line mode. The command is to “source” (to interpret and execute) the script. The VIMHOME here is ~/.vim/. The folder in the VIMHOME is scripts| and \verb|beta2unicode.vim is the name of the script. is the equivalent of pressing the Enter key.

It basically works like adding other menus. You can find the details in vim's help (:help menu).

4
  • That's a start, but not really a good one. This tutorial only works on Windows and it explains almost nothing. However, it gave me some more keywords for Googling.
    – innaM
    Jul 23, 2009 at 16:26
  • @Manni: Hmm, it should be enough to get you started, after that it is IMHO best to stick to vim help anyway. For the 'only works on Windows' part: Can you explain what didn't work for you? Jul 23, 2009 at 16:55
  • The tutorial tells you to create icons in .bmp format. On everything that is not Windows, you need .xpm.
    – innaM
    Jul 23, 2009 at 18:21
  • Don't get me wrong though. This really got me started. I just hope that there is something a little better out there.
    – innaM
    Jul 23, 2009 at 18:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .