Created
June 2, 2021 00:55
-
-
Save tjdevries/9068778bc4997231efcfb81bd5dde53f to your computer and use it in GitHub Desktop.
Yo
This file contains hidden or 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:PerlSubstitute(line1, line2, sstring) | |
let l:lines = getline(a:line1, a:line2) | |
" Perl command with 'utf8' enabled | |
" '#line 1' makes error messages prettier, displayed below: | |
" Substitution replacement not terminated at PerlSubstitute line 1. | |
let l:sysresult = systemlist("perl -e 'use utf8;' -e '#line 1 \"PerlSubstitute\"' -pe ". shellescape("s".escape(a:sstring,"%!").";"), l:lines) | |
if v:shell_error | |
echo l:sysresult | |
return | |
endif | |
call nvim_buf_set_lines(0, a:line1 - 1, a:line2, v:false, l:sysresult) | |
endfunction | |
command! -range -nargs=1 S call s:PerlSubstitute(<line1>, <line2>, <q-args>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment