Created
September 22, 2010 21:18
-
-
Save kconragan/592595 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Map Leader | |
let mapleader = "," | |
imap jj <Esc> " map jj to escape | |
:map <leader>dd "_dd " Map ',dd' to delete line and put in black-hole register | |
nmap <leader>w :w!<cr> " Shortcut | |
" Fast editing of the .vimrc | |
map <leader>e :e! ~/.vimrc<cr> | |
" When vimrc is edited, reload it | |
autocmd! bufwritepost vimrc source ~/.vimrc | |
" Visuals ******************************************************************** | |
colorscheme lucius " Color scheme | |
set title "Set window title | |
set scrolloff=5 "Number of lines visible above/below cursor | |
set sidescrolloff=2 | |
set ruler "Display current position of cursor | |
set cursorline "Highlight current line | |
set nu "Line Numbers" | |
set numberwidth=4 "Gutter width for line numbers | |
set guifont=DroidSansMonoDotted:h13 | |
set shortmess=atI "Abbreviate status messages | |
set cmdheight=2 "The commandbar height | |
" Miscelaneous Settings ************************************************************** | |
set hidden | |
set showmatch "show matching brackets/parenthesis" | |
nnoremap ' ` | |
nnoremap ` ' | |
set history=1000 "Remember 100 lines of history | |
set undolevels=1000 "Many levels of undo | |
set wildignore=*.pyc | |
set wildmenu "Command-line completion | |
set visualbell "Turn off audible bell | |
set autoread "Automatically read a file changed from outside Vim | |
" Tabs & Line Spacing ********************************************************* | |
set nowrap "Wrap long lines" | |
set autoindent "Indent at the same level of the previous line" | |
set expandtab "Use soft tabs" | |
set shiftwidth=2 "Tab width" | |
set softtabstop=2 "Tab width" | |
" Searching ******************************************************************* | |
set incsearch "find as you type" | |
set ignorecase "case insensitive search" | |
set smartcase "case sensitive search when UC present" | |
set hlsearch "Highlight search terms | |
nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR> " Clear searches with the space key | |
noremap <F4> :set hlsearch! hlsearch?<CR> " Toggle search highlighting (but don't clear) | |
" Invisible characters ********************************************************* | |
set listchars=trail:.,tab:>-,eol:$ | |
set nolist | |
:noremap <Leader>i :set list!<CR> " Toggle invisible chars | |
:nnoremap <silent> <Leader>ii :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR> | |
" Auto-close commonly typed patterns ****************************************** | |
imap ( ()<Left> | |
imap < <><Left> | |
imap { {}<Left> | |
" Insert New Line ************************************************************* | |
map <S-Enter> O<ESC> " awesome, inserts new line without going into insert mode | |
map <Enter> o<ESC> | |
runtime macros/matchit.vim | |
" Intuitive backspacing in insert mode *************************************** | |
set backspace=indent,eol,start | |
" Syntax Highlight *********************************************************** | |
" File-type highlighting and configuration. | |
" Run :filetype (without args) to see what you may have | |
" to turn on yourself, or just set them all to be sure. | |
syntax on | |
filetype on | |
filetype plugin on | |
filetype indent on | |
set listchars=tab:>-,trail:·,eol:$ | |
nmap <silent> <leader>s :set nolist!<CR> | |
au BufRead,BufNewFile *.less setfiletype css | |
au BufRead,BufNewFile *.mjt setfiletype html | |
au BufRead,BufNewFile *.sjs setfiletype javascript | |
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery | |
" Supertab { | |
let g:SuperTabDefaultCompletionType = "context" | |
let g:SuperTabContextDefaultCompletionType = "<c-x><c-o>" | |
" } | |
au FileType html,xhtml,xml so ~/.vim/ftplugin/html_autoclosetag.vim | |
" Omni Completion ************************************************************* | |
autocmd FileType html :set omnifunc=htmlcomplete#CompleteTags | |
autocmd FileType python set omnifunc=pythoncomplete#Complete | |
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS | |
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags | |
autocmd FileType css set omnifunc=csscomplete#CompleteCSS | |
" Sessions ******************************************************************** | |
" Sets what is saved when you save a session | |
set sessionoptions=blank,buffers,curdir,folds,help,resize,tabpages,winsize | |
"Use TAB to complete when typing words, else inserts TABs as usual. | |
"Uses dictionary and source files to find matching words to complete. | |
"See help completion for source, | |
"Note: usual completion is on <C-n> but more trouble to press all the time. | |
"Never type the same word twice and maybe learn a new spellings! | |
"Use the Linux dictionary when spelling is in doubt. | |
"Window users can copy the file to their machine. | |
function! Tab_Or_Complete() | |
if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w' | |
return "\<C-N>" | |
else | |
return "\<Tab>" | |
endif | |
endfunction | |
:inoremap <Tab> <C-R>=Tab_Or_Complete()<CR> | |
" Shortcuts for easily opening/switching between files *********************** | |
" This automatically changes you to current working directory | |
" and provides options for new buffer, split, tabs, etc. | |
" Open in new buffer | |
map <leader>ew :e <C-R>=expand("%:p:h") . "/" <CR> | |
" Open in split pane | |
map <leader>es :sp <C-R>=expand("%:p:h") . "/" <CR> | |
" Open in vertically-split pane | |
map <leader>ev :vsp <C-R>=expand("%:p:h") . "/" <CR> | |
" Open in new tab | |
map <leader>et :tabe <C-R>=expand("%:p:h") . "/" <CR> | |
"Move a line of text using ALT+[jk] or Comamnd+[jk] on mac | |
nmap <M-j> mz:m+<cr>`z | |
nmap <M-k> mz:m-2<cr>`z | |
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z | |
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z | |
nmap <D-j> <M-j> | |
nmap <D-k> <M-k> | |
vmap <D-j> <M-j> | |
vmap <D-k> <M-k> | |
" map Ctrl-A, Ctrl-E, and Ctrl-K in *all* modes. map! makes the mapping work in | |
" insert and commandline modes too. | |
map <C-A> <Home> | |
map <C-E> <End> | |
map! <C-A> <Home> | |
map! <C-E> <End> | |
"Delete trailing white space, useful for Python ;) | |
func! DeleteTrailingWS() | |
exe "normal mz" | |
%s/\s\+$//ge | |
exe "normal `z" | |
endfunc | |
autocmd BufWrite *.py :call DeleteTrailingWS() | |
" Informative status line | |
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [LINE=%04l/%L]\ [COL=%04v]\ [%p%%] | |
set laststatus=2 | |
map <Leader>f :NERDTreeToggle<CR> " Toggle NERDTree |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment