Skip to content

Commit

Permalink
Escape single quotes from text selection
Browse files Browse the repository at this point in the history
  • Loading branch information
zubieta committed Jun 22, 2017
1 parent 5add3e4 commit 21c16d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion contrib/vim-slackcat/plugin/vim-slackcat.vim
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ function! SendToSlack()
let s_lang = input("lang? ", &filetype)
call inputrestore()
echo "\rSending to Slack ..."
let s_selection = s:getVisualSelection()
let s_selection = s:escapeTildes(s:getVisualSelection())
if empty(s_lang)
let s_lang = 'txt'
endif
let return = system("echo '". s_selection ."' |slackcat -c " . s_channel . " --filetype " . s_lang)
echo "\rSent !"
endfunction

function! s:escapeTildes(text)
return substitute(a:text, "'", "'\"'\"'", 'g')
endfunction

function! s:getVisualSelection()
" Why is this not a built-in Vim script function?!
let [lnum1, col1] = getpos("'<")[1:2]
Expand Down

0 comments on commit 21c16d5

Please sign in to comment.