cake.vim


Ⅰ. 插件描述

Utility for CakePHP developers.

Ⅱ. 基本信息

创建日期:  2011-05-17
使用用户:  51
Github星:  35
插件作者:  Yuhei Kagaya

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

# cake.vim
Utility for CakePHP developers. Provides the ability to easily jump between files.

Requirements

  • Vim ver.7.3 or heigher
  • CakePHP ver.1.3.x or ver.2.x

Quick Start

  1. Installation
    Download, unzip, put under the ~/.vim directory.

If you are using Vundle,as follows:

:BundleInstall violetyk/cake.vim
  1. Launch vim, specify the application directory of CakePHP.

    :CakePHP /path/to/cakephp_app_directory
  2. Open the file as follows:

    :Ccontroller {controller-name}
  • Argument that you specify in the command {controller-name}, you can tab-completion.
  • You can horizontal split, vertical split, also be open in the tab. Add sp, vsp, and tab to the each command.
  • Multiple arguments can be specified.

    :Ccontrollersp {controller-name} {controller-name} ...
    :Ccontrollervsp {controller-name} {controller-name} ...
    :Ccontrollertab {controller-name} {controller-name} ...

Jump Command List

No arguments : If you do not specify arguments, guess depending on the type of the current buffer.

TargetCommandMultiple argumentsNo arguments
Controller:Ccontroller {controller-name}okView / Model / ControllerTestCase
Model:Cmodel {model-name}okController / Fixture / ModelTestCase
View of the current controller:Cview {view-name} ({theme-name}) ({theme-name} is optional)
View of action the current controller:Cview
View of the specified controller:Ccontrollerview {controller-name} {view-name} ({theme-name}) ({theme-name} is optional)
Config (core.php, database.php etc):Cconfig {config-name}ok
Component:Ccomponent {component-name}okComponentTestCase
Behavior:Cbehavior {behavior-name}okBehaviorTestCase
Helper:Chelper {helper-name}okHelperTestCase
Shell:Cshell {shell-name}ok
Task:Ctask {task-name}ok
Cake Core library:Ccore {core-name}ok
1st party library:Clib {lib-name}ok
Log File (like tail -f):Clog {log-name} (See g:cakephp_log)
Fixture:Cfixture {fixture-name}okModel
TestController:Ctestcontroller {controller-name}okController
TestModel:Ctestmodel {model-name}okModel
TestComponent:Ctestcomponent {component-name}okComponent
TestBehavior:Ctestbehavior {behavior-name}okBehavior
TestHelper:Ctesthelper {helper-name}okHelper
Test (Any):Ctest Controller / Model / Component / Behavior / Helper / Fixture

gf

  • In Vim, you press the gf in normal mode, open the path it is written under the cursor, but, gf in a project in CakePHP to open the file of the object.
  • <C-w>f is horizontal split, <C-w>gf is open in a tab, and gs is vertical split. See g:cakephp_keybind_vsplit_gf.

Example

// gf on AppController -> AppController
class MyController extends AppController {
  // gf with the following line -> layouts/2column.ctp
  var $layout = '2column';
  
  // gf on Post -> PostHelper
  var $helpers = array('Post');

  // gf on Session -> SessionComponent (CakePHP Core)
  var $components = array('Session');

  // gf with the following line -> index.ctp
  function index() {

    // gf with the following line -> layouts/default.ctp
    $this->layout = 'default';
    
    // gf on Post -> PostModel
    $this->Post->find('all')
    
    // gf on Set -> cake/libs/set.php
    Set::extract('/Post', $posts);
    
    // gf with the following line -> views/{controller-name}/pc/index.ctp
    $this->render('pc/index.ctp');
  }
}

// gf with the following line -> config
Configure::load('list');

// gf with the following line -> views/elements/pager.ctp
$this->element('pager');

// gf with the following line -> views/elements/sidebar/menu.ctp
$this->element('sidebar/menu');

// gf with the following line -> css/style.css
$html->css('style');

// gf with the following line -> js/jquery.js
$html->script('jquery');

// gf with the following line -> HogeController::fuga()
array('controller' => 'Hoge', 'action' => 'fuga')

// gf with the following line -> HogeController::admin_fuga()
array('controller' => 'Hoge', 'action' => 'fuga', 'admin' => true)

Utility Command

  • If dbext.vim is installed, you can see the table definition of the model, :Cdesc {model-name}. If you do not specify an argument, the word under the cursor can be specified.
  • :Celement {element-name} Cut out as an element the selected range. :help :Celement
  • :Cbake [{target}] Run bake command interactively. :help :Cbake
  • :Ctestrun [{testmethod}] Run test case command, guess depending on the type of the current buffer.
  • :Ctestrunmethod Run the test method of the current line.

unite-sources

TargetSource
Controllercake_controller
Modelcake_model
View of the current controllercake_view
View of the specified controllercake_view:{controller-name}
Configcake_config
Componentcake_component
Behaviorcake_behavior
Helpercake_helper
Shellcake_shell
Taskcake_task
Fixturecake_fixture
Cake Core librarycake_core
1st party librarycake_lib

添加新评论