Advertisement
Guest User

Jeffrey's vimrc file

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