This is a pretty old question ... but for those still trying to find a way to do this:
You can count the number of characters \ n to the current range .location and set the new range.location to \ n before the cursor moves up the line or \ n after the cursor moves down.
If you want to move it up or down and save it according to the characters in the line, you will need to count the number of characters in each line and move them to the right place.
source share