views:

266

answers:

1

I have never used a mouse click to get a hovering menu in Vim. The following manual suggests such a menu exists.

Here are a few vimrc lines that can help. Put them in your vimrc - -, then you can beautify at least single lines using one mouse click.

nmenu Misc.Beautify.For :s/for\s*(\s*/for ( /<CR>:s/\s*)\s*$/ )/<CR>:s/\(\i\+\)\s*=\s*/\1 = /<CR>:s/\s*\([=<>!]=\\|[<>]\)\s*/ \1 /<CR>:s/\s*\(--\\|++\)/\1/<CR>:s/\s*;\s*/; /g<CR>
nmenu Misc.Beautify.Func :s/\s*)/ )/g<CR>:s/\s*\([(,]\)\s*/\1 /g<CR>:s/(\s\+)/()/g<CR>
nmenu Misc.Beautify.If :s/if\s*(\s*/if ( /<CR>:s/\s*)\s*$/ )/<CR>:silent s/\s*\([=<>!]=\\|[<>]\)\s*/ \1 /<CR>
nmenu Misc.Beautify.Assign :s/\s*\([-+*\/&\|]\?\)\s*=\s*/ \1= /g<CR>

I found onlythe following lines about nmenu in Vim docs. They are not really useful.

   :nmenu Words.Add\ Var         wb"zye:menu! Words.<C-R>z <C-R>z<CR>
   :nmenu Words.Remove\ Var      wb"zye:unmenu! Words.<C-R>z<CR>

It seems that my Vim 7.2 does not have such a hovering menu. The manual suggests to remove the nmenu to get a code-beautifier for many lines. This suggests me that I have misunderstood the action button for the beautifier. It is not apparently only a mouse click.

How can you use the code beautifier in Vim?

+2  A: 
ephemient
*Is there any way to get the functionality to Vim?* --- I am not sure whether key mappings are possible here or not.
Masi
Use `:map` http://www.vim.org/htmldoc/map.html#:map to set up key mappings
ephemient
I run the following mapping unsuccessfully `map <C-w>1 Misc...` It pastes the actual sed-codes to my editing codes. The problem seems to be that the insertion of code to `:` -mode. **How can you paste the code to `:` -mode such that the formatting happens?**
Masi
Which `:map` command are you using? If it starts in insert mode, you will of course need to exit to normal mode before commands can work; `<C-\><C-N>` will go to normal mode (without causing a beep like `<Esc>` does if you're already in normal mode).
ephemient