Replies: 2 comments 6 replies
-
You can probably write your own wrapper around these calls to make your life easier. Something like this: -- Orgmode setup call. This is needed in the function
local org = require('orgmode').setup(require('partials.orgmode_config'))
function _G.capture_from_terminal()
-- Ensure org is initialized
org:init()
vim.schedule(function()
-- Open desired template
org.capture:open_template_by_shortcut('t')
-- Map Q to write + exit Neovim. Make sure to leave vim.schedule calls
-- to make sure everything is written
vim.keymap.set('n', 'Q', function()
vim.cmd[[wq]]
vim.schedule(function()
vim.cmd[[qall!]]
end)
end)
end)
end
And then run your nvim with Note that this touches some of the internal things, so I'm not guaranteeing this will not break in future. |
Beta Was this translation helpful? Give feedback.
5 replies
-
I use |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This may be considered golfing. I often find myself outside of vim when I want to capture something in orgmode. Being naturally
lazyefficient I looked at my workflowv
)<leader>oc
):wq
):q
)and it's less than desirable. Yes I can collapse steps 4 and 5 to
:wqa
and I will relearn my fingers to do so (perhaps you know an even better way than:wqa
?). But still, I already know that I want to only make a capture and nothing else before step 1. So I researched if I could do something likev -"<leader>oc"
to jump directly into the capture buffer. Indeed, there is-c|--cmd
that allows me to do thisv +"norm 1 oc"
(see this question for why the1
is necessary when your<leader>
is mapped to space). But alas! It does not work for this particular remapping. Thenorm 1 ...
syntax works for other mappings I have and also for e.g.norm 1 oih
. I have made no research yet why it does not work for fornorm 1 oc
, but it also doesn't work fornorm 1 oa
(opening the agenda), so I suspect it's something about opening a buffer.The reason I write here is that perhaps I'm doing this all wrong and there is a really easy way to start the capture buffer straight from the terminal.
Beta Was this translation helpful? Give feedback.
All reactions