This page is not available in every language. Missing translations are disabled in the language selector.

Quick reference

Vim Projectionist Cheatsheet

A quick reference guide for vim-projectionist: project configuration, alternate file navigation, file templates, dispatch commands, and custom projections.

· Published

vim-projectionist by Tim Pope provides granular project navigation, alternate file jumping (:A), and automated file skeleton templates.

Basic Configuration (.projectionist.json)

Place .projectionist.json in the root of your project:

{
  "src/*.js": {
    "alternate": "test/{}.test.js",
    "type": "source"
  },
  "test/*.test.js": {
    "alternate": "src/{}.js",
    "type": "test",
    "template": [
      "import { describe, it, expect } from 'vitest';",
      "",
      "describe('{}', () => {",
      "  it('works', () => {",
      "    expect(true).toBe(true);",
      "  });",
      "});"
    ]
  }
}

Alternate File Navigation Commands

Command Action
:A Edit the alternate file in the current window
:AS Edit alternate file in a horizontal split
:AV Edit alternate file in a vertical split
:AT Edit alternate file in a new tab
:AD Read the template into the current empty buffer

Project Commands & Root Navigation

Command Action
:Cd Change working directory to project root
:Cd {path} Change directory to relative path under root
:Lcd Local directory change (:lcd) to root
:ProjectDo {cmd} Execute shell command from project root

Custom Type Commands

Defining "type": "model" creates :Emodel, :Smodel, :Vmodel, and :Tmodel commands:

{
  "app/models/*.rb": {
    "type": "model",
    "alternate": "spec/models/{}_spec.rb"
  }
}

Run :Emodel user to jump straight to app/models/user.rb.


References

Related topics