sponsor Vim development Vim logo Vim Book Ad

vim-cpywrite : Generate copyright headers for any open source license

 script karma  Rating 0/0, Downloaded by 396  Comments, bugs, improvements  Vim wiki

created by
Robert Di Pardo
script type
Pass a license identifier to the :CPYwrite command and it will insert the
standard header, if available, at the top of the current buffer.

When g:cpywrite#verbatim_mode is off, licenses with no standard header will
be acknowledged below your author line. Turn on g:cpywrite#verbatim_mode to
use the full license text instead.

This plugin learns your name and email by invoking `git`; it falls back to
your OS user and host names.

Quick Reference
:CPYwrite [{spdx_short_name}]

Fetches the license identified by `spdx_short_name` (without quotes)
-- uses the current value of `g:cpywrite#default_license` when no argument is
given -- supports <tab> completion

:CPYwriteDefaultLicense [{spdx_short_name}]

Sets g:cpywrite#default_license to the given SPDX license identifier (without
quotes) and prints the updated value. Use <tab> for name completion.

Simply prints g:cpywrite#default_license when called with no argument.


Toggles the state of the g:cpywrite#verbatim_mode option and prints a
description of the current state:

    0 == "standard header/brief"
    1 == "verbatim"


Toggles the state of the g:cpywrite#hide_filename option and prints a
description of the current state:

    0 == "showing"
    1 == "hidden"


Does the same as calling :CPYwrite with no argument


Maps to <Plug>(cpywrite)

g:cpywrite#default_license (string; default: 'GPL-3.0-or-later')

Set this to the SPDX identifier of your favourite license. Press <tab> after
the :CPYwriteDefaultLicense or :CPYwrite command for suggestions.

g:cpywrite#verbatim_mode (number; default: 0)

When set to a non-zero value, the full license text will be requested, whether
or not a standard header exists. You should only choose this when the license
is no longer than 3-4 paragraphs (e.g. Unlicense, MIT, BSD 1- 2- 3-Clause, etc.)

When set to 0, only standard headers are requested. Licenses with no standard
header will be briefly mentioned below your copyright line.

g:cpywrite#hide_filename (number; default: 0)

When set to a non-zero value, hides the name of the current buffer from the
license header in all modes. Otherwise, the buffer's name will appear on the
first line.

Testing Locally
- install vader.vim (vimscript #4832) into your runtime path

- alternatively, run `git clone https://github.com/junegunn/vader.vim.git` and
edit `test/vimrc` by changing

     set rtp+=vader.vim


     set rtp+=/path/to/cloned/source/of/vader.vim

- change directories into /your/plugin/path/vim-cpywrite

- issue these commands:

     pip install -r test/requirements.txt
     pytest -v
     vim -ENsu test/vimrc -c '+Vader! test/vader/*' > /dev/null
install details
Make sure your environment has the requirements listed at https://github.com/rdipardo/vim-cpywrite#requirements

For a detailed installation guide, refer to https://github.com/rdipardo/vim-cpywrite#installation

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-cpywrite-0.3.4.tar.gz 0.3.4 2021-04-04 7.4 Robert Di Pardo Handle missing emails, fix regex bugs, reduce plugin size
vim-cpywrite-0.3.3.tar.gz 0.3.3 2021-03-08 7.4 Robert Di Pardo Maintenance release.
vim-cpywrite-0.3.2.tar.gz 0.3.2 2020-12-29 7.4 Robert Di Pardo More file types, minor fixes.
vim-cpywrite-0.3.1.tar.gz 0.3.1 2020-10-27 7.4 Robert Di Pardo Fixes bug caused by emails with '+' separators
vim-cpywrite-0.3.0.tar.gz 0.3.0 2020-10-12 7.4 Robert Di Pardo Provide option to hide buffer name in license header, support for more file types
vim-cpywrite-0.2.1.tar.gz 0.2.1 2020-08-17 7.4 Robert Di Pardo Support more file types, detect public domain licenses
vim-cpywrite.tar.gz 0.1.0 2020-06-13 7.4 Robert Di Pardo Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.