kgroll

.vimrc

Nov 18th, 2011
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 7.29 KB | None | 0 0
  1. " .vimrc
  2. " Author: Karl Groll <[email protected]>
  3. "
  4. " Mostly stolen from Steve Losh
  5. "  (http://stevelosh.com/blog/2010/09/coming-home-to-vim/)
  6.  
  7. " Preamble --------------------------------------------- Last edit 11/18/11 {{{
  8.  
  9. filetype off
  10. call pathogen#runtime_append_all_bundles()              " Enable 'Pathogen' plugin. (Vim plugin manager)
  11. filetype plugin on                                      " Load plugin if one exists for current filetype
  12. filetype plugin indent on                               " Load indent plugin if one exists for current ft. Disable auto-indenting
  13. set nocompatible                                        " Don't use Vi compatibility
  14.  
  15. " }}}
  16. " Basic Options ---------------------------------------- Last edit 11/18/11 {{{
  17. set encoding=utf-8                                      " Set encoding inside vim to 32bit UTF-8 encoded Unicode
  18. set modelines=0                                         " Prevent (some) modelines security exploits
  19. set autoindent                                          " Copy indent from current line when CR or o/O commands used
  20. set copyindent                                          " Autoindent copies indent format of previous line
  21. set nosmartindent                                       " Explicity don't try to guess how I want my indents
  22. set showmode                                            " Put a message on last line showing edit mode
  23. set showcmd                                             " Show partial commands
  24. set cursorline                                          " Highlight current row
  25. set ttyfast                                             " Improves smoothness w/ multiple windows
  26. set ruler                                               " Show ruler at bottom
  27. set backspace=indent,eol,start                          " Nothing can stop the backspace !
  28. set number                                              " Turn on line numbers
  29. set laststatus=2                                        " Always show status bar (w/ filename)
  30. set history=1000                                        " Remember 1000 lines of command line history
  31. set undoreload=10000                                    " Save whole buffer for undo when reloading it
  32. set undofile                                            " Specify new location for vim7.3 persistent undo file
  33. set undodir=~/.vim/.undo                                " Put undo history into ~/.vim/undo
  34. set backup                                              " turn backups on
  35. set backupdir=~/.vim/.backup                            " Where to keep backup files
  36. set directory=~/.vim/.tmp                               " Where to keep swap files
  37. set list listchars=tab:>-,trail:~,extends:>,precedes:<  " Show tabs as >- and trailing space as ~
  38. set lazyredraw                                          " Don't redraw screen when executing macros/untyped cmds
  39. set splitbelow splitright                               " Use sane window splitting. To right and below
  40. set autoread                                            " Automatically read file when changed outside vim
  41. set title                                               " Title of window set to value of 'titlestring'
  42. set mouse=a                                             " Use mouse everywhere
  43. set noerrorbells                                        " Don't make noise
  44. set clipboard+=unnamed                                  " Put contents of unnamed register in system clipboard
  45. set foldmethod=syntax                                   " Syntax highlighting items specify folds
  46.  
  47. " }}}
  48. " Wildmenu Completion ---------------------------------- Last edit 11/18/11 {{{
  49. set wildmenu                                            " Enhanced cmd line completion. show possible autocomplete matches
  50. set wildmode=full                                       " Complete first full match, next match, etc.
  51. set wildignore+=*.git                                   " Don't show version control in autocomplete
  52. set wildignore+=*.jpg,*.jpeg,*.png,*.gif                " Don't show image binaries
  53.  
  54. " }}}
  55. " Tabs, spacing, wrapping ------------------------------ Last edit 11/18/11 {{{
  56. set tabstop=2                                           " Tabs count for 2 spaces
  57. set shiftwidth=2                                        " Use 2 spaces for each step of autoindent
  58. set softtabstop=2                                       " Tabs count for 2 spaces in edit mode
  59. set expandtab                                           " Expand tabs to spaces
  60. set nowrap                                              " Word wrapping off
  61. set textwidth=80                                        " Break line after 80 characters (on whitespace only)
  62.  
  63. " }}}
  64. " Colorscheme ------------------------------------------ Last edit 11/18/11 {{{
  65. syntax on                                               " Syntax highlighting on
  66. set background=dark                                     " Changes highlighting to look better on dark bg
  67. colorscheme desert
  68.  
  69. " }}}
  70. " Search and Movement ---------------------------------- Last edit 11/18/11 {{{
  71. set ignorecase                                          " Ignore case in searches...
  72. set smartcase                                           " ...unless caps explicitly specified
  73. set showmatch                                           " Show matching brackets
  74. set incsearch                                           " Jump to search results as they're typed
  75. set hlsearch                                            " Highlight all search matches
  76. "set gdefault                                            " Make global flag default when searching
  77. set scrolloff=5                                         " Keep 5 lines of context at the top/bottom
  78. set sidescrolloff=5                                     " Keep 5 lines of context at the sides
  79. set virtualedit+=block                                  " Allow cursor to move outside char boundaries (in visual block)
  80.  
  81. " }}}
  82. " Misc settings/mappings ------------------------------- Last edit 11/18/11 {{{
  83.  
  84. " Resize vim windows when terminal window is resized
  85. autocmd VimResized * exe "normal! \<C-W>="
  86.  
  87. " Change leader key to , (instead of \ by default)
  88. let mapleader = ","
  89.  
  90. map <F2> :NERDTreeToggle<cr>
  91.  
  92. " 'jj' exits insert mode
  93. inoremap jj <ESC>
  94. cnoremap jj <ESC>
  95.  
  96. " H jumps to first non whitespace char on line, L to last
  97. noremap H ^
  98. noremap L g_
  99.  
  100. " <leader><space> clears all highlighting
  101. nnoremap <leader><space> :nohlsearch<cr>
  102.  
  103. " Use <leader>w to remove all trailing spaces
  104. "   Searches for any number of spaces (\s\+$) and replaces it with nothing (//)
  105. "   The search term still resides in the '/' buffer, so then we clear it ('')
  106. nnoremap <leader>w :%s/\s\+$//g<cr>:let @/=''<cr>
  107.  
  108. " Use <leader>rt to retab the file with tabstop=8
  109. "   Sets tab width to 8, and then converts all tabs to spaces
  110. nnoremap <leader>rt :set ts=8<cr>:%retab<cr>
  111.  
  112. " Map arrow keys to window resizing
  113. if bufwinnr(1)
  114.   map <Up> <C-W>-
  115.   map <Down> <C-W>+
  116.   map <Left> <C-W><
  117.   map <Right> <C-W>>
  118. endif
  119.  
  120. " Useful for when 'wrap' is set. Instead of moving to the real next line,
  121. "  j (or k) moves down (or up) to the next *row* of text
  122. nnoremap j gj
  123. nnoremap k gk
  124.  
  125. " }}}
  126. " Filetype Specifics ----------------------------------- Last edit 11/18/11 {{{
  127. augroup ft_vim
  128.   autocmd!
  129.   autocmd FileType vim setlocal foldmethod=marker foldmarker={{{,}}}
  130. augroup END
  131. " }}}
Advertisement
Add Comment
Please, Sign In to add comment