Create title on save #506
Unanswered
guilhermeprokisch
asked this question in
Q&A
Replies: 1 comment
-
Hey @guilhermeprokisch, you could get this behavior by adding a custom callbacks = {
-- Runs right before writing the buffer for a note.
---@param client obsidian.Client
---@param note obsidian.Note
---@diagnostic disable-next-line: unused-local
pre_write_note = function(client, note)
local util = require "obsidian.util"
if not note.title then
local title = util.input "Enter title: "
if not title or string.len(title) == 0 then
return
end
note.title = title
local insert_at = 0
if note.frontmatter_end_line ~= nil then
insert_at = note.frontmatter_end_line + 1
end
vim.api.nvim_buf_set_lines(0, insert_at, insert_at, false, { "# " .. title })
end
end,
}, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey,
I've got a bit of a workflow quirk when it takes notes in Obsidian. I prefer jotting down the main content first and coming up with a title afterwards. Saves me from getting hung up on naming things upfront.
So here's what I'm hoping to sort out:
Is there a way to have prompt for a title only when I'm about to save the note?
Even better - if my note already has a main header (like a top-level H1), could just automatically use that as the title and skip the prompt altogether?
I appreciate any suggestions or config tweaks that could help make this happen!
Beta Was this translation helpful? Give feedback.
All reactions