「SQL Statement indentation good practice」似乎是寫入SQL塊的可接受格式。可以VIM autoindent SQL嗎?
是否存在符合此標準的Vim縮進/語法文件,或者至少關閉?
目前我的Vim幾乎離開了所有的東西,只縮進了某些關鍵字。
「SQL Statement indentation good practice」似乎是寫入SQL塊的可接受格式。可以VIM autoindent SQL嗎?
是否存在符合此標準的Vim縮進/語法文件,或者至少關閉?
目前我的Vim幾乎離開了所有的東西,只縮進了某些關鍵字。
「SQLUtilities : SQL utilities - Formatting, generate - columns lists, procedures for databases」有SQL Utilities插件,它是有能力的。和「How to auto-format and auto-capitalize SQL in Vim」是一個相關的討論。
被Vim安裝Python模塊sqlparse
pip install sqlparse
可以使用
:%!sqlformat --reindent --keywords upper --identifiers lower -
爲了不附加快捷,PT我添加以下配置我的.vimrc配置文件:
autocmd FileType sql call SqlFormatter()
augroup end
function SqlFormatter()
set noai
" set mappings...
map ,pt :%!sqlformat --reindent --keywords upper --identifiers lower -<CR>
endfunction
您可以自定義sqlformat一點。見
sqlformat --help
可以使用vim-autoformat插件:
vim-autoformat
(我比較喜歡輕便vim-plug)sqlparse
與pip
noremap <F3> :Autoformat<CR>
let g:formatdef_sql = '"sqlformat --reindent --keywords upper - identifiers lower -"'
let g:formatters_sql = ['sql']
如果你看到這條消息:vim has no support for python
,你應該用Python支持重建你的vim或者neovim