Advertisement
Guest User

Jeffrey's vimrc file

a guest
May 2nd, 2012
4,228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 6.88 KB | None | 0 0
  1.    " .vimrc File  
  2.     " Maintained by: Jeffrey Way  
  3.     " jeffrey@jeffrey-way.com  
  4.     " http://net.tutsplus.com  
  5.     "  
  6.      
  7.     "Forget compatibility with Vi. Who cares.  
  8.     set nocompatible  
  9.      
  10.     "Enable filetypes  
  11.     filetype on  
  12.     filetype plugin on  
  13.     filetype indent on  
  14.     syntax on  
  15.      
  16.     "Write the old file out when switching between files.  
  17.     set autowrite  
  18.      
  19.     "Display current cursor position in lower right corner.  
  20.     set ruler  
  21.      
  22.     "Want a different map leader than \  
  23.     "set mapleader = ",";  
  24.      
  25.     "Ever notice a slight lag after typing the leader key + command? This lowers  
  26.     "the timeout.  
  27.     set timeoutlen=500  
  28.      
  29.     "Switch between buffers without saving  
  30.     set hidden  
  31.      
  32.     "Set the color scheme. Change this to your preference.  
  33.     "Here's 100 to choose from: http://www.vim.org/scripts/script.php?script_id=625  
  34.     colorscheme twilight  
  35.      
  36.     "Set font type and size. Depends on the resolution. Larger screens, prefer h20  
  37.     set guifont=Menlo:h14  
  38.      
  39.     "Tab stuff  
  40.     set tabstop=3  
  41.     set shiftwidth=3  
  42.     set softtabstop=3  
  43.     set expandtab  
  44.      
  45.     "Show command in bottom right portion of the screen  
  46.     set showcmd  
  47.      
  48.     "Show lines numbers  
  49.     set number  
  50.      
  51.     "Prefer relative line numbering?  
  52.     "set relativenumber"  
  53.      
  54.     "Indent stuff  
  55.     set smartindent  
  56.     set autoindent  
  57.      
  58.     "Always show the status line  
  59.     set laststatus=2  
  60.      
  61.     "Prefer a slightly higher line height  
  62.     set linespace=3  
  63.      
  64.     "Better line wrapping  
  65.     set wrap  
  66.     set textwidth=79  
  67.     set formatoptions=qrn1  
  68.      
  69.     "Set incremental searching"  
  70.     set incsearch  
  71.      
  72.     "Highlight searching  
  73.     set hlsearch  
  74.      
  75.     " case insensitive search  
  76.     set ignorecase  
  77.     set smartcase  
  78.      
  79.     "Hide MacVim toolbar by default  
  80.     set go-=T  
  81.      
  82.     "Hard-wrap paragraphs of text  
  83.     nnoremap <leader>q gqip  
  84.      
  85.     "Enable code folding  
  86.     set foldenable  
  87.      
  88.     "Hide mouse when typing  
  89.     set mousehide  
  90.      
  91.     "Shortcut to fold tags with leader (usually \) + ft  
  92.     nnoremap <leader>ft Vatzf  
  93.      
  94.     " Create dictionary for custom expansions  
  95.     set dictionary+=/Users/jeff_way/.vim/dict.txt  
  96.      
  97.     "Opens a vertical split and switches over (\v)  
  98.     nnoremap <leader>v <C-w>v<C-w>l  
  99.      
  100.     "Split windows below the current window.  
  101.     set splitbelow                
  102.      
  103.     " session settings  
  104.     set sessionoptions=resize,winpos,winsize,buffers,tabpages,folds,curdir,help  
  105.      
  106.     "Set up an HTML5 template for all new .html files  
  107.     "autocmd BufNewFile * silent! 0r $VIMHOME/templates/%:e.tpl  
  108.      
  109.     "Load the current buffer in Firefox - Mac specific.  
  110.     abbrev ff :! open -a firefox.app %:p<cr>  
  111.      
  112.     "Map a change directory to the desktop - Mac specific  
  113.     nmap <leader>d :cd ~/Desktop<cr>:e.<cr>  
  114.      
  115.     "Shortcut for editing  vimrc file in a new tab  
  116.     nmap <leader>ev :tabedit $MYVIMRC<cr>  
  117.      
  118.     "Change zen coding plugin expansion key to shift + e  
  119.     let g:user_zen_expandabbr_key = '<C-e>'  
  120.      
  121.     "Faster shortcut for commenting. Requires T-Comment plugin  
  122.     map <leader>c <c-_><c-_>  
  123.      
  124.     "Saves time; maps the spacebar to colon  
  125.     nmap <space> :  
  126.      
  127.     "Automatically change current directory to that of the file in the buffer  
  128.     autocmd BufEnter * cd %:p:h  
  129.      
  130.     "Map code completion to , + tab  
  131.     imap <leader><tab> <C-x><C-o>  
  132.      
  133.     " More useful command-line completion  
  134.     set wildmenu  
  135.      
  136.     "Auto-completion menu  
  137.     set wildmode=list:longest  
  138.      
  139.     "http://vim.wikia.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE  
  140.     set completeopt=longest,menuone  
  141.     inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"  
  142.     inoremap <expr> <C-n> pumvisible() ? '<C-n>' :  
  143.       \ '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'  
  144.     inoremap <expr> <M-,> pumvisible() ? '<C-n>' :  
  145.       \ '<C-x><C-o><C-n><C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'  
  146.      
  147.     "Map escape key to jj -- much faster  
  148.     imap jj <esc>  
  149.      
  150.     "Delete all buffers (via Derek Wyatt)  
  151.     nmap <silent> ,da :exec "1," . bufnr('$') . "bd"<cr>  
  152.      
  153.     "Bubble single lines (kicks butt)  
  154.     "http://vimcasts.org/episodes/bubbling-text/  
  155.     nmap <C-Up> ddkP  
  156.     nmap <C-Down> ddp  
  157.      
  158.     "Bubble multiple lines  
  159.     vmap <C-Up> xkP`[V`]  
  160.     vmap <C-Down> xp`[V`]  
  161.      
  162.     " Source the vimrc file after saving it. This way, you don't have to reload Vim to see the changes.  
  163.     if has("autocmd")  
  164.      augroup myvimrchooks  
  165.       au!  
  166.       autocmd bufwritepost .vimrc source ~/.vimrc  
  167.      augroup END  
  168.     endif  
  169.      
  170.     " easier window navigation  
  171.     nmap <C-h> <C-w>h  
  172.     nmap <C-j> <C-w>j  
  173.     nmap <C-k> <C-w>k  
  174.     nmap <C-l> <C-w>l  
  175.      
  176.     "------------------------"  
  177.     "NERDTREE PLUGIN SETTINGS  
  178.     "------------------------"  
  179.     "Shortcut for NERDTreeToggle  
  180.     nmap <leader>nt :NERDTreeToggle <CR>  
  181.      
  182.     "Show hidden files in NerdTree  
  183.     let NERDTreeShowHidden=1  
  184.      
  185.     "autopen NERDTree and focus cursor in new document  
  186.     autocmd VimEnter * NERDTree  
  187.     autocmd VimEnter * wincmd p  
  188.      
  189.     "Helpeful abbreviations  
  190.     iab lorem Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.  
  191.     iab llorem Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.  
  192.      
  193.     "Spelling corrects. Just for example. Add yours below.  
  194.     iab teh the  
  195.     iab Teh The  
  196.      
  197.     " Get to home dir easier  
  198.     " <leader>hm is easier to type than :cd ~  
  199.     nmap <leader>hm :cd ~/ <CR>  
  200.      
  201.     " Alphabetically sort CSS properties in file with :SortCSS  
  202.     :command! SortCSS :g#\({\n\)\@<=#.,/}/sort  
  203.      
  204.     " Shortcut to opening a virtual split to right of current pane  
  205.     " Makes more sense than opening to the left  
  206.     nmap <leader>bv :bel vsp  
  207.      
  208.     " Saves file when Vim window loses focus  
  209.     au FocusLost * :wa  
  210.      
  211.     " Backups  
  212.     set backupdir=~/.vim/tmp/backup// " backups  
  213.     set directory=~/.vim/tmp/swap// " swap files  
  214.     set backup " enable backup  
  215.      
  216.     " No more stretching for navigating files  
  217.     "noremap h ;  
  218.     "noremap j h  
  219.     "noremap k gj  
  220.     "noremap l gk  
  221.     "noremap ; l  
  222.      
  223.     set showmatch " show matching brackets  
  224.      
  225.     " print empty <a> tag  
  226.     map! ;h <a href=""></a><ESC>5hi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement