Skip to content

Instantly share code, notes, and snippets.

Avatar

bouzuya bouzuya

View GitHub Profile
@bouzuya
bouzuya / gist:1885339
Created Feb 22, 2012
autoload/*.vim <-> plugin/*.vim
View gist:1885339
function! s:open_pair_file()
let path = expand('%:p')
let pairs = [
\ ['/autoload/\([^/]\+\).vim$', '/plugin/\1.vim'],
\ ['/plugin/\([^/]\+\).vim$', '/autoload/\1.vim']
\ ]
for [pat, sub] in pairs
if match(path, pat) != -1
execute 'hide' 'edit' substitute(path, pat, sub, '')
break
View gist:1892513
" http://subtech.g.hatena.ne.jp/motemen/20080504/1209838652
nnoremap <expr> ^ search('^\s*\%#\S', 'bn') ? '0' : '^'
nnoremap <expr> 0 col('.') == 1 ? '^' : '0'
@bouzuya
bouzuya / sid.vim
Created Feb 27, 2012
vim s:snr() & s:sid() & s:parse_script_names() & s:path_to_snr()
View sid.vim
function! s:snr()
let sfile = expand('<sfile>')
return matchstr(sfile, '<SNR>\zs\d\+\ze_snr$')
endfunction
function! s:sid()
let snr = s:snr()
return printf('<SNR>%s_', snr)
endfunction
@bouzuya
bouzuya / nnoremap-p.vim
Created Feb 28, 2012
nnoremap <expr> p col('.') !=# 1 ? 'p' : 'P'
View nnoremap-p.vim
nnoremap <expr> p col('.') == 1 ? 'P' : 'p'
View config
Host 560
HostName very.long.host.name
User user560
Port 560
IdentityFile ~/.ssh/id_rsa.560
View yank_gist.vim
function! s:yank_gist()
let gist_id = input('gist? ')
execute 'Gist' gist_id
let match = matchlist(bufname('%'), '^gist:\(\d*\)/\(.*\)$')
if empty(match)
echoerr 'no match'
return
endif
let gist_url = printf('https://gist.github.com/%s.js?file=%s', match[1], match[2])
let code = join(getline(1, '$'), "\n")
View gist:3136324
//samba/shared/repos/git /repos cifs user=user,password=password 0 0
View amazon-gp.js
javascript:
(function(){
var id = 'bouzuya-22';
var pattern = /^http:\/\/www\.amazon\.co\.jp(?:.*)\/(?:(?:gp\/product)|(?:dp))\/([0-9A-Za-z]{10}).*$/;
var result = location.href.match(pattern);
if (result == null) {
return;
}
var text = document.createTextNode('A!');
var href = 'http://amazon.jp/o/ASIN/' + result[1] + '/' + id;
View [quickrun output]
javascript:(function(){var f="bouzuya-22";var d=/^http:\/\/www\.amazon\.co\.jp(?:.*)\/(?:(?:gp\/product)|(?:dp))\/([0-9A-Za-z]{10}).*$/;var a=location.href.match(d);if(a==null){return}var e=document.createTextNode("A!");var b="http://amazon.jp/o/ASIN/"+a[1]+"/"+f;var c=document.createElement("a");c.appendChild(e);c.setAttribute("href",b);document.getElementById("btAsinTitle").appendChild(c);return false})();