Replies: 1 comment
-
|
I wrote a very nasty workaround a while ago, which might help you out. I'm not actually sure if it works right now. I ended up just using space contained file names as they didn't bring as much trouble as I initially thought. local neorg_aug = vim.api.nvim_create_augroup("NeorgWritePre", { clear = true })
local function rename_file_with_spaces(_)
vim.api.nvim_create_autocmd("BufWinEnter", {
group = neorg_aug,
pattern = "*.norg",
desc = "Neorg: rename file if filename contains whitespace to underscore",
callback = function()
local file = vim.fn.expand("<afile>")
local dir, file_name = vim.fn.fnamemodify(file, ":p:h"), vim.fn.fnamemodify(file, ":p:t")
local new_name = string.gsub(file_name, " ", "_")
-- TODO: you may want to string.lower here
if file_name == new_name then
return
end
local res, err = os.rename(dir .. "/" .. file_name, dir .. "/" .. new_name)
if not res then
vim.notify(err or string.format("Failed to rename: `%s` -> `%s`", file_name, new_name), vim.log.levels.ERROR)
return
end
vim.schedule(function()
vim.api.nvim_buf_delete(0, {})
vim.cmd.edit(dir .. "/" .. new_name)
end)
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
Uh oh!
There was an error while loading. Please reload this page.
-
I like that I can use
,nnto create a new note on the fly. I don't like that the file names end up having the same case/spaces. I would prefer that:Given a new note title such as "All about Neorg"
When I create a new note using
,nnand type in 'All about Neorg"I then get a new note file with the name all-about-neorg.norg, with a title inside the norg file that reads "All about Neorg"
Is there a setting/hack I can use to do this simply?
Beta Was this translation helpful? Give feedback.
All reactions