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

I know this thread is old, and it seems to be fixed, but I found it while trying to overcome the same problem of inserting a blank line between the ‘head’ and the cursor.

So far, all my attempts have failed, I followed the link to github you provided, and tried to look at the commit which is supposed to have fixed the issue where I can see a reassuring (insert (org-roam-capture--fill-template head 'ensure-newline))) added to the code.

Since inserting \n or \n\n has no effect on my end, I looked for some ensure-newline or fill-template kind of variable but did not find any. I cannot find anything related in the org-roam-capture-template help.

Is there anything in particular to do to prevent blank lines from being stripped off the org-roam-templates ?