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
function! MapMeta(cmd, lhs, rhs) | |
if has('gui_running') | |
exec a:cmd.' <M-'.substitute(a:lhs, '[<>]', '', 'g').'> '.a:rhs | |
else | |
exec a:cmd.' <Esc>'.a:lhs.' '.a:rhs | |
endif | |
endfunction | |
call MapMeta('map', '<Left>', 't') |
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
" Will write text including first match until before the second match: | |
" :WriteMatchedText first second /path/to/file.ext | |
function! WriteMatchedText(first, second, file) | |
exec "normal /".a:first."\<CR>" | |
normal v | |
exec "normal /".a:second."\<CR>h" | |
normal y | |
call writefile(split(@", "\n"), expand(a:file)) | |
endfunction |
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
" From jamessan#[email protected] | |
" Folding for unified diffs | |
function! DiffFoldLevel(lineno) | |
let line = getline(a:lineno) | |
if line =~ '^Index:' | |
return '>1' | |
elseif line =~ '^===' || line =~ '^RCS file: ' || line =~ '^retrieving revision ' | |
let lvl = foldlevel(a:lineno - 1) | |
return lvl >= 0 ? lvl : '=' |
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
" http://vim.pastey.net/142521 | |
" Author: bairui | |
function! Incrementor(start, step) | |
let incrementor = {} | |
let incrementor.initial_value = a:start - 1 | |
let incrementor.value = incrementor.initial_value | |
let incrementor.step = a:step | |
function incrementor.inc() dict | |
let self.value += self.step | |
return self.value |
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
if true | |
x | |
end |
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
# If a command takes more than $CUR_CMD_TIMEOUT seconds to finish, | |
# then let me know when it has finished. | |
# Code to get command name from http://aperiodic.net/phil/prompt/ | |
CUR_CMD_TIMEOUT=1 | |
precmd () { | |
CUR_CMD_END=`date +%s` | |
if [[ -n "$CUR_CMD_START" ]] { | |
let "CUR_CMD_ELAPSED = $CUR_CMD_END - $CUR_CMD_START" |
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
" Always edit a file on gf, but be nice and ask | |
map gf :<C-U>call GoFile()<CR> | |
function! GoFile() | |
try | |
normal! gf | |
catch /^Vim\%((\a\+)\)\=:E447/ | |
let q = substitute(v:exception,'^Vim\%((\a\+)\)\=:E\d\+: \(.*\)','\1','') . ', would you like to create it?' | |
try | |
buffer <cfile> |
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
" From jamessan@#vim | |
" http://vim.pastey.net/148644 | |
let i = 1 | |
while synIDtrans(i) != 0 | |
if synIDattr(i, 'name') == 'Normal' | |
if synIDattr(i, 'fg') >= 0 | |
" fg is set | |
endif | |
if synIDattr(i, 'bg') >= 0 |
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
Monday, December 15, 2008 | |
If programming languages were religions... | |
By amz at 14:52 | |
C would be Judaism - it's old and restrictive, but most of the world | |
is familiar with its laws and respects them. The catch is, you can't | |
convert into it - you're either into it from the start, or you will | |
think that it's insanity. Also, when things go wrong, many people are | |
willing to blame the problems of the world on it. |