Notepad ++添加到每一行

本文翻译自:Notepad++ add to every line

I'm using Notepad++ and I can't figure this out : 我正在使用Notepad ++而我无法解决这个问题:

I have numerous lines all starting with http . 我有很多行都以http开头。 I need to add some text in front of it in every line. 我需要在每行中添加一些文本。 Also, I need to add different text to the end of each line. 另外,我需要在每行的末尾添加不同的文本。 Each line ends differently. 每条线的结尾都不同。

What is the fastest way to add text to the start and end of each line? 在每行的开头和结尾添加文本的最快方法是什么?


#1楼

参考:https://stackoom.com/question/kAa1/Notepad-添加到每一行


#2楼

Follow these steps: 跟着这些步骤:

  1. Press Ctrl + H to bring up the Find/Replace Dialog. Ctrl + H以显示“查找/替换”对话框。
  2. Choose the Regular expression option near the bottom of the dialog. 选择对话框底部附近的Regular expression选项。

To add a word, such as test , at the beginning of each line: 要在每行的开头添加一个单词,例如test

  1. Type ^ in the Find what textbox Find what文本框中键入^
  2. Type test in the Replace with textbox Replace with文本框中键入test
  3. Place cursor in the first line of the file to ensure all lines are affected 将光标放在文件的第一行以确保所有行都受到影响
  4. Click Replace All button 单击Replace All按钮

To add a word, such as test , at the end of each line: 要在每行的末尾添加一个单词,例如test

  1. Type $ in the Find what textbox Find what文本框中键入$
  2. Type test in the Replace with textbox Replace with文本框中键入test
  3. Place cursor in the first line of the file to ensure all lines are affected 将光标放在文件的第一行以确保所有行都受到影响
  4. Click Replace All button 单击Replace All按钮

#3楼

Notepad++ has a very powerful editing capability. Notepad ++具有非常强大的编辑功能。 (Today I'm searching for the similar function in Sublime Text), but for Notepad++, just hold Alt when you drag the mouse. (今天我在Sublime Text中搜索类似的功能),但对于Notepad ++,只需在拖动鼠标时按住Alt键 What you type will then replace the selected column on every line. 然后,您键入的内容将替换每行上的选定列。 To insert without replacing existing text, use Alt-Shift . 要在不替换现有文本的情况下插入,请使用Alt-Shift

在此输入图像描述


#4楼

  1. Move your cursor to the start of the first line 将光标移动到第一行的开头
  2. Hold down Alt + Shift and use the cursor down key to extend the selection to the end of the block 按住Alt + Shift并使用向下光标键将选择范围扩展到块的末尾

This allows you to type on every line simultaneously. 这允许您同时键入每一行。

I found the solution above here . 我在这里找到了解决方案。

I think this is much easier than using regex. 我认为这比使用正则表达式容易得多。


#5楼

Open Notepad++, then click Ctrl + F . 打开Notepad ++,然后单击Ctrl + F.

Choose Regular Expression 选择正则表达式

*Find What: "^" (which represents index of the each line - "PREFIX"). *查找内容:“^”(表示每行的索引 - “PREFIX”)。

Replace with : "anyText"* 替换为:“anyText”*

在此输入图像描述

For Suffix on each line: Follow the same steps as above "Replace ^ with $" . 对于每行的后缀 :按照上面“使用$替换^”中的相同步骤操作。 That's it. 而已。


#6楼

You can automatically do it in Notepad++ (add text at the beginning and/or end of each line) by using one regular expression in Replace ( Ctrl + H ): 您可以在Notepad ++中自动执行此操作 (在每行的开头和/或末尾添加文本) ,使用 Replace( Ctrl + H )中的一个正则表达式

在此输入图像描述

Explanation: Expression $1 in Replace with input denotes all the characters that include the round brackets (.*) in Find what regular expressin. 说明: 替换为输入中的表达式$1表示在查找常规表达式中包含圆括号(.*)所有字符。

Tested, it works. 经测试,它的工作原理。

Hope that helps. 希望有所帮助。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值