Ⅰ. 插件描述
Vim plugin for high-level file type management.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'adityaramesh/smartfile'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'adityaramesh/smartfile'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'adityaramesh/smartfile'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/adityaramesh/smartfile
Ⅳ. 文档说明
<!--
-- File Name: README.md
-- Author: Aditya Ramesh
-- Date: 08/10/2012
-- Contact: _@adityaramesh.com
--->
Introduction
Smartfile is a Vim plugin that allows you to automate file-specific actions
like:
- Generating headers
- Setting the line and block comments
- Changing the default identation mode
- Setting the default position of the cursor
The same JSON files are used to define behavior across all file types. So
a C++ header might look like this:
/*
** File Name: test.cpp
** Author: Jane Doe
** Date: 08/10/2012
** Contact: jane@doe.com
*/
The equivalent HTML header might look like this:
<!--
-- File Name: test.html
-- Author: Jane Doe
-- Date: 08/10/2012
-- Contact: jane@doe.com
--->
Consult the documentation for more details and some
examples.
Features
Each time a buffer is entered, the following actions can be configured:
- File extensions associated with file type.
- A new filetype, if the default filetype is not desired (e.g.
.lessfiles
- be treated as
.cssfiles).
- Line and block comment characters so that word wrapping using
gqworks
properly. - Default indentation.
Each time a new file is created, the following actions can be configured:
- Format of the header.
- Default content (e.g. for C++ header files, automatically insert include
- using
uuidgen).
- Position of the carat (by executing a predetermined Vim command).
These settings are specified by the configuration files located in~/smartfile. Many of these settings (e.g. the file header structure) will be
the same for most of file types that you will edit. Smartfile allows you to
define global settings in your .vimrc file, and override these settings on a
per-filetype basis, when you desire specialized behavior.
Smartfile also allows you to define new keys that map to custom actions, and use
these keys in the configuration file. Further details are provided in the
documentation.
Prerequisites
Vim needs to be configured with support for Python 3 in order for Smartfile to
- You can check if this is the case by examining the output of
:version, - checking to ensure that it has
+python3or+python3/dyn. If your version
of Vim does not have support for Python 3, you have the following options:
- If your package manager has a variant of Vim with support for Python 3,
- this variant, and set this variant as your active Vim version.
- Compile Vim from the sources. Make sure that you supply the following flags
you run
./configure:--with-pythoninterp(for Python 2 support)--with-python3interp(for Python 3 support)
You may also have to specify the paths to the Python configuration directories
using:
- `--with-python-config-dir` (for Python 2)
- `--with-python3-config-dir` (for Python 3)
Installation
This package requires Vundle. If you do not have Vundle installed already, you
can get it here. Then, add
Bundle 'adityaramesh/smartfile'
to your list of repositories in .vimrc. The next time you start up Vim, use:BundleInstall to have Vundle install Smartfile.
Uninstallation
Remove
Bundle 'adityaramesh/smartfile'
from your .vimrc, and remove ~/.vim/bundle/smartfile.