-
-
Save note103/2f8c8902eae0c7b385aaa866c5b75dbd to your computer and use it in GitHub Desktop.
This file contains 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! 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