Hi there,<div><br></div><div>I’m trying to reimplement this handy vim snippet:</div><div><br></div><div><div>vnoremap J :m '&gt;+1&lt;CR&gt;gv=gv</div><div>vnoremap K :m '&lt;-2&lt;CR&gt;gv=gv</div><div><br></div><div>What it does is it moves visually selected lines down with J and up with K, reindenting them as it goes and maintaining the same visual selection so it is easily repeatable w/ J/K</div><div><br></div><div>So far, this is what I have (ignoring the reindent portion for now):</div><div><br></div><div><div>(evil-define-operator my-move-line-down (beg end type)</div><div>&nbsp; "Move selected lines down"</div><div>&nbsp; (evil-move beg end (+ 0 (line-number-at-pos end)))</div><div>&nbsp; (call-interactively evil-visual-restore)</div><div>&nbsp; )</div><div>(define-key evil-visual-state-map (kbd "J") 'my-move-line-down)</div></div><div><br></div><div>It has a few problems:</div><div><br></div><div></div><ol><li>evil-visual-restore doesn’t work like it does in vim, in particular, it is restoring to include the original first line of the selection as well as the text that has moved. In other words, if I select 2 lines, then hit J, 3 will be selected afterwards, the selection expands down instead of moving down.</li><li>I can’t figure out how to get the count such that 3J would move down 3 lines. I’d like to replace the 0 with the count.</li><li>I’m not sure if I’m supposed to use evil-move in this way, it seems to work, but I don’t know if it is abusing a command. Originally I tried to do this by programmatically executing an ex command but apparently that is a no-no.</li></ol><div>Thanks!</div><div id="psignature"><div>Aaron</div></div></div>