Skip to content

Instantly share code, notes, and snippets.

@varvaruc
Created February 6, 2014 14:37
Show Gist options
  • Save varvaruc/8845374 to your computer and use it in GitHub Desktop.
Save varvaruc/8845374 to your computer and use it in GitHub Desktop.
"this is for ctrl-c / ctrl-p on windows
source $VIMRUNTIME/mswin.vim
"Forget compatibility with Vi. Who cares.
set nocompatible
"for vundle
filetype off
"Write the old file out when switching between files.
set autowrite
"Display current cursor position in lower right corner.
set ruler
"enable syntax
syntax on
"Tab stuff
set softtabstop=4 "go back one tab when hitting backspace(without this is goes back single space)
set tabstop=4 "used by >>, << and tab.
set shiftwidth=4 "number of space characters used when displaying TAB
set expandtab "replace tab by spaces
"Indent stuff
set smartindent
set autoindent
"working backspace
set backspace=indent,eol,start
fixdel
"case insensitive search
set ignorecase
set smartcase
"highlight search
set hlsearch
"incremental search
set incsearch
"better line wrappings
set wrap
set textwidth=79
set formatoptions=qrn1
"disable menus in GUI
set guioptions-=m
set guioptions-=T
"show line numbers
set number
set laststatus=2
set cursorline
set t_Co=256 "xterm 256 colors
set encoding=utf-8
" Key mappings
" Move visual blocks up and down with <C-j> and <C-k>
nnoremap <C-j> :m .+1<CR>==
nnoremap <C-k> :m .-2<CR>==
inoremap <C-j> <Esc>:m .+1<CR>==gi
inoremap <C-k> <Esc>:m .-2<CR>==gi
vnoremap <C-j> :m '>+1<CR>gv=gv
vnoremap <C-k> :m '<-2<CR>gv=gv
"disable arrow keys in normal mode
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
"disable arrow keys in insert mode
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop>
"Redraws screen no highlighting
nnoremap <silent> <C-l> :nohl<CR><C-l>
"Better wrap navigation
nnoremap j gj
nnoremap k gk
nnoremap gj j
nnoremap gk k
"ESC with jj
imap jj <Esc>
"Complete brackets
inoremap { {}<Left>
inoremap {<CR> {<CR>}<Esc>O
inoremap {{ {
inoremap {} {}
"Uppercase type proof
:command! WQ wq
:command! W w
:command! Wq wq
:command! Q q
"Print colon when hitting semicolor
map ; :
"Leader is now a comma
let mapleader = ","
"Leader Commands
nmap <Leader>nt :NERDTree<cr>
nmap <Leader>ntt :NERDTreeToggle<cr>
nmap <Leader>f :CtrlP<cr>
nmap <Leader>ff :CtrlP %:p:h<cr>
nmap <Leader>b :CtrlPBuffer<cr>
vmap <Leader>c "+y<cr>
nmap <Leader>v "+p<cr>
nmap <Leader>s :w<cr>
nmap <Leader>a ggVG<cr>
nmap <Leader>in ggVG=<cr><c-o><cr>
nmap <Leader>x :bd<cr>
nmap <Leader>xx :bd!<cr>
nmap <Leader>q :q<cr>
nmap <Leader>qq :q!<cr>
nmap <Leader>vi :e! $VIM/_vimrc<cr>
nmap <Leader>cd :cd %:p:h<cr>
"Delete all buffers (via Derek Wyatt)
nmap <silent> <Leader>da :exec "1," . bufnr('$') . "bd"<cr>
":grep 'word' %:p:h\*
"results forward
nmap <Leader>rf :cn<CR>zv
" results backwards
nmap <Leader>rb :cp<CR>zv
nmap <tab> <c-w><c-w>
"Bubble single lines (kicks butt)
"http://vimcasts.org/episodes/bubbling-text/
nmap <C-Up> ddkP
nmap <C-Down> ddp
"Bubble multiple lines
vmap <C-Up> xkP`[V`]
vmap <C-Down> xp`[V`]
" Vundle things
" git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
" Vundle; see https://github.com/gmarik/vundle
" To install, run :BundleInstall
" To update, run :BundleInstall!
" To remove, run :BundleClean after removing the line from this file
set rtp+=$VIM/vimfiles/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'tComment'
Bundle 'scrooloose/nerdtree'
Bundle 'Lokaltog/vim-powerline'
Bundle 'mattn/gist-vim'
Bundle 'mattn/webapi-vim'
Bundle 'tpope/vim-surround'
Bundle 'mattn/emmet-vim'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'kien/ctrlp.vim'
Bundle 'nanotech/jellybeans.vim'
Bundle 'flazz/vim-colorschemes'
Bundle "pangloss/vim-javascript"
Bundle 'vim-scripts/indenthtml.vim'
" emmet-vim settings
let g:user_emmet_leader_key = '<Leader>'
let g:user_emmet_expandabbr_key='<Leader>e'
let g:user_emmet_complete_tag=1
let g:user_emmet_next_key='<c-n>'
let g:user_emmet_prev_key='<c-p>'
" Emmet.vim Enable just for html/css
let g:user_emmet_install_global = 0
autocmd FileType html,css EmmetInstall
" In vim 7.4 html, head, body are not indented automatically
let g:html_indent_inctags = "html,body,head,tbody"
"indenthtml.vim settings
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"
filetype plugin indent on
"colorscheme
colorscheme ir_black
" colorscheme twilight
set guifont=Consolas:h12:cANSI
"enable scrolling
set mouse=a
"open current buffer in chrome/firefox
abbrev gc :!chrome %<cr>
abbrev ff :!firefox %<cr>
"insert current time (for temp files).
cmap <F3> <C-R>=strftime("_%d_%m_%Y_%H_%M")<CR>
"hex view ( works on linux )
map <Leader>hx :%!xxd<cr>
map <Leader>hxr :%!xxd -r<cr>
"remove default binding for CtrlP, interacts with emmet-vim ctrl-p
let g:ctrlp_map = ''
"enable folding
set foldmethod=indent
"open files unfolded
set foldlevel=99
"fullscreen in windows
map <F11> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>
"centralized backup
set backup
set backupdir=C:\WINDOWS\Temp
set backupskip=C:\WINDOWS\Temp\*
set directory=C:\WINDOWS\Temp
set writebackup
"Ever notice a slight lag after typing the leader key + command? This lowers
"the timeout.
set timeoutlen=500
"Switch between buffers without saving
set hidden
"Show command in bottom right portion of the screen
set showcmd
"Split windows below the current window.
set splitbelow
"Map a change directory to the desktop
nmap ,d :cd D:\_work<cr>:e.<cr>
"Show hidden files in NerdTree
let NERDTreeShowHidden=1
"Open my work directory
:cd D:\_work
"autopen NERDTree and focus cursor in new document
" autocmd VimEnter * NERDTree
" autocmd VimEnter * wincmd p
" enable vertical ruler
set cursorline cursorcolumn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment