Skip to content

Instantly share code, notes, and snippets.

@gzagatti
Last active February 16, 2018 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gzagatti/3f48a46182b4d5e7211a681d66f2c8c9 to your computer and use it in GitHub Desktop.
Save gzagatti/3f48a46182b4d5e7211a681d66f2c8c9 to your computer and use it in GitHub Desktop.
Rename figure tag in tex and move the corresponding file.
function! VimtexLabelRename(oldtag, newtag)
" Change figure tag in tex and move the corresponding
" file.
exe '%s/\v\{(fig:)?' . a:oldtag . '\}/{fig:' . a:newtag . '}/g'
exe '%s/\v\{' . a:oldtag . '(_.*)?\.png\}/{' . a:newtag . '\1.png}/g'
exe '!for i in `find assets -name 'a:oldtag.'*`; do mv $i ${i/'.a:oldtag.'/'.a:newtag.'}; done'
"exe '!mv' 'assets/'.a:oldtag.'.png' 'assets/'.a:newtag.'.png'
endfunction
command! -nargs=* VimtexLabelRename call VimtexLabelRename(<f-args>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment