vim-simpledb


Ⅰ. 插件描述

Execution of postgresql or mysql commands from vim buffer

Ⅱ. 基本信息

创建日期:  2011-11-06
使用用户:  27
Github星:  74
插件作者:  Ivan Tkalin

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

# vim-simpledb

Vim plugin to execute postgresql or mysql commands from VIM buffer

Installation

Pathogen

If you use git submodules, run this command from your .vim folder:

git submodule add https://github.com/ivalkeen/vim-simpledb bundle/simpledb

Otherwise, , run this command from your .vim folder:

git clone https://github.com/ivalkeen/vim-simpledb bundle/simpledb

Vundle

Add this line to your vimrc

Bundle 'ivalkeen/vim-simpledb'

Usage

Default key mapping for execution: <enter>.

  1. Create new file with .sql extension (without extensions, mapping would not work)
  2. Create first line with commented parameters:

    for psql:

    -- -h localhost -U postgres -d my_database

    or for mysql:

    -- db:mysql -D my_database -u root

    Note: if you don't want to enter password each time, you should create .pgpass (.my.cnf for mysql) file

    There is also usefull key -q to avoid messages like 'Timing is on' etc.

  3. Add sql statements to your file
  4. Hit <enter> to execute all not commented queries
  5. Hit <leader><enter> to execute all queries in the current paragraph
  6. Select multiple lines in visual mode and hit <enter> to execute just those queries

Configuration

If you do not want timings to be displayed, add this to your .vimrc:

let g:simpledb_show_timing = 0

If you want to customize the key mappings,
set the variable simpledb_use_default_keybindings to 0 and add your own mappings in ~/.vimrc.
For example, to execute a sql statement by pressing "ctrl-q" instead of "enter",
add the following:

let g:simpledb_use_default_keybindings=0
vnoremap <buffer> <c-q> :SimpleDBExecuteSql<cr>
nnoremap <buffer> <c-q> m':SimpleDBExecuteSql <cr>g`'
nnoremap <buffer> <leader><c-q> m':'{,'}SimpleDBExecuteSql<cr>g`'

If you have any questions, mail me

TODO

  1. Rewrite code to match vim script conventions
  2. Intellisense

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Self-Promotion

If you like this project, please follow the repository on GitHub. Also, you might consider visiting my blog and following me on Twitter and Github.

添加新评论