ddkP
is actually three low-level commands put together into a single high-level one, performed in normal mode (the mode you are in by default):
dd
cuts the current line,
k
moves the cursor up by one line,
P
puts the line that was cut above the current line.
So, you have done $ git rebase -i
, which opened Vim with something like the following, in normal mode:
pick 07c5abd Introduce OpenPGP and teach basic usage <-- current line
pick de9b1eb Fix PostChecker::Post#urls
pick 3e7ee36 Hey kids, stop all the highlighting
pick fa20af3 git interactive rebase, squash, amend
and you want to move 3e7ee36
up.
This is done by moving the cursor down two times with jj
, making 3e7ee36
the current line:
pick 07c5abd Introduce OpenPGP and teach basic usage
pick de9b1eb Fix PostChecker::Post#urls
pick 3e7ee36 Hey kids, stop all the highlighting <-- current line
pick fa20af3 git interactive rebase, squash, amend
then cutting the line with dd
, making fa20af3
the current line:
pick 07c5abd Introduce OpenPGP and teach basic usage
pick de9b1eb Fix PostChecker::Post#urls
pick fa20af3 git interactive rebase, squash, amend <-- current line
then moving the line up with k
, making de9b1eb
the current line:
pick 07c5abd Introduce OpenPGP and teach basic usage
pick de9b1eb Fix PostChecker::Post#urls <-- current line
pick fa20af3 git interactive rebase, squash, amend
then putting the previously cut line above the current line with P
, effectively switching the two lines and thus moving 3e7ee36
up:
pick 07c5abd Introduce OpenPGP and teach basic usage
pick 3e7ee36 Hey kids, stop all the highlighting <-- current line
pick de9b1eb Fix PostChecker::Post#urls
pick fa20af3 git interactive rebase, squash, amend
And that's about it.
Vim is no different than other professional tools like Photoshop or Blender or what have you. Anyone can start them and poke around without any prior experience but there is some learning and training necessary to extract the most value from them.
In Vim's case, you have two invaluable built-in resources at your disposal:
If you only use Vim casually, for quick edits like $ git commit
or $ rebase -i
, then going through $ vimtutor
at least one time is pretty much required. Case in point, the command that is giving you trouble is explained under lesson 3.1.
If you plan to use Vim as your main editor, then the most sensible thing to do is to start an active reading of the user manual, :help user-manual
. It is actually a thorough tutorial that takes you from "noob" to "advanced" in a very approchable, iterative manner.
If you think all of this is too much work for too little gain, then I would suggest you stick to nano or some similar, more comfortable, editor. There is no point picking up a notoriously weird and complex tool if you don't want to put in the required effort.
Sample rebase taken from this article.