Skip to content

Instantly share code, notes, and snippets.

@note103
Last active September 13, 2018 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save note103/2f8c8902eae0c7b385aaa866c5b75dbd to your computer and use it in GitHub Desktop.
Save note103/2f8c8902eae0c7b385aaa866c5b75dbd to your computer and use it in GitHub Desktop.
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