Multiple blank lines in head of capture template

I’m trying to have my capture templates insert an extra line before the content of the entry and the head. From what I understand after looking at the definition of org-roam-capture--fill-template, when using the template line breaks are essentially ignored. So, effectively, these two bits of code are treated the same

(setq org-roam-capture-templates
   '(("d" "default" plain "%?" :target
      (file+head "%<%Y%m%d%H%M%S>.org" "#+title: ${title}\n#+filetags: :draft:\n")
      :unnarrowed t)))
(setq org-roam-capture-templates
   '(("d" "default" plain "%?" :target
      (file+head "%<%Y%m%d%H%M%S>.org" "#+title: ${title}\n#+filetags: :draft:\n\n")
      :unnarrowed t)))

Has anyone managed to find a way around this? (I don’t want to insert a bunch of blank lines after capture, so in general I’m OK with the default behavior in most situations, but I’d like the ability to have that extra space after the header (or is is the head?)

1 Like

Use \n to insert a line break, so \n\n would insert a blank line.

@apc This indeed doesn’t work, line breaks \n are ignored at the end of the header. I am having the same problem. I also tried adding a blank line at the start of the template file, but it is ignored as well. Any ideas?
Edit: corrected typo.

Refer to the comments and following lines of code around here.

I believe you’d need to override the function locally (I am not certain which line exactly). I’d edebug and see how the code removes the additional empty lines added in the template.

Have looked at the code comments. It makes sense to strip trailing new lines from the header, but I would suggest not touching anything people define in the template file; i.e. leave that up to the user.

I suggest you report this to the project as an issue.

Done, see here. Thanks!

1 Like