Skip to content

Instantly share code, notes, and snippets.

@MilesCranmer
Last active December 22, 2018 04:44
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 MilesCranmer/6a192f15a7c6e67c5ffc26e2b60baede to your computer and use it in GitHub Desktop.
Save MilesCranmer/6a192f15a7c6e67c5ffc26e2b60baede to your computer and use it in GitHub Desktop.
Remove latex code so can feed paper into grammarly.com
" Delete up to begin{document}, and from end{document} to before the bibliography.
:%s/\\cite{[a-zA-Z0-9_]\+}/REF/g
:%s/\\citealt{[a-zA-Z0-9_]\+}/REF/g
:%s/\\cref{[a-zA-Z0-9_:]\+}/REF/g
:%s/\\caption{//g
:%s/\$\$.\{-}\$\$/REF/g
:%s/\$.\{-}\$/REF/g
:%s/\\[a-zA-Z_]\+{.*}/ /g
:%s/\\[a-zA-Z_]\+/ /g
:%s/\\\\//g
:%s/%.*//g
:%s/{/ /g
:%s/}/ /g
" Run the following several times to remove line breaks (only single line breaks)
:%s/^\(.\+\)\n\(.\+\)\n/\1 \2\r/g
" Run the following several times
:%s/ / /g
" Delete remaining double blank lines
:%s/\n\n\n/\r\r/g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment