autocd.vim


Ⅰ. 插件描述

Intelligent directory switching based on marker

Ⅱ. 基本信息

创建日期:  2019-01-20
使用用户:  3
Github星:  8
插件作者:  paroxayte

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'paroxayte/autocd-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'paroxayte/autocd-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'paroxayte/autocd-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/paroxayte/autocd.vim

Ⅳ. 文档说明

# Autocd.vim

A cwd management tool for vim.
Keep your cwd in sync with your workflow so that functions, plugins, and external commands can
utilize getcwd() as a reliable current project directory.

Features

  • Highly configurable current directory setter.
  • NERDTree integration. Keep NERDTree in sync with the output of this command.

Installation

TEST

Use the plugin manager of your choice to install. Example using dein. If using NERDTree integration and vim-devicons, this plugin must be sourced after vim-devicons to prevent conflict.

call dein#add('paroxayte/autocd.vim')

Configuration

Below are some configuration examples. For a full list of configuration options see :help autocd.vim-configuration

Markers

Autocd works by processing various triggers each associated with a mark. When a trigger goes off,
autocd searches up the directory heiarchy looking for a specified marker. For instance if creating a
java project with maven there will be a pom.xml in the project root. To automatically change to the
root of a maven java project with :Autocd

let g:autocd#markers = {
\  '*.java': ['pom.xml']
\}

To automatically cd to project root of vscode, eclipse, or git projects.

let g:autocd#markers = {
\   '*user/Dev*': ['.project', '.vscode', '.git']
\}

To create special rules for a specific file, the file's full path can be used with
g:autocd#markers.

let g:autocd#markers = {
\   '/path/to/file': ['some_marker']
\}

Default

If search for markers fail, a default action can be preformed. To enable this
g:autocd#markers_default = 1 must be set. By default, the behavior is the same as autochdir,
switching to the current file's containing directory. To modify this behavior
g:autocd#makers_get_default() may be overridden. The function is expected to return a string
representing the desired directory, or a integer to represent failure. For more information see :help g:autocd#makers_get_default()

NERDTree Sync

To enable NERDTree synchronization g:autocd#nts_enable = 1 must be set at startup. Alternatively
the functions autocd#nts_enable() and autocd#nts_disable() may be called to change the state of
this feature post startup.

Commands & Autocommands

The sole command of Autocd is :Autocd. To run :Autocd automatically on BufEnter g:autocd#autocmd_enable = 1 must be set on startup.

Example Configuration

let g:autocd#nts_enable = 1
let g:autocd#autocmd_enable = 1
let g:autocd#markers_default = 1
let g:autocd#markers = {
\   '*.java' : ['pom.xml'],
\   '*/user/Dev/*': ['.project', '.vscode', '.git'],
\}

More Information

For more information see :help autocd.vim

Issues

See contributing.

Self Promotion

If this plugin is useful, give the repo a star!

添加新评论