Created
August 11, 2010 14:38
-
-
Save narbs/519068 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
source $VIMRUNTIME/vimrc_example.vim | |
behave xterm | |
set selectmode=mouse | |
set lines=50 | |
set co=80 | |
set vb | |
set ignorecase | |
set lcs=tab:>-,trail:- | |
set nolist | |
set ts=3 | |
set sw=3 | |
" disable backup file creation | |
set nobackup | |
set nowritebackup | |
" turns on omnicompletion ctrl+x, ctrl+o | |
filetype plugin on | |
set ofu=syntaxcomplete#Complete | |
"set guioptions=mr | |
"set guioptions=mrlb | |
"set guioptions=gmrLtT | |
setlocal spell spelllang=en_au | |
set nospell | |
set guifont=DejaVu\ Sans\ Mono:h11 | |
"set guifont=Envy\ Code\ R:h12 | |
" set et | |
set ai | |
:colo darkblue | |
:fu! It() | |
:return setline(line("."), strftime("%a %Y-%m-%d %X ") . getline(line("."))) | |
:endf | |
:map <F12> o<ESC>:call It()<CR>A | |
:imap <F12> <ESC>:call It()<CR>A | |
" Function for use with Sort(), to compare two strings. | |
func! Strcmp(str1, str2) | |
if (a:str1 < a:str2) | |
return -1 | |
elseif (a:str1 > a:str2) | |
return 1 | |
else | |
return 0 | |
endif | |
endfunction | |
" Sort lines. SortR() is called recursively. | |
func! SortR(start, end, cmp) | |
if (a:start >= a:end) | |
return | |
endif | |
let partition = a:start - 1 | |
let middle = partition | |
let partStr = getline((a:start + a:end) / 2) | |
let i = a:start | |
while (i <= a:end) | |
let str = getline(i) | |
exec "let result = " . a:cmp . "(str, partStr)" | |
if (result <= 0) | |
" Need to put it before the partition. Swap lines i and partition. | |
let partition = partition + 1 | |
if (result == 0) | |
let middle = partition | |
endif | |
if (i != partition) | |
let str2 = getline(partition) | |
call setline(i, str2) | |
call setline(partition, str) | |
endif | |
endif | |
let i = i + 1 | |
endwhile | |
" Now we have a pointer to the "middle" element, as far as partitioning | |
" goes, which could be anywhere before the partition. Make sure it is at | |
" the end of the partition. | |
if (middle != partition) | |
let str = getline(middle) | |
let str2 = getline(partition) | |
call setline(middle, str2) | |
call setline(partition, str) | |
endif | |
call SortR(a:start, partition - 1, a:cmp) | |
call SortR(partition + 1, a:end, a:cmp) | |
endfunc | |
" To Sort a range of lines, pass the range to Sort() along with the name of a | |
" function that will compare two lines. | |
func! Sort(cmp) range | |
call SortR(a:firstline, a:lastline, a:cmp) | |
endfunc | |
" :Sort takes a range of lines and sorts them. | |
command! -nargs=0 -range Sort <line1>,<line2>call Sort("Strcmp") | |
set diffexpr=MyDiff() | |
function MyDiff() | |
let opt = '' | |
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif | |
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif | |
silent execute '!C:\Program Files\Vim\vim73e\diff -a ' . opt . v:fname_in . ' ' . v:fname_new . ' > ' . v:fname_out | |
endfunction | |
" vim -b : edit binary using xxd-format! | |
augroup Binary | |
au! | |
au BufReadPre *.bin,*.dmp,*.exe let &bin=1 | |
au BufReadPost *.bin,*.dmp,*.exe if &bin | %!xxd | |
au BufReadPost *.bin,*.dmp,*.exe set ft=xxd | endif | |
au BufWritePre *.bin,*.dmp,*.exe if &bin | %!xxd -r | |
au BufWritePre *.bin,*.dmp,*.exe endif | |
au BufWritePost *.bin,*.dmp,*.exe if &bin | %!xxd | |
au BufWritePost *.bin,*.dmp,*.exe set nomod | endif | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment