matze / vim-move

Plugin to move lines and selections up and down
http://www.vim.org/scripts/script.php?script_id=4687
MIT License
1.2k stars 56 forks source link

How to restore the position in the line after moving? #33

Closed c02y closed 5 years ago

c02y commented 5 years ago

Currently when you are in the middle of the line, and using vim-move to move the current line, then the point of the cursor will be placed at the beginning of the line.

This is annoying when the word of the point before moving is important, and when I have multiple such lines(not in a block) to move, then I have to keep moving back to the middle of the line(the old point) manually.

Is it possible to make the point untouched when moving line(s) or restore the point in the line after moving line(s)?

matze commented 5 years ago

Unfortunately, the builtin command that the plugin wraps automatically moves the cursor. I suppose it's possible to reset the cursor but I'll better wait for a PR.

c02y commented 5 years ago

Actually, you can save the column into a variable using col(".") before moving, and jump to the col using the saved variable after moving.