Skip to content

Instantly share code, notes, and snippets.

@Raimondi
Created September 19, 2010 18:31
Show Gist options
  • Save Raimondi/586998 to your computer and use it in GitHub Desktop.
Save Raimondi/586998 to your computer and use it in GitHub Desktop.
function! ReplaceCurrentChar(match, replace)
let save_cursor = getpos('.')
let col = col('.')
exec 's/\%'.col.'v./\=getline(".")[col-1] ==# "'.a:match.'" ? "'.a:replace.'" : submatch(0) /'
call setpos('.', save_cursor)
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment