Skip to content

Instantly share code, notes, and snippets.

@vjsingh
Created August 23, 2012 21:10
Show Gist options
  • Save vjsingh/3441798 to your computer and use it in GitHub Desktop.
Save vjsingh/3441798 to your computer and use it in GitHub Desktop.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MULTIPURPOSE TAB KEY
" Indent if we're at the beginning of a line. Else, do completion.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n>
" Map ; to :
nnoremap ; :
" case insensitive unless at least one capital letter, then case sensitive
set ignorecase
set smartcase
" w!! to write with sudo
cnoreabbrev <expr> w!!
\((getcmdtype() == ':' && getcmdline() == 'w!!')
\?('!sudo tee % >/dev/null'):('w!!'))
" Have Vim jump to the last position when reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif
Rename a file with :Rename(!) - http://www.vim.org/scripts/script.php?script_id=1928
" \vs splits window in 2 and sets scroll bind so you can see 2 pages (or more) of a file
:noremap <silent> <Leader>vs :<C-u>let @z=&so<CR>:set so=0 noscb<CR>:bo vs<CR>Ljzt:setl scb<CR><C-w>p:setl scb<CR>:let &so=@z<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment