Skip to content

Instantly share code, notes, and snippets.

@heavenshell
Created February 18, 2013 10:35
Show Gist options
  • Save heavenshell/4976504 to your computer and use it in GitHub Desktop.
Save heavenshell/4976504 to your computer and use it in GitHub Desktop.
Decode unicode escape string to utf-8
let s:save_cpo = &cpo
set cpo&vim
python << PYTHONEOF
import vim
def unicode_escape():
start = vim.eval('start')
end = vim.eval('end')
line = vim.eval('val')
string = line[int(start) - 1:int(end)]
print string.decode('unicode_escape').encode('utf-8')
PYTHONEOF
function! UnicodeEscapeDecode() range
let start = col("'<")
let end = col("'>")
let val = getline('.')
python unicode_escape()
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment