0
* Infrastructure and Programming Machine                              :inbox:
:PROPERTIES:
:Effort:   0:30
:END:
** test1
-test
-test2

If my cursor is under "test2" and I use C-c C-u, the cursor jumps back to "Infrastructure", but I would expect the cursor to jump to **test1. Why does the cursor jump further?

2 Answers 2

1

Check the menu items under Org/Navigate Headings. There you will find Up, bound to C-c C-u, but you will also find Previous, bound to C-c C-p and Previous Same Level, bound to C-c C-b. In this case, either of the latter will do what you want, but in general you need to use the one that does what you mean. So you should read the descriptions of the commands that the various keys are bound to: they are different for a reason, so it is up to you to decide which one is the appropriate one for the task at hand. For example, you can ask Emacs what command C-c C-u is bound to withC-h c C-c C-u: that will tell you that C-c C-u is bound to outline-up-heading. Then using the help system again with C-h f outline-up-heading will tell you the doc string of the command:

...
Move to the visible heading line of which the present line is a subheading.
With argument, move up ARG levels.

whereas doing the same thing with C-c C-p will tell you that the key is bound to org-previous-visible-heading and that this command does the following:

Move to the previous visible heading.
With ARG, repeats or can move forward if negative.

As @choroba points out in his answer, you can also supply an argument of 0 to outline-up-heading to have it move up to the current heading. You do that with M-0 C-c C-u; if you want to go up two levels, you supply an argument of 2 with M-2 C-c C-u. You can change the behavior of many functions by supplying such a numeric argument. This is described in the Emacs manual.

To summarize: 1) use the menus to find out what's available; 2) use the help system to find out what command a key is bound to and to read the doc string of the command; 3) use arguments to modify the behavior of a command; 4) experiment with what's available to find out the (sometimes subtle) differences between the various commands.

1

To get zero levels up, use the universal argument zero:

M-0C-cC-u

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.