Search code examples
org-modeorg-babel

How to org-babel-tangle only one code block?


I'm generating multiple files in one .org file, with multiple source code blocks. For example:

#+begin_src rst :tangle file1.rst :noweb yes
<<file1>>
#+end_src

#+begin_src rst :tangle file2.rst :noweb yes
<<file2>>
#+end_src

Is there any way to only tangle one specific code block without changing the header options?

I'm generating these files for Sphinx and to reduce the compilation time I want to tangle only the file I'm currently working on.

It would be great if there is a command such as org-babel-tangle-current-block - is there any way to do this?

(This is a related question to Orgmode: how to filter the blocks to be tangle?)


Solution

  • That is possible by calling org-babel-tangle with a prefix argument.

    So C-u C-c C-v t should do what you want.

    From the docstring:

    With one universal prefix argument, only tangle the block at point. When two universal prefix arguments, only tangle blocks for the tangle file of the block at point.