views:

1906

answers:

9

I've used Vim for about 8 years, and I am trying gVim for the first time. What settings do you to be productive? What's in your gvimrc?

Note: gVim only. Vim stuff is quite well taken care of in:

A: 

The cream feature list is quite long. Pick any feature you find useful, especially GUI ones.

Wikipedia provides a short description:

Cream is a configuration of the Vim text editor that consists of a set of scripts which can be run within Vim to make it behave more like an editor now common to most personal computers which conform to the Common User Access standards of interface and operability.

Through pulldown menus, keyboard shortcuts, and extensive editing functions, Cream tries to make Vim more approachable for novice users and adds features for those more experienced. These are provided through Vim's extensibility, without any special customizations to Vim itself.

gimel
+1  A: 

The biggest thing of use is having more of the <alt/metta + letter keys> that actually work. I use <a-h> and <a-l> for tab left and tab right for example. I find it easy to put my thumb on the alt button, so its useful for remapping various slightly hard to reach motions.

David Raznick
A: 

Look here for a cool way to use the tabs. I've used the methods described in both answers, depending on the situation.

kajaco
+5  A: 

Turn on a horizontal scrollbar (displayed at the bottom of the window):

:set guioptions+=b

This is useful when reading fixed-width data files with very long lines, if you turn off word wrapping (set nowrap).

Brian Carper
+8  A: 

The first thing I did in gVim was to get rid of unnecessary UI elements:

if has('gui_running')
    set guioptions-=T   " Get rid of toolbar "
    set guioptions-=m   " Get rid of menu    "
endif

The only value added is of course just more screen real estate.

Johannes Hoff
Agreed. Don't forget to get rid of the scroll bars.set go-=LrWho needs a mouse anyway?
Steve K
Interresting idea. I'm often using the scroll bar to see where I am in a document. I'll try your tip and see if the percentages given in the ruler (or similar) is enough...
Johannes Hoff
+1  A: 
autocmd GUIEnter * simalt ~ x " start maximized

Makes gVim start in maximized mode on Windows. Since gVim doesn't seem to have a "remember last used windows size", so I just opt for the "always maximize windows" startup option.

Svend
Any way to do this on linux?
Paul Biggar
It is possible to make Vim store the window size (variables `columns` and `lines`) and later set them back to the previous value. It just requires a bit of vim-scripting, but not too much.
Denilson Sá
+2  A: 

I've disabled my toolbar:

set guioptions-=T

I still like to keep the menu bar, because sometimes I use the Syntax menu. You can disable it if you prefer:

set guioptions-=m

I've also mapped F12 to toggle word-wrapping, and Shift+F12 to toggle horizontal scrollbar:

function ToggleWrap()
    set wrap!
    echo &wrap ? 'wrap' : 'nowrap'
endfunc

"F12 toggles wrap (Thanks to Alexandre Moreira)
nnoremap <silent> <F12>      :call ToggleWrap()<CR>
vnoremap <silent> <F12> <C-C>:call ToggleWrap()<CR>
inoremap <silent> <F12> <C-O>:call ToggleWrap()<CR>


function ToggleHorizontalScrollbar()
    "set guioptions+=b
    if &go =~# "b"
        set go-=b
    else
        set go+=b
    endif
endfunc

function ToggleHorizontalScrollbar_setKeys()
    "Shift+F12 toggles the horizontal scrollbar
    nnoremap <silent> <S-F12>      :call ToggleHorizontalScrollbar()<CR>
    vnoremap <silent> <S-F12> <C-C>:call ToggleHorizontalScrollbar()<CR>
    inoremap <silent> <S-F12> <C-O>:call ToggleHorizontalScrollbar()<CR>
endfunc

au GUIEnter * call ToggleHorizontalScrollbar_setKeys()
Denilson Sá
A: 

Following keystrokes/commands used specially in "C" files

  • using "%" to match the parenthesis especially a loop or function begin/end.
  • Folding a big block of code by mapping "+" to v%zf ( :map + v%zf), to unfold use "zo" on the folded block
  • Use of '[' or ']' to reach the begin of functions in forward/reverse direction
  • In visual mode select a block and "=" to align the code
subbul
A: 

Actually, I'm always using gVim. Hence I have access to many more key-bindings, see David's response, that I use to expand my code related manipulations.

My gvimrc does not contain much, just a mapping to toggle the size of gVim windows on MS Windows.

The only real impact I see is that I try to provide menus for the plug-ins I'm maintaining. I even have functions that define toggle-able/cycle-able menu items. Which is quite useful to have options in &Project menu like : "[x] compile in background", "new functions go to end-of-file/where-a-pattern-matches/..."

Luc Hermitte