gvim snippets

Recording a macro in vim

Tagged vim, gvim, macro  Languages bash

Vim is a powerful text editor. All powerful text editors support some kind of macro's. Here's how vim does it.

qa - start recording a macro into register 'a'
q - stop recording

Running the macro.

@a - run the macro in register 'a'
@@ - repeat the last macro that was run
[email protected] - run the macro in register 'a' ten times

How to make GVim look and behave better on Windows

Tagged gvim, _vimrc, windows, vim  Languages 

I use this configuration with GVim (sometimes I'm forced to use Windows). It makes the GVim behave and look better.

" Start maximized
au GUIEnter * simalt ~x

" Use CUA keystrokes for clipboard: CTRL-X, CTRL-C, CTRL-V and CTRL-z
source $VIMRUNTIME/mswin.vim

syntax on
set nocompatible
filetype on
filetype indent on
filetype plugin on

" General options
set incsearch
set ignorecase smartcase 

" Use two space tabs
set tabstop=2
set shiftwidth=2
set expandtab

" No menus and no toolbar
"set guioptions-=m  
set guioptions-=T

set guifont=Consolas:h11:cANSI

highlight Normal guifg=White   guibg=Black
highlight Cursor guifg=Black   guibg=White
highlight Keyword guifg=#FF6600
highlight Define guifg=#FF6600
highlight Comment guifg=#9933CC
highlight Type guifg=White gui=NONE
highlight rubySymbol guifg=#339999 gui=NONE
highlight Identifier guifg=White gui=NONE
highlight rubyStringDelimiter guifg=#66BB00
highlight rubyInterpolation guifg=White
highlight rubyPseudoVariable guifg=#339999
highlight Constant guifg=#FFEE98
highlight Function guifg=#FFCC00 gui=NONE
highlight Include guifg=#FFCC00 gui=NONE
highlight Statement guifg=#FF6600 gui=NONE
highlight String guifg=#66BB00
highlight Search guibg=White

function RubyEndToken ()
  let current_line = getline( '.' )
  let braces_at_end = '{\s*\(|\(,\|\s\|\w\)*|\s*\)\?$'
  let stuff_without_do = '^\s*\(class\|if\|unless\|begin\|case\|for\|module\|while\|until\|def\)'
  let with_do = 'do\s*\(|\(,\|\s\|\w\)*|\s*\)\?$'

  if match(current_line, braces_at_end) >= 0
    return "\<CR>}\<C-O>O" 
  elseif match(current_line, stuff_without_do) >= 0
    return "\<CR>end\<C-O>O" 
  elseif match(current_line, with_do) >= 0
    return "\<CR>end\<C-O>O" 
    return "\<CR>" 

function UseRubyIndent ()
  setlocal tabstop=8
  setlocal softtabstop=2
  setlocal shiftwidth=2
  setlocal expandtab

  imap <buffer> <CR> <C-R>=RubyEndToken()<CR>

autocmd FileType ruby,eruby call UseRubyIndent()

GVim _vimrc file

Tagged windows, gvim  Languages 
set history=100

let mapleader = ","
set tabstop=2
set smarttab
set shiftwidth=2
set autoindent
set expandtab
set backspace=start,indent

autocmd FileType make     set noexpandtab
autocmd FileType python   set noexpandtab

set number
set hlsearch
syntax on

let g:fuzzy_trim_length = 3000
let g:fuzzy_ignore = "*.log"
let g:fuzzy_matching_limit = 70

map ,t :FuzzyFinderTextMate<CR>
map ,b :FuzzyFinderBuffer<CR>

map ,d :execute 'NERDTreeToggle ' . getcwd()<CR>

set guifont=Bitstream\ Vera\ Sans\ Mono:h9

au GUIEnter * simalt ~x

colorscheme railscasts
" set guifont=consolas:h8