天天看點

用Sublime Text中的實際新行替換\\ n

本文翻譯自:Replace \n with actual new line in Sublime Text

How can I replace

\\n

in Sublime Text with real in-editor displayed new line so:

如何用實際的編輯器顯示的新行替換Sublime Text中的

\\n

,是以:
foo\nbar
           

becomes:

變成:
foo
bar
           

in the editor when I view the file in it.

在編輯器中檢視檔案時。

#1樓

參考:https://stackoom.com/question/1O53u/用Sublime-Text中的實際新行替換-n

#2樓

使用

Find > Replace

或( Ctrl + H )打開“

Find What

/

Replace With

視窗,然後使用Ctrl + Enter在“

Replace With

輸入框中訓示新行。

#3樓

Turn on Regex Search and Replace (icon most to the left in search and replace bar or shortcut Alt + R )

打開正規表達式搜尋和替換(搜尋和替換欄或快捷鍵Alt + R中最左側的圖示)

Find What:

\\\\n

查找内容:

\\\\n

Replace with:

\\n

替換為:

\\n

Cheers

幹杯

#4樓

In Sublime Text (with shortcuts on Mac):

在Sublime Text中(在Mac上為快捷方式):
  1. Highlight the text that you want to search to apply Find & Replace 突出顯示要搜尋以應用“查找和替換”的文本
  2. Go to Menu > Find > Replace... (Keyboard Shortcut: Alt + Command + F) 轉到菜單>查找>替換...(鍵盤快捷鍵:Alt + Command + F)
  3. In the Find & Replace tool, enable Regular Expression by clicking on the button which looks like [.*] (Keyboard Shortcut: Alt + Command + R) 在“查找和替換”工具中,通過單擊看起來像[。*]的按鈕來啟用正規表達式(鍵盤快捷鍵:Alt + Command + R)
  4. In Find What, type:

    \\\\n

    在“查找内容”中,鍵入:

    \\\\n

    Note: The additional

    \\

    escapes the Regular Expression syntax when searched. 注意:搜尋時,附加

    \\

    轉義正規表達式文法。
  5. In Replace With, type:

    \\n

    在“替換為”中,鍵入:

    \\n

  6. Click on the 'Replace All' button (Keyboard Shortcut: CTRL + Alt + Enter) 單擊“全部替換”按鈕(鍵盤快捷鍵:CTRL + Alt + Enter)

Your literal text

\\n

will then turn into an actual line break.

您的文字文本

\\n

将變成實際的換行符。

#5樓

Fool proof method (no RegEx and Ctrl + Enter didn't work for me as it was just jumping to next

Find

):

簡便的方法 (沒有RegEx和Ctrl + Enter對我不起作用,因為它隻是跳轉到下一個

Find

):

First, select an occurrence of

\\n

and hit Ctrl + H (brings up the

Replace...

dialogue, also accessible through

Find -> Replace...

menu).

首先,選擇一個

\\n

并按Ctrl + H (彈出“

Replace...

對話框,也可以通過“

Find -> Replace...

菜單進行通路)。

This populates the

Find what

field.

這将填充“

Find what

字段。

Go to the end of any line of your file (press End if your keyboard has it) and select the end of line by holding down Shift and pressing → (right arrow) EXACTLY once.

轉到檔案任何行的末尾(如果有鍵盤,請按End ( 結束 )),然後按住Shift并完全按一次→ (向右箭頭)以選擇行尾。

Then copy-paste this into the

Replace with

field.

然後将其複制粘貼到“

Replace with

字段中。

(the animation is for finding true new lines; works the same for replacing them)

(動畫用于查找真正的新行;替換它們的工作原理相同)
用Sublime Text中的實際新行替換\\ n

#6樓

None of the above worked for me in Sublime Text 2 on Windows.

在Windows上的Sublime Text 2中,上述方法都不适合我。

I did this:

我這樣做:
  • click on an empty line; 單擊一個空行;
  • drag to the following empty line (selecting the invisible character after the line); 拖動到以下空行(選擇該行後的不可見字元);
  • press ctrl+H for replace; 按ctrl + H進行替換;
  • input desired replacement character/string or leave it empty; 輸入所需的替換字元/字元串或将其留白;
  • click "Replace all"; 點選“全部替換”;

By selecting before hitting ctrl+H it uses that as the character to be replaced.

通過在按下ctrl + H之前進行選擇,它将使用該字元作為要替換的字元。