Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm setting up virtualized Linux boxes (as local development servers) for developers at a company that is primarily Windows-based, and some of developers make negative cracks about vim (among other things). (It seems to them to represent Linux/Unix in some way, and prove that the environment is obtusely difficult to use.) I remember when I was first forced to use vim, (the sysadmins refused to install emacs!) and the difficult initial learning curve, so I'm somewhat sympathetic. It occured to me that, rather than introduce them to nano (which they would probably never get past) it might be possible to set up nano-like menus in vim to make the transition easier. (I've found a very beginner-friendly .vimrc file to give them, but it doesn't have anything like nano-style menus.)

The only problem is the only thing I've been able to find that claims it's possible to setup menus in vim (not gvim) didn't work, and my attempts to correct the problem just left me with yet another problem to solve. Before I waste lots of time I'd like to know if it is in fact possible, since there seems to be very little information about how to do it.

share|improve this question
    
Emacs + viper… No, I got nuthin. –  Gilles Jul 19 '12 at 23:48
add comment

2 Answers

up vote 4 down vote accepted

Yes, it is possible. You can load menu.vim (the default gvim menu definitions), or you can just start from scratch and create your own, then access them through :emenu. This doesn't give you nano-like always-visible menus, though; it gives you the ability to navigate menus using command-line tab completion.

If the user doesn't have a vimrc, you'll want to start by disabling vi compatibility:

:set nocompatible

Enable smart command line completion on <Tab> (enable listing all possible choices, and navigating the results with <Up>, <Down>, <Left>, <Right>, and <Enter>):

:set wildmenu

Make repeated presses cycle between all matching choices:

:set wildmode=full

Load the default menus (this would happen automatically in gvim, but not in terminal vim):

:source $VIMRUNTIME/menu.vim

After those four commands, you can manually trigger menu completion by invoking tab completion on the :emenu command, by doing :emenu<space><tab>

You can navigate the results using the tab key and the arrow keys, and the enter key (it both expands submenus and selects items). You can then make that more convenient by going a step further, and binding a mapping to pop up the menu without having to type :emenu every time:

Make Ctrl-Z in a mapping act like pressing <Tab> interactively on the command line:

:set wildcharm=<C-Z>

And make a binding that automatically invokes :emenu completion for you:

:map <F4> :emenu <C-Z>
share|improve this answer
    
Brilliant! Let me know how I can buy you a beer! –  iconoclast Dec 7 '12 at 21:38
add comment

As far as i know there is no way to have menues with vim (in the terminal).

Depending on the role of your server you may consider talking to the admins and demand the installation of additional editors like nano, emacs, mcedit…. If this is not a production environment and should be used by developers interactively there is no good reason to deny the installation of the additional editors.

On the other hand the developers may still continue using their existing work environment under windows and just check-in their files into the version repository. Another possible solution is to use either sshfs or cifs share and just edit the files on the windows system. These solutions should be preferred as they probably won't impact the performance of the developer as they still can use their existing development environment.

share|improve this answer
    
Another possiblity akin to the sshfs way is "back-channel vi". –  sr_ Jul 20 '12 at 8:05
    
bcvi looks very interesting, but can you use it with Windows or OS X? –  iconoclast Jul 20 '12 at 21:56
    
looking at some of the plugins that get installed with Janus, it's clearly possible to control the –  iconoclast Jul 25 '12 at 1:32
    
@iconoclast a menu in vim means the menubar, e.g: i.imgur.com/lX5fQ.png and i never saw something like this in the terminal and vim. I am sorry if this is not what you meant –  Ulrich Dangel Jul 25 '12 at 1:40
    
@UlrichDangel: I'm not sure how that last comment got submitted... I stopped composing it because I was unsure how to word it. Anyway, some plugins draw things on the vim screen: that's roughly what I was starting to say. But I see what you mean: everyone answering the question means something differently by "menu" than I do. (I virtually never use gvim, only vim, so I didn't even think about the fact that the gvim mouse menus would be configurable from .vimrc.) –  iconoclast Jul 25 '12 at 20:03
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.