Mar 29, 2009

How to hide menu and tool bar in GVim

By default, GVim has a menu and tools bar, like this:

But most of the time, the reason why people use GVim or Vim is that they don't need to use mouse - the powerful keyboard shortcut is enough for an efficient editing. So it seems like a waste of space to have this menu and tools bar. Here I will introduce a tip to hide the menu and a keyboard shortcut to recall it.

In your .vimrc file, add the following lines.

"Toggle Menu and Toolbar
set guioptions-=m
set guioptions-=T
map <silent> <F2> :if &guioptions =~# 'T' <Bar>
\set guioptions-=T <Bar>
\set guioptions-=m <bar>
\else <Bar>
\set guioptions+=T <Bar>
\set guioptions+=m <Bar>

The next time you use GVim, it will automatically hide the menu bar. And you can use F2 to recall it and hide it again.

Note that you can change the second and third lines to the following(with a "+" sign), and GVim will start with a menu bar and you still can toggle with F2 key.

set guioptions+=m
set guioptions+=T

Welcome to Non-geek's
Linux Handbook!

or if you will, Linux Cookbook.

tutorials on Linux applications~

Subscribe if you are willing to follow.

If you find the post useful, please click the donate button on the upper right corner. Any amount is useful.