Ⅰ. 插件描述
PGSQL syntax highlighting, etc.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'prosumma/vim-pgsql'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'prosumma/vim-pgsql'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'prosumma/vim-pgsql'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/prosumma/vim-pgsql
Ⅳ. 文档说明
Opinionated Syntax Highlighting For PostgreSQL In Vim!
I started with Devrim Gunduz' psql.vim at http://www.gunduz.org/postgresql/pgsql.vim, but very little of that remains. This is PG highlighting the way I use it. It may be useful to you, it may not. I suspect it will work very well for most, and if not, it's not too hard to fork.
Some improvements:
Syntax Highlighting For Function Bodies
CREATE FUNCTION foo(_x INTEGER) RETURNS INTEGER
STRICT IMMUTABLE
AS $$
BEGIN
RETURN _x;
END;
$$;
The text inside the $$ delimiters will be highlighted. Of course, the syntax highlighting is _always_ more PostgreSQL highlighting, since that's all I ever use. (I've considered conventions such as $PYTHON$ or $PGSQL$ with $PGSQL$ being the default, but since I don't use Python in PG, I never had the motivation.)
A Broader Set Of Keywords
I've done a good, but probably imperfect job of adding far more keywords and trying to get them to work contextually.
Variables
One of the things I've always liked about Microsoft's SQL Server is the @ sigil it uses for variables. This makes them stand out and prevents collisions with field names. Sadly, PG has no such sigil, and its parser won't allow you to use one. As a compromise, I always prefix my variables with an underscore, e.g., _foo. If you do this, you will get syntax highlighting for variables. They will stand out nicely, depending upon your color scheme.