After getting the current word with expand("<cWORD>") and processing the result string, I’m trying to replace the current word with it.
How can I do this?
EDIT Source added. I wrote it in python.
cur_word = vim.eval('expand("<cWORD>")')
parts = cur_word.split('.')
if parts:
obj, accesses = parts[0], parts[1:]
result = obj + ''.join("['%s']"%a for a in accesses)
# how do I replace the current word with result?
In the python interface for Vim, you can execute normal mode command, in your case,
will do the trick.