Guides Give Yourself a Menu in Vim

Give Yourself a Menu in Vim




This week, I have a quick couple of tips for Vim users that should make life just a little bit easier when using Vim in command mode and completing filenames.

By default, when you use Vim you can type the first letter or first few letters of a command, and you’ll be able to cycle through the commands using Tab. For example, type :e, and you can cycle through all the commands that begin with e:

earlier
echo
echoerr
echohl

That’s just a short list. But what if you’d like to see a quick menu of the available commands instead? For this, you have a little-known Vim option, wildmenu. As a reminder for folks not particularly well-versed with Vim, the : tells Vim to enter command mode from its normal mode.

While in Vim, just run :set wildmenu, and you’ll toggle the option to enable the enhanced command-line completion. Note that you enable this any time by adding it to your ~/.vimrc.

So what does this little toggle get you? Now when you hit Tab, you’ll get a one-line menu at the bottom so you can see all the options that begin with the letters you’ve typed. So :e will give you the same list as before, but in a one-line menu at the bottom. Hit Tab again, and it will move to the next command, and so forth. You can also use Ctrl-p and Ctrl-n to move backward and forward (respectively) through the list.

This doesn’t work just with commands, though–it also works with filenames. If you’re looking to open a file, for example, using :r (read) and you type the first character or characters, hitting Tab will display all the filenames that match in a one-line menu at the bottom.

Setting wildmenu is a minor thing, but it’s another way to boost productivity and make Vim a bit more usable. I recommend giving this a shot. See if you don’t find that it makes life a bit easier!

Joe ‘Zonker’ Brockmeier is a freelance writer and editor with more than 10 years covering IT. Formerly the openSUSE Community Manager for Novell, Brockmeier has written for Linux Magazine, Sys Admin, Linux Pro Magazine, IBM developerWorks, Linux.com, CIO.com, Linux Weekly News, ZDNet, and many other publications. You can reach Zonker at [email protected] and follow him on Twitter.

Follow ServerWatch on Twitter

Latest Posts

How to Convert a Physical Computer to a Virtual Machine

Many organizations are implementing virtualization technology into their networks to convert physical computers to virtual machines (VM). This helps reduce overall physical hardware costs,...

HPE ProLiant DL380 Gen10: Rack Server Overview and Insight

The HPE ProLiant DL380 series has consistently been a market leader in the server space. The Gen10 released in 2017 further increased HPE's market...

Best Server Management Software & Tools 2021

Finding the best server management software tools for your organization can have a major impact on the success of your business operations. Manually handling...

IBM AS/400: Lasting the Test of Time

Some server operating systems (OS) were built to survive the test of time – the IBM AS/400 is one such system.  The AS/400 (Application System/400)...

What is Disaster Recovery?

The modern organization's heavy dependence on using data to drive their business has made having a Disaster Recovery (DR) plan in place a necessity....

Related Stories