How can I replace \n
in Sublime Text with real in-editor displayed new line so:
我怎样才能用真正的编辑器来取代\n,显示出新的线条:
foo\nbar
becomes:
就变成:
foo
bar
in the editor when I view the file in it.
在编辑器中,当我查看文件的时候。
5 个解决方案
#1
572
Turn on Regex Search and Replace (icon most to the left in search and replace bar or shortcut Alt + R)
打开Regex搜索和替换(在搜索和替换栏或快捷键Alt + R中最左边的图标)
Find What: \\n
Replace with: \n
查找:\\n Replace with: \n。
Cheers
干杯
#2
193
Use Find > Replace
, or (Ctrl+H), to open the Find What
/Replace With
Window, and use Ctrl+Enter to indicate a new line in the Replace With
inputbox.
使用Find >替换,或者(Ctrl+H),打开找到/替换的窗口,并使用Ctrl+Enter来表示用inputbox替换的新行。
#3
33
Fool proof method (no RegEx and Ctrl+Enter didn't work for me as it was just jumping to next Find
):
傻瓜证明方法(没有RegEx和Ctrl+Enter对我来说不适合,因为它只是跳转到下一个发现):
First, select an occurrence of \n
and hit Ctrl+H (brings up the Replace...
dialogue, also accessible through Find -> Replace...
menu). This populates the Find what
field.
首先,选择发生\n并按Ctrl+H(弹出替换…对话,也可通过Find ->替换…菜单)。这填充了查找字段。
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. Then copy-paste this into the Replace with
field.
去任何线的最后文件(如果你的键盘有新闻结束)并选择线通过压低转变和紧迫→(右箭头)是一次。然后复制粘贴到替换字段中。
(the animation is for finding true new lines; works the same for replacing them)
(动画是寻找真正的新线条;用同样的方法替换它们)
#4
11
In Sublime Text (with shortcuts on Mac):
崇高的文本(在Mac上有捷径):
-
Highlight the text that you want to search to apply Find & Replace
突出显示您想要搜索的文本来应用查找和替换。
-
Go to Menu > Find > Replace... (Keyboard Shortcut: Alt + Command + F)
到菜单>找到>替换…(键盘快捷键:Alt + Command + F)
-
In the Find & Replace tool, enable Regular Expression by clicking on the button which looks like [.*] (Keyboard Shortcut: Alt + Command + R)
在Find & Replace工具中,通过单击看起来像[的按钮]来启用正则表达式。*](键盘快捷键:Alt + Command + R)
-
In Find What, type:
\\n
在找到什么,类型:\\n。
Note: The additional
\
escapes the Regular Expression syntax when searched.注意:当搜索时,额外的\会转义正则表达式语法。
-
In Replace With, type:
\n
在替换时,键入:\n。
-
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
5
None of the above worked for me in Sublime Text 2 on Windows.
以上这些都没有在Windows上为我工作。
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键之前选择,将其作为要替换的字符。
#1
572
Turn on Regex Search and Replace (icon most to the left in search and replace bar or shortcut Alt + R)
打开Regex搜索和替换(在搜索和替换栏或快捷键Alt + R中最左边的图标)
Find What: \\n
Replace with: \n
查找:\\n Replace with: \n。
Cheers
干杯
#2
193
Use Find > Replace
, or (Ctrl+H), to open the Find What
/Replace With
Window, and use Ctrl+Enter to indicate a new line in the Replace With
inputbox.
使用Find >替换,或者(Ctrl+H),打开找到/替换的窗口,并使用Ctrl+Enter来表示用inputbox替换的新行。
#3
33
Fool proof method (no RegEx and Ctrl+Enter didn't work for me as it was just jumping to next Find
):
傻瓜证明方法(没有RegEx和Ctrl+Enter对我来说不适合,因为它只是跳转到下一个发现):
First, select an occurrence of \n
and hit Ctrl+H (brings up the Replace...
dialogue, also accessible through Find -> Replace...
menu). This populates the Find what
field.
首先,选择发生\n并按Ctrl+H(弹出替换…对话,也可通过Find ->替换…菜单)。这填充了查找字段。
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. Then copy-paste this into the Replace with
field.
去任何线的最后文件(如果你的键盘有新闻结束)并选择线通过压低转变和紧迫→(右箭头)是一次。然后复制粘贴到替换字段中。
(the animation is for finding true new lines; works the same for replacing them)
(动画是寻找真正的新线条;用同样的方法替换它们)
#4
11
In Sublime Text (with shortcuts on Mac):
崇高的文本(在Mac上有捷径):
-
Highlight the text that you want to search to apply Find & Replace
突出显示您想要搜索的文本来应用查找和替换。
-
Go to Menu > Find > Replace... (Keyboard Shortcut: Alt + Command + F)
到菜单>找到>替换…(键盘快捷键:Alt + Command + F)
-
In the Find & Replace tool, enable Regular Expression by clicking on the button which looks like [.*] (Keyboard Shortcut: Alt + Command + R)
在Find & Replace工具中,通过单击看起来像[的按钮]来启用正则表达式。*](键盘快捷键:Alt + Command + R)
-
In Find What, type:
\\n
在找到什么,类型:\\n。
Note: The additional
\
escapes the Regular Expression syntax when searched.注意:当搜索时,额外的\会转义正则表达式语法。
-
In Replace With, type:
\n
在替换时,键入:\n。
-
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
5
None of the above worked for me in Sublime Text 2 on Windows.
以上这些都没有在Windows上为我工作。
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键之前选择,将其作为要替换的字符。