Skip to content

Instantly share code, notes, and snippets.

@igrep
Last active March 18, 2023 05:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igrep/3618bcdf0294c81bda3481464be96bc8 to your computer and use it in GitHub Desktop.
Save igrep/3618bcdf0294c81bda3481464be96bc8 to your computer and use it in GitHub Desktop.
MDNの翻訳中、現在開いている英語版のパスを日本語版のパスに変換して開く(WindowsのNeovimで動かしていて、なおかつtranslated-contentとcontentが同じディレクトリーにある前提なので注意)
function! ToJaPath(enPath) abort
" e.g. content\files\en-us\glossary\boolean\html\index.md
return substitute(a:enPath, '^content\\files\\en-us', 'translated-content\\files\\ja', '')
endfunction
function! PrepareJaPath() abort
let path_to_index_md = ToJaPath(expand('%'))
call mkdir(v:lua.vim.fs.dirname(path_to_index_md), "p")
return path_to_index_md
endfunction
function! OpenJaPath() abort
execute "edit " . PrepareJaPath()
endfunction
function! CopyToJaPath() abort
let path_to_index_md = PrepareJaPath()
execute "w " . path_to_index_md
execute "edit " . path_to_index_md
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment