orgmode icon indicating copy to clipboard operation
orgmode copied to clipboard

Text objects for code/verbatim (inline) and source code blocks

Open Maltimore opened this issue 3 years ago • 1 comments

Does this feature exist in Emacs orgmode core?

N/A

Orgmode link

Not sure, didn't find anything during a quick web search. But I'm sure it exists.

Feature value

If I have inline code:

Here is inline code: ~echo hello world~

I would like to be able to interact with the code easily, for instance yi~ to copy the code while the cursor is somewhere inside the code. Same for verbatim here is =verbatim=. Would be nice to be able to do yi= or di= or whatever. And one could even extend it to full source code blocks demarked by

#+BEGIN_SRC 
..
..
#+END_SRC

I noticed that neovim can already do this with backticks (that (I think) are not part of org): here `this works`. I can do yi`.

Additional context

No response

Maltimore avatar Jun 12 '22 09:06 Maltimore

I would suggest the following:

  • [x] Expanding this to other markings in the Org markup: *bold*, /italic/, _underlined_ and +strike-through+.
  • [x] Supporting not only i (‘inner’) but also a (‘around’? ‘all’?); see :h object-select.
  • [ ] Supporting s (‘surround’) as well, like surround.vim does. This is particularly useful when you want to remove (ds) or change (cs) surrounding markings. If we don’t actually rely on surround.vim as a dependency, maybe care should be taken so the behaviour of the two packages doesn’t collide.

rwmpelstilzchen avatar Sep 03 '23 19:09 rwmpelstilzchen

This was partially addressed in https://github.com/nvim-orgmode/orgmode/commit/44a20fb5a5628a1374d481d384ee198d428cc330.

First 2 options from previous comment:

  • [x] Expanding this to other markings in the Org markup: *bold*, /italic/, _underlined_ and +strike-through+.
  • [x] Supporting not only i (‘inner’) but also a (‘around’? ‘all’?); see :h object-select.

kristijanhusak avatar Feb 25 '24 21:02 kristijanhusak

Works perfectly. Thanks a lot! The main part in this issue has been addressed. Making it work like surround.vim should be its own issue I think, so I'm closing.

Maltimore avatar Feb 25 '24 22:02 Maltimore