Skip to content

Instantly share code, notes, and snippets.

@abstrctn
Last active October 5, 2021 17:49
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 abstrctn/601de891eda7bf3755e5 to your computer and use it in GitHub Desktop.
Save abstrctn/601de891eda7bf3755e5 to your computer and use it in GitHub Desktop.
Don't make assumptions about gender in your documentation

gender.vim

Don't make assumptions about gender in your documentation.

If you use VIM, you can use the following configuration to alert you to any gender-specific pronouns in your documentation, giving you the chance to de-gender them as necessary.

gender.vim extends the syntax highlighting of a filetype to highlight certain words.

You will need to load this after any default syntax highlighting gets applied to your filetype. The after directory in VIM gets loaded after other plugins or syntax files, making it the location where you should store extensions to existing behavior. If doesn't exist already, make a ~/.vim/after/syntaxdirectory, and placegender.vim` inside it.

By default, files in the syntax directory are loaded by the filetype of the file you're editing. ~/.vim/after/syntax/html.vim would be loaded when editing an HTML file, for example, letting you declare language-specific syntax.

You can make it apply to multiple filetypes by adding the following to your ~/.vimrc file, or another location that gets autoloaded by your vim editor.

au BufNewFile,BufRead *.md,*.html so ~/.vim/after/syntax/gender.vim

This command runs by default on files whose extension match *.md,*.html, i.e. Markdown and HTML files. You can add addition comma-separated file extensions to make this run on additional filetypes. Or, include the following to make it run on all filetypes:

au BufNewFile,BufRead * so ~/.vim/after/syntax/gender.vim

" Text between "\<" and "\>" ensures only complete words are matched.
" '\c' matches case insensitive
syn match Gender containedin=ALL /\c\<he\>/
syn match Gender containedin=ALL /\c\<him\>/
syn match Gender containedin=ALL /\c\<his\>/
syn match Gender containedin=ALL /\c\<himself\>/
syn match Gender containedin=ALL /\c\<she\>/
syn match Gender containedin=ALL /\c\<her\>/
syn match Gender containedin=ALL /\c\<hers\>/
syn match Gender containedin=ALL /\c\<herself\>/
" Add all genderKeywords patterns to the Error group
hi link Gender Error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment