Vim Tips Wiki
Register
Advertisement
Tip 1045 Printable Monobook Previous Next

created November 9, 2005 · complexity basic · author Matt Zyzik · version 5.7


Put these two in your vimrc, and you'll enjoy the greatest wildmode that isn't fully documented in the Vim help.

set wildmenu
set wildmode=list:longest,full

"set wildmenu" enables a menu at the bottom of the vim/gvim window.

The meaning of "list:longest,full" is so that when you do completion in the command line via tab, these events will happen:

1. (on the first tab) a list of completions will be shown and the command will be completed to the longest common command.

2. (on second tab) the wildmenu will show up with all the completions that were listed before.

To test it out, type ":spe" and then hit tab once to see 1 and hit tab again to see 2.

set mouse=a

Put that line in your vimrc to enable full mouse support in the console.

This way you won't have to wait for gvim's excessively long startup and just run Vim in an xterm, having full mouse/scrollwheel support.

With both the above features, Vim in the console is practically just as good as gvim (":emenu" command could be used to access the gvim menus).

Comments[]

 TO DO 

  • This tip is made up of two completely unrelated topics. Split into two tips (probably just merge info into other tips and delete this one).

In Vim 7.0 there are nice popups when you hit Ctrl-n for completing current word, both in gvim and console Vim.


I've used "set mouse=a" before, but sometimes it behaves oddly in my xterm.

For example, sometimes, I have started an xterm shell, executed Vim on a file and been able to scrollwheel down, but the scroll wheel up takes me to the xterm buffer. if I quit, and then execute in that same xterm a "gnu screen" session, and execute Vim in that, mouse support sometimes does not work at all. I checked that the mouse=a was set in the screen and I have been able to use mouse support in the screen some of the time.


Mess around with "set ttymouse" in Vim. It might fix something.

Also, try setting the following in ~/.screenrc

termcapinfo linux|xterm|screen* ti@:te@:XT

While trying this tip, I found that

set wim=longest:full,full 

is more of what I was looking for. On the first tab it will act as longest:full, showing the wildmenu but only populating the longest string found. The second tab will populate the first full match, which happens to be the first in the wildmenu. You are also free at this point to use the wildmenu to select what options you want. If you still want to see a list of candidates with the old stile, you can press <c-d>.


The wildmenu does not appear to show the right-aligned text that is sometimes next to menu items in gvim. (For example, gvim shows the command ":w" to the right of File.Save)

The following mapping will show additional info for the current menu item when the F1 key is pressed.

cnoremap <expr> <F1> wildmenumode() ? "\<Home>" . repeat("\<Delete>", match(getcmdline(),'menu')) . "\<CR>" : ""

(Basically converting the command "emenu File.Save" to just "menu File.Save")

Advertisement