使用VIM可视块连接块
我尝试使用VIM通过连接字符串块来构建SQL查询。例如,我在VIM的三个选项卡中有以下字符串:使用VIM可视块连接块,vim,Vim,我尝试使用VIM通过连接字符串块来构建SQL查询。例如,我在VIM的三个选项卡中有以下字符串: # block one where c = '123' where c = '2345' ... # block two set b = 12 set b = 345 ... # block three update myTable set a = 'abc', update myTable set a = '23423', ... 每个块包含100行(SQL查询片段)。我想将这些块
# block one
where c = '123'
where c = '2345'
...
# block two
set b = 12
set b = 345
...
# block three
update myTable set a = 'abc',
update myTable set a = '23423',
...
每个块包含100行(SQL查询片段)。我想将这些块连接到一个完整的SQL查询中:块一+块二+块三(100行),如下所示:
# sql queries
update myTable set a = 'abc', set b = 12 where c = '123'
update myTable set a = '23423', set b = 345 where c = '2345'
...
忽略第一行,它只是为了解释。我认为可视块可以用于:
ctrl-v
)吗?它们必须是相同宽度的线,但它可以工作
您可能需要做一些更改,但希望它至少能给您一些想法。您是否尝试过Visual blockwise(ctrl-v
)?它们必须是相同宽度的线,但它可以工作
您可能需要做一些更改,但希望它至少能给您一些想法。我认为使用一个简短的脚本(python,或者可能是bash)可以更轻松地完成这项工作。另外,您应该使用参数化查询,而不是字符串串联,因为发送普通字符串会使您面临sql注入攻击。我认为使用短脚本(python,或者可能是bash)可以更容易地做到这一点。另外,您应该使用参数化查询,而不是字符串串联,因为发送普通字符串会使您面临sql注入攻击。是的。我先拖动块,然后P将块粘贴到要插入文本块的位置。谢谢对我先拖动块,然后P将块粘贴到要插入文本块的位置。谢谢
# Yank the lines from the other file
gg V G
# Add whitespace to the end
:%s/$/ /
# Select the whitespace at the end of the other file, and paste it
gg $ ctrl-v $ p