빠른 참조

Vim Projectionist 치트시트

vim-projectionist 빠른 참조 가이드: 프로젝트 구성, 대체 파일 탐색, 파일 템플릿, 디스패치 명령 및 커스텀 프로젝션.

· 게시일

Tim Pope가 개발한 vim-projectionist는 정밀한 프로젝트 탐색, 대체 파일 이동(:A), 자동 파일 스켈레톤 템플릿을 제공합니다.

기본 설정 (.projectionist.json)

프로젝트 루트에 .projectionist.json 파일을 생성합니다:

{
  "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);",
      "  });",
      "});"
    ]
  }
}

대체 파일 탐색 명령어

명령어 동작
:A 현재 창에서 대체 파일 편집
:AS 수평 분할 창에서 대체 파일 편집
:AV 수직 분할 창에서 대체 파일 편집
:AT 새 탭에서 대체 파일 편집
:AD 현재 빈 버퍼에 템플릿 내용 읽어오기

프로젝트 명령어 및 루트 탐색

명령어 동작
:Cd 작업 디렉터리를 프로젝트 루트로 변경
:Cd {path} 프로젝트 루트 기준 상대 경로로 디렉터리 변경
:Lcd 현재 창 로컬 디렉터리(:lcd)를 루트로 변경
:ProjectDo {cmd} 프로젝트 루트에서 셸 명령 실행

사용자 지정 타입 명령어

"type": "model"을 정의하면 :Emodel, :Smodel, :Vmodel, :Tmodel 명령이 생성됩니다:

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

:Emodel user를 실행하면 app/models/user.rb로 즉시 이동합니다.


참고 자료

관련 주제