Nicolás Brailovsky


A modern blog

vimrc: Vim startup file

author Posted by: nico on date Jun 11th, 2009 | filed Filed under: Linux, Programming, Vim
vim_editor I usually create a partition for /home, so whenever I decide to foobar my OS (i.e. do a kernel update on Ubuntu, or start playing with compiz too much) there’s no need to copy my home folder to another disk and back again. Regardless of this, there are some essential files which I’d be dead without. One of these is my .vimrc, the startup file for Vim.

My .vimrc file has been organically growing since I started using this editor, a couple of years ago, so I’ve decided to clean it up a little bit and post it here, just to be sure I won’t be loosing it. It’s got some tweaks to use Vim as an IDE, feel free to download it and change it or use it anyway you want.

  1. colorscheme torte
  2. set nocompatible
  3. syntax on
  4. set ruler
  5. set number
  6. set hls                 " Highlight search results
  7. set showmatch   " Show matching () {} []
  8. set wildmode=list:longest,full  " Use tab-completition
  9. set mouse=a                     " Always use the mouse
  10.  
  11. " Set the working directory to the directory of the current file.
  12. autocmd BufEnter * lcd %:p:h
  13.  
  14. " Allow movement to another buffer without saving the current one
  15. set hidden
  16.  
  17. " *********** Text formatting *************
  18. set nowrap
  19. set beautify
  20. set shiftwidth=3
  21. set tabstop=3
  22.  
  23. filetype on
  24. filetype plugin indent on
  25.  
  26. " *********** Search & replace *************
  27. set ignorecase  " case insensitive
  28. set smartcase   " case insensitive only if there is no uppercase
  29. set incsearch   " incremental seach
  30. set gdefault    " default to /g on replace
  31.  
  32. " Load matchit (% to bounce from do to end, etc.)
  33. runtime! macros/matchit.vim
  34.  
  35. augroup myfiletypes
  36.         " Clear old autocmds in group
  37.         autocmd!
  38.         " autoindent with two spaces, always expand tabs
  39.         autocmd FileType ruby,eruby,yaml set ai sw=2 sts=2 et
  40. augroup END
  41.  
  42. " display the current mode and partially-typed commands in the status line:
  43. set showmode
  44. set showcmd
  45.  
  46. set autoindent
  47. set smartindent
  48. " Show an error window (if there are errors)
  49. cwindow
  50.  
  51. " *********** Mappings *************
  52. " Ctrl-t: Write tabnew (wait for filename and )
  53. map  :tabnew
  54. " Alt-R: Exec current file as script
  55. map  :!.%
  56. " Ctrl-Alt-R
  57. map  :tabnew:make
  58. " Spellcheck
  59. map  :!ispell -x %:e!
  60. " Comment a line
  61. map  0i//
  62. map  0xxx
  63.  
  64. " Build for a LaTeX file (assumes correct path and makefile)
  65. autocmd filetype tex map  :w:make
  66.  
  67. " Automatic closing brackets
  68. inoremap do{ do{}while();O
  69. inoremap do{ do{}while();O
  70. inoremap { {}O
  71. <a href="http://nicolasb.com.ar/archivos/2009/05/.vimrc">Link to my .vimrc file</a>


     Add A Comment

trackback Trackback URI | rsscomment Comments RSS