Created
October 29, 2011 03:15
-
-
Save typpo/1324034 to your computer and use it in GitHub Desktop.
.vimrc
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
set nocompatible | |
colorscheme wombat | |
set cul | |
syntax on | |
filetype plugin indent on | |
au BufNewFile,BufRead *.djs set filetype=javascript | |
set smartindent | |
set smarttab | |
set nu | |
set ic | |
set ts=2 | |
set sw=2 | |
set softtabstop=2 | |
set expandtab | |
set background=dark | |
" | |
" Attempting to set title string of window | |
autocmd BufEnter * let &titlestring = hostname() . "[vim(" . expand("%:t") . ")]" | |
" Search highlighting - highlight in light blue, unlighting on press space | |
set hlsearch | |
:nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR> | |
:hi Search ctermbg=LightBlue | |
" Automatically cd into the directory that the file is in | |
autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ') | |
" Remove any trailing whitespace that is in the file | |
autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif | |
" Restore cursor position to where it was before | |
augroup JumpCursorOnEdit | |
au! | |
autocmd BufReadPost * | |
\ if expand("<afile>:p:h") !=? $TEMP | | |
\ if line("'\"") > 1 && line("'\"") <= line("$") | | |
\ let JumpCursorOnEdit_foo = line("'\"") | | |
\ let b:doopenfold = 1 | | |
\ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) | | |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 | | |
\ let b:doopenfold = 2 | | |
\ endif | | |
\ exe JumpCursorOnEdit_foo | | |
\ endif | | |
\ endif | |
" Need to postpone using "zv" until after reading the modelines. | |
autocmd BufWinEnter * | |
\ if exists("b:doopenfold") | | |
\ exe "normal zv" | | |
\ if(b:doopenfold > 1) | | |
\ exe "+".1 | | |
\ endif | | |
\ unlet b:doopenfold | | |
\ endif | |
augroup END | |
" shows what you are typing as a command | |
"set showcmd | |
" Enable mouse support in console | |
"set mouse=a | |
" remap jj to escape in insert mode | |
inoremap jj <Esc> | |
nnoremap JJJJ <Nop> | |
" When I close a tab, remove the buffer | |
"set nohidden | |
" Create Blank Newlines and stay in Normal mode | |
nnoremap <silent> zj o<Esc> | |
nnoremap <silent> zk O<Esc> | |
" Blank out line and stay in Normal mode | |
nnoremap <silent> zc ^<S-C><Esc> | |
" Makes tab autocomplete figure out whether you want to place a word or actual tab there | |
function! Mosh_Tab_Or_Complete() | |
if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w' | |
return "\<C-N>" | |
else | |
return "\<Tab>" | |
endfunction | |
inoremap <Tab> <C-R>=Mosh_Tab_Or_Complete()<CR> | |
" Easier buffer switching | |
map <C-j> :bprev<CR> | |
map <C-k> :bnext<CR> | |
set hidden " allow hide buffers with no write | |
" bash like tab completion | |
set wildmenu | |
set wildmode=list:longest | |
" use ctrl-h/j/k/l to switch between splits | |
"map <c-j> <c-w>j | |
"map <c-k> <c-w>k | |
"map <c-l> <c-w>l | |
"map <c-h> <c-w>h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment