Instantly share code, notes, and snippets.

@note103 /.vimrc.vim Secret
Last active Sep 13, 2018

Embed
What would you like to do?
function! s:sbpost(prj) range
let prj = a:prj
let ans = input('Create? @'.prj.' (y/n) [n]: ')
if ans != 'y'
redraw
echo 'Canceled!'
return
endif
let date = strftime('%Y-%m-%d')
let lines = getline(a:firstline, a:lastline)
let msg = join(lines, "\r")
let msg = substitute(msg, '(', '\\(', 'g')
let msg = substitute(msg, ')', '\\)', 'g')
let msg = substitute(msg, '<', '\\<', 'g')
let msg = substitute(msg, '>', '\\>', 'g')
let msg = substitute(msg, '&', '\\&', 'g')
let msg = substitute(msg, ' ', ' ', 'g')
execute ':!ruby ~/scrapbox/sb-post.rb '.prj.' '.msg
endfunction
nnoremap <silent><Leader><Leader>n :<C-u>call <SID>sbpost('note103')<CR>
xnoremap <silent><Leader><Leader>n :<C-u>'<,'>call <SID>sbpost('note103')<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment