在 Notepad++ 中每 x 个字符添加一个换行符

Adding a line break every x characters in Notepad++

我想做什么

在书面文本中大约每隔 x 个字符添加换行符,而不打断单词。如果我可以在每个换行符后添加“#”,那就太好了。我一般都是用Notepad++来操作这样的文字。

示例:

set the random seed to 144 and use sample.split function to select the 70% of observations for the training set

变成

# set the random seed to 144 and use sample.split function 
# to select the 70% of observations for the training set

我为什么要做

我在 Rstudio 工作,有时会将已经编写的文本中的注释粘贴到我的代码中。

我试过的

我是空白的。我只是手动执行此操作,但我意识到通过自动化此过程可以节省大量时间。

你可以在Notepad++上为此录制一个宏。 我会在录制时遵循这些步骤。

  1. 将光标放在开头。
  2. 将光标向右移动 70 次(使用右箭头)
  3. 当您到达第 70 个字符时,按 ControlRight Arrow 键。
  4. 这将使光标跳到下一个单词的开头。
  5. #Enter

停止宏并回放。

或者您可以使用 this 之类的东西。它完全符合您的要求。