Register now and start sharing your code snippets.
How to make GVim look and behave better on Windows
Plain Text posted 7 months ago by christian
I use this configuration with GVim (sometimes I’m forced to use Windows). It makes the GVim behave and look better.
1 " Start maximized 2 au GUIEnter * simalt ~x 3 4 " Use CUA keystrokes for clipboard: CTRL-X, CTRL-C, CTRL-V and CTRL-z 5 source $VIMRUNTIME/mswin.vim 6 7 syntax on 8 set nocompatible 9 filetype on 10 filetype indent on 11 filetype plugin on 12 13 " General options 14 set incsearch 15 set ignorecase smartcase 16 17 " Use two space tabs 18 set tabstop=2 19 set shiftwidth=2 20 set expandtab 21 22 " No menus and no toolbar 23 "set guioptions-=m 24 set guioptions-=T 25 26 set guifont=Consolas:h11:cANSI 27 28 highlight Normal guifg=White guibg=Black 29 highlight Cursor guifg=Black guibg=White 30 highlight Keyword guifg=#FF6600 31 highlight Define guifg=#FF6600 32 highlight Comment guifg=#9933CC 33 highlight Type guifg=White gui=NONE 34 highlight rubySymbol guifg=#339999 gui=NONE 35 highlight Identifier guifg=White gui=NONE 36 highlight rubyStringDelimiter guifg=#66BB00 37 highlight rubyInterpolation guifg=White 38 highlight rubyPseudoVariable guifg=#339999 39 highlight Constant guifg=#FFEE98 40 highlight Function guifg=#FFCC00 gui=NONE 41 highlight Include guifg=#FFCC00 gui=NONE 42 highlight Statement guifg=#FF6600 gui=NONE 43 highlight String guifg=#66BB00 44 highlight Search guibg=White 45 46 function RubyEndToken () 47 let current_line = getline( '.' ) 48 let braces_at_end = '{\s*\(|\(,\|\s\|\w\)*|\s*\)\?$' 49 let stuff_without_do = '^\s*\(class\|if\|unless\|begin\|case\|for\|module\|while\|until\|def\)' 50 let with_do = 'do\s*\(|\(,\|\s\|\w\)*|\s*\)\?$' 51 52 if match(current_line, braces_at_end) >= 0 53 return "\<CR>}\<C-O>O" 54 elseif match(current_line, stuff_without_do) >= 0 55 return "\<CR>end\<C-O>O" 56 elseif match(current_line, with_do) >= 0 57 return "\<CR>end\<C-O>O" 58 else 59 return "\<CR>" 60 endif 61 endfunction 62 63 function UseRubyIndent () 64 setlocal tabstop=8 65 setlocal softtabstop=2 66 setlocal shiftwidth=2 67 setlocal expandtab 68 69 imap <buffer> <CR> <C-R>=RubyEndToken()<CR> 70 endfunction 71 72 autocmd FileType ruby,eruby call UseRubyIndent()
Recording a macro in vim
Shell Script (Bash) posted about 1 year ago by marko
Vim is a powerful text editor. All powerful text editors support some kind of macro’s. Here’s how vim does it.
1 qa - start recording a macro into register 'a' 2 q - stop recording
Running the macro.
1 @a - run the macro in register 'a' 2 @@ - repeat the last macro that was run 3 10@a - run the macro in register 'a' ten times