<commit_before>---
title: Cite as you Write
aliases:
  - /Cite-as-you-Write
  - /cayw
tags:
  - citation keys
  - overleaf
  - cite as you write
---

**PSA: as of Zotero 5.0.71, access to the CAYW URL will no longer work from the browser for security reasons; `curl` and other programmatic such as from editors access will work.**

Good news for TeXnicians and those down with Mark (aka Markdown, RST, whatnot): this is the time to go pester the author of your favorite editor for Zotero integration! 

## Editor integration

### vim

Graciously supplied by <NAME>:

paste it in your .vimrc (and modify to your liking):

```
function! ZoteroCite()
  " pick a format based on the filetype (customize at will)
  let format = &filetype =~ '.*tex' ? 'citep' : 'pandoc'
  let api_call = 'http://127.0.0.1:23119/better-bibtex/cayw?format='.format.'&brackets=1'
  let ref = system('curl -s '.shellescape(api_call))
  return ref
endfunction

noremap <leader>z "=ZoteroCite()<CR>p
inoremap <C-z> <C-r>=ZoteroCite()<CR>
```

This inserts the citation at the cursor using the shortcut ctrl-z (in insert mode) or `<leader>`z (in normal, visual etc. modes, `<leader>` being backslash by default).

###  Zotero Citations for Atom

A sample implementation of real integration (rather than the working-but-clunky workarounds using paste) can be found in the [Zotero Citations](https://atom.io/packages/zotero-citations) package for the [Atom](http://atom.io) editor.

### Scrivener 2.0/Marked 2 for Mac

Dave Smith has gracefully written [instructions](http://davepwsmith.github.io/academic-scrivener-howto/) on how to set up Scrivener 2.0 and Marked 2 for OSX to use the CAYW picker, including ready-to-run apps
<commit_msg>Update cayw.md (#1338)<commit_after>---
title: Cite as you Write
aliases:
  - /Cite-as-you-Write
  - /cayw
tags:
  - citation keys
  - overleaf
  - cite as you write
---

**PSA: as of Zotero 5.0.71, access to the CAYW URL will no longer work from the browser for security reasons; `curl` and other programmatic such as from editors access will work.**

Good news for TeXnicians and those down with Mark (aka Markdown, RST, whatnot): this is the time to go pester the author of your favorite editor for Zotero integration! 

## Editor integration

### vim

Graciously supplied by <NAME>:

paste it in your .vimrc (and modify to your liking):

```
function! ZoteroCite()
  " pick a format based on the filetype (customize at will)
  let format = &filetype =~ '.*tex' ? 'citep' : 'pandoc'
  let api_call = 'http://1192.168.127.12:23119/better-bibtex/cayw?format='.format.'&brackets=1'
  let ref = system('curl -s '.shellescape(api_call))
  return ref
endfunction

noremap <leader>z "=ZoteroCite()<CR>p
inoremap <C-z> <C-r>=ZoteroCite()<CR>
```

This inserts the citation at the cursor using the shortcut ctrl-z (in insert mode) or `<leader>`z (in normal, visual etc. modes, `<leader>` being backslash by default).

###  Zotero Citations for Atom

A sample implementation of real integration (rather than the working-but-clunky workarounds using paste) can be found in the [Zotero Citations](https://atom.io/packages/zotero-citations) package for the [Atom](http://atom.io) editor.


###  VS Code Citation Picker for Zotero

If you don't feel like typing citations out (and let's be honest, you don't), executing [VS Code Citation Picker for Zotero](https://marketplace.visualstudio.com/items?itemName=mblode.zotero) extension for the [VS Code](https://code.visualstudio.com/) editor will call up a graphical picker which will insert these for you, formatted and all.

### Scrivener 2.0/Marked 2 for Mac

<NAME> has gracefully written [instructions](http://davepwsmith.github.io/academic-scrivener-howto/) on how to set up Scrivener 2.0 and Marked 2 for OSX to use the CAYW picker, including ready-to-run apps

{'fraction_non_alphanumeric': 0.11192660550458716, 'fraction_numerical': 0.014154652686762779, 'mean_word_length': 4.213114754098361, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3192079', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1249, 'n_words': 479}