file-magic.vim


Ⅰ. 插件描述

Create files quickly with some magic

Ⅱ. 基本信息

创建日期:  2015-06-13
使用用户:  1
Github星:  0
插件作者:  Oleg Voronkovich

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/voronkovich/file-magic.vim

Ⅳ. 文档说明

# Vim file magic

Vim plugin for quick creating files.

Basic usage

Suppose that you have added this magic spells into you .vimrc:

" Note %s in strings?
let g:file_magic_spells = {
    \ 'apachevhost': '/etc/apache2/sites-available/%s.conf',
    \ 'sfview': 'app/Resources/views/%s.html.twig',
    \ 'sfcontroller': 'src/AppBundle/Controller/%sController.php',
    \ 'tmp': '/tmp/%s/%s.txt'
\ }

Now if you run a command:

:FileMagic sfview user/login

you will get a file app/Resources/views/user/login.html.twig opened in the Vim.

Installation

For creating parent directories this plugin requires easydir, vim-mkdir or another plugin with the same features.

Using pathogen

git clone https://github.com/voronkovich/file-magic.vim.git ~/.vim/bundle/file-magic.vim

Using vundle

Add to your .vimrc:

Bundle 'voronkovich/file-magic.vim'

Configuration

Setting a default command for opening a created file:

g:file_magic_open_command = 'vsplit' " 'e' by default

Setting the FileMagic command alias:

g:file_magic_command_alias = 'Create'

Add callback function instead of a spell string:

g:file_magic_spells = {
    \ 'note': '!CreateNote'
\ }

...

" a:key will be equal 'note'
fun! CreateNote(key, title)
    return printf('~/notes/%s-%s.txt', a:title, strftime('%FT%T%z'))
endfun

License

Copyright (c) Voronkovich Oleg. Distributed under the same terms as Vim itself.
See :help license.

添加新评论