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.21k stars 56 forks source link

Read v:count before it is overwritten #43

Closed hugomg closed 4 years ago

hugomg commented 4 years ago

Fixes #42.

The v:count parameter is overwritten whenever we invoke a normal-mode command so we must ensure that we read the value of v:count at the start of our functions, before we call any normal-mode commands.

Another change in this commit is that the computations that use v:count now use it as a multiplier, instead of adding it to the computed distance. The behavior should be the same as before for MoveLineDown(1) but it is different for larger steps such as MoveLineHalfPageDown(). In the previous version, moving half a page twice would only move it half a page + 2 lines.

matze commented 4 years ago

Thanks for further investigating the issue. Could you update the commit message to refer to the correct issue number so the issue will be closed automatically?

hugomg commented 4 years ago

Oops! Looks like I wrote 52 instead of 42 😅. I think it should be working now.

matze commented 4 years ago

Thanks!