You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a function to mimic the basic usage of this Obsidian plugin: Filename Heading Sync
My function:
" keeps markdown heading in sync with filename
function! SyncHeading()
let @a ="# " . trim(bufname(), ".md", 2)
1g/^# .*/norm D"ap
endfunction
" merge with ObsidianRename
command! ObsidianMyRenameAndSync execute 'ObsidianRename' | call SyncHeading()
noremap <F2> :ObsidianMyRenameAndSync<cr>
It's crude, but I only have basic skills in vimscripting; it fits my needs and it might be useful to some of you.
Note: 1g/ means it only updates the heading if it occupies the first line in the file. To give it a bit of leeway you might try something like 1,10g/ (checks lines 1 to 10). If you only have one heading, use g/ instead.
To update a misaligned heading, just execute the function: :call SyncHeading().
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I wrote a function to mimic the basic usage of this Obsidian plugin:
Filename Heading Sync
My function:
It's crude, but I only have basic skills in vimscripting; it fits my needs and it might be useful to some of you.
Note:
1g/
means it only updates the heading if it occupies the first line in the file. To give it a bit of leeway you might try something like1,10g/
(checks lines 1 to 10). If you only have one heading, useg/
instead.To update a misaligned heading, just execute the function:
:call SyncHeading()
.Beta Was this translation helpful? Give feedback.
All reactions