是否有解决方案可以从软件中添加特殊字符以及如何操作

Jam*_*s78 0 text-editors patch

我有一个问题想问你,你知道是否有一个程序/软件可以轻松地向所有行添加字符?例如,如果我想+在这些行的前面添加并且不想逐一添加,可以吗?

+CONFIG_PACKAGE_git=y
+CONFIG_PACKAGE_git-http=y
+CONFIG_PACKAGE_htop=y
CONFIG_PACKAGE_https-dns-proxy=y
CONFIG_PACKAGE_ip-full=y
CONFIG_PACKAGE_ip6tables-nft=y
CONFIG_PACKAGE_iperf3=y
CONFIG_PACKAGE_iptables-mod-conntrack-extra=y
CONFIG_PACKAGE_iptables-mod-ipopt=y
CONFIG_PACKAGE_iptables-nft=y
CONFIG_PACKAGE_irqbalance=y
CONFIG_PACKAGE_kmod-crypto-authenc=y
CONFIG_PACKAGE_kmod-crypto-cbc=m
CONFIG_PACKAGE_kmod-crypto-cts=m
CONFIG_PACKAGE_kmod-crypto-deflate=m
CONFIG_PACKAGE_kmod-crypto-des=m
CONFIG_PACKAGE_kmod-crypto-lib-chacha20=y
CONFIG_PACKAGE_kmod-crypto-lib-chacha20poly1305=y
CONFIG_PACKAGE_kmod-crypto-lib-curve25519=y
CONFIG_PACKAGE_kmod-crypto-lib-poly1305=y
CONFIG_PACKAGE_kmod-crypto-md5=m
CONFIG_PACKAGE_kmod-crypto-sha1=m
CONFIG_PACKAGE_kmod-crypto-sha512=m
CONFIG_PACKAGE_kmod-crypto-xts=m
CONFIG_PACKAGE_kmod-cryptodev=y
CONFIG_PACKAGE_kmod-ifb=y
CONFIG_PACKAGE_kmod-ip6tables=y
CONFIG_PACKAGE_kmod-ipt-conntrack=y
CONFIG_PACKAGE_kmod-ipt-conntrack-extra=y
CONFIG_PACKAGE_kmod-ipt-core=y
CONFIG_PACKAGE_kmod-ipt-ipopt=y
CONFIG_PACKAGE_kmod-ipt-ipset=y
CONFIG_PACKAGE_kmod-lib-zlib-deflate=m
CONFIG_PACKAGE_kmod-lib-zlib-inflate=m
# CONFIG_PACKAGE_kmod-mwifiex-sdio is not set
CONFIG_PACKAGE_kmod-nf-conncount=y
CONFIG_PACKAGE_kmod-nf-conntrack-netlink=y
CONFIG_PACKAGE_kmod-nf-ipt=y
CONFIG_PACKAGE_kmod-nf-ipt6=y
CONFIG_PACKAGE_kmod-nf-nat6=y
CONFIG_PACKAGE_kmod-nft-compat=y
CONFIG_PACKAGE_kmod-sched-cake=y
CONFIG_PACKAGE_kmod-sched-connmark=y
CONFIG_PACKAGE_kmod-sched-core=y
CONFIG_PACKAGE_kmod-tun=y
CONFIG_PACKAGE_kmod-udptunnel4=y
CONFIG_PACKAGE_kmod-udptunnel6=y
CONFIG_PACKAGE_kmod-wireguard=y
CONFIG_PACKAGE_libatomic=y
CONFIG_PACKAGE_libattr=y
CONFIG_PACKAGE_libavahi-client=y
CONFIG_PACKAGE_libavahi-dbus-support=y
CONFIG_PACKAGE_libbpf=y
CONFIG_PACKAGE_libbz2=y
Run Code Online (Sandbox Code Playgroud)

spi*_*hie 7

使用 Notepad++ 或 Sublime Text 等工具。

将光标置于第一行的开头(第 1 行,第 1 列)。按住Shift+ Alt,然后单击最后一行的开头(第 54 行,第 1 列)。您应该在左边框上看到一个跨越所有行的闪烁光标。

现在按+,按键将在所有选定的行上重复。

这适用于大多数文本编辑器和 SQL Server Management Studio,但不适用于常规 Notepad.exe 或 Wordpad.exe(本机 Windows 文本编辑器)。

另请参阅https://techcommunity.microsoft.com/t5/core-infrastruct-and-security/quick-tip-shift-alt-for-multiple-line-edits/ba-p/371355


dav*_*man 7

是的,有很多很多方法可以做到这一点,具体取决于您要寻找的内容。

sed -i -E 's/^(.*)$/\+\1/' file.txt
Run Code Online (Sandbox Code Playgroud)

会在 file.txt 中的每一行前面添加一个 + 这字面意思是:

for each line in file.txt
    take the passage of any characters between the beginning and end of the line
    and replace it with the same passage with a + prepended
Run Code Online (Sandbox Code Playgroud)

正如评论中指出的,这可以最小化为:

sed -i 's/^/+/' file.txt
Run Code Online (Sandbox Code Playgroud)

这翻译成Replace the beginning of every line with a +

如果你想要更具选择性和交互性,Ivim 中的编辑操作会从行首开始编辑。将其与.此处重复上次编辑结合起来。这样做时,您可以在一行中添加一个加号,单击“转义”,然后您可以向下箭头指向.每行上的其他行,无论您向行上的哪个位置箭头以 开始该行+

  • 为什么不简单地使用`'s/^/+/'`? (那么你甚至不需要`-E`。) (5认同)

Aus*_*arn 5

大多数专为处理源代码而设计的优秀文本编辑器(Nodepad++、Sublime Text、VSCode、Vim、EMACS 等)都具有强大的搜索和替换语法,允许在行开头作为搜索表达式的一部分进行匹配。这是所谓的搜索模式中正则表达式支持的一部分。

\n

在大多数此类编辑器中,简单的^搜索模式和 a+作为替换文本将完全按照您在问题中描述的方式进行操作(例如,在 Vim 中就是如此:%s/^/+/)。

\n

但是,您可能想要的(仅将加号添加到 \xe2\x80\x99t 空的行,并且 don\xe2\x80\x99t 以 a#或开头+)相当棘手,并且确切的语法略有不同。对于 VSCode,您需要^([^#+])搜索模式和+$1替换文本。对于 Vim 来说,它(通常)是:%s/^\\([^#+]\\)/+\\1/. 其他编辑器可能有自己的语法。

\n