0

Suppose I have the following code block in an org file.

#+begin_src sql
SELECT id
FROM product
WHERE name = 'Apple'
#+end_src

I want to select this part:

SELECT id
FROM product
WHERE name = 'Apple'

I was taught to use C-SPC, but C-SPC was already used by my OS, is there any way to do this? For example, bind this function to another shortcut? By the way, I'm using spacemacs.

  • Your question is about how to set the mark if C-SPC is hijacked before emacs can use it. Isn't strictly related to org-mode, neither about how to bind keys, although that will solve your problem. Please update tags and question. – Muihlinn May 2 at 10:33
1

You can rebind set-mark-command to anything (C-. in the example)

(global-set-key (kbd "C-.") 'set-mark-command)

or

(define-key 'global-map (kbd "C-.") 'set-mark-command)

Alernatively, without having to rebind anything:

  • it's also bound to C-@.

  • You can exchange point and mark C-xC-x -- if you're not using the current mark already it'll be the same.

  • You can mark the paragrah, or org-element with M-h, move the point to first line you want, then reduce region exchanging point and mark first, and moving the point again to the desired end. Sounds far more complicated than it is, but sometimes it's faster than any other method.

Sure there are more ways, but I do use those.


Straight to the example, to select directly only the src block contents you can use org-babel-mark-block which is bound to C-c C-v C-M-h. Sure not really the most friendly shortcut for the memory muscle.

Thanks to bertfred for pointing it in this answer

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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