Last active
February 16, 2018 20:18
-
-
Save gzagatti/3f48a46182b4d5e7211a681d66f2c8c9 to your computer and use it in GitHub Desktop.
Rename figure tag in tex and move the corresponding file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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