您是否尝试过以下操作?
:g/pdb.set_trace()/norm I#
该:global
命令在每个匹配行上执行搜索模式之后的命令。
:g/foo/d <-- deletes every line containing foo
该:normal
命令允许您从命令行或脚本执行正常模式命令。
:norm I# <-- inserts a # before the first printable character of the current line
见:help :global
和:help :normal
。