2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SQLをPHPの文字リテラルに変換するVimスクリプト

2
Posted at
"SQLのPHP文字リテラルへの整形
function! SQLToPHP()
  %s/^\(.\+\)$/"\1 " \./g
  normal G$
  execute "normal ?.<CR>"
  normal xxggVG
  echo "Convert to PHP String is finished."
endfunction
command! Sqltop :call SQLToPHP()

function! SQLFromPHP()
  %s/^"\(.\+\) " *\.*$/\1/g
  normal ggVG
  echo "Convert from PHP String is finished."
endfunction
command! Sqlfromp :call SQLFromPHP()

http://www.vim.org/scripts/script.php?script_id=294
https://github.com/vim-scripts/SQLUtilities

以上2つのプラグインを入れて、選択後。
:SQLUFormatter
をしたりするのと組み合わせるととても便利。
ORMを使おうという話はとりあえずおいておいて...。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?