How to replace space character with line break(LF) in emacs? - emacs

I want to use "replace-string" command to achieve this function,
but how to type in "LF" character?
it's confuse me so much...

You can use C-q C-j to search/replace a newline

Related

Replace x/y/z to x&z with Emacs?

I have a large file like this:
x/y/z
x2/y2/z2
...
How can I use Emacs's replace to change them to
x&z
x2&z2
so the '/y/' part is changed to '&'?
Assuming that you need to replace /y/ or /y1/ or /xxx/ to &, you can use replace-regexp.
M-x replace-regexp <RET> /.*/ <RET> & <RET>
This will replace the strings including slashes of both sides to &.
You can also use query-replace-regexp to replace the matched strings interactively.

join all lines in a text file in emacs

I have a large text file. Each sentence is on a separate line and I ant to join them all together in emacs. DOes anyone know how to do this. Somebody has told me I can use M-^ but this only joins one line to the one above one at a time and I have hundreds of lines. Help!
You can replace newlines with an empty string. Move the cursor to the beginning of your file and execute this sequence
M-x replace-string C-q C-j RET RET
You can replace with query replace, pasting the newline.
mark/copy a newline
start at beginning of buffer
Alt-%
paste the newline and do enter. (for me the buffer says Query replace ^J with: )
type space + enter
type ! for accept all or y/n for accept/reject per match

What is the canonical command to remove newlines within a paragraph?

Is there some command I am missing? Something like M-q (fill-paragraph)? Otherwise I do M-% C-q C-j Return Space Return.
The command you're looking for is unfill-paragraph; there's also unfill-region.

How to replace '_' by space in emacs

I have a text file which I am only able to look that there is an underscore between some words only using emcas editor but not other editors such as vi. I do not know how to use emacs but I wanted to replace these underscores "_" by space in the emacs editor automated fashion. How can I do that ?
I believe that those underscore aren't really underscore, but non breaking space (U+00A0 unicode char), that Emacs show as underscore with a different color. You probably don't need to replace them, but if this is really needed, just use M-x replace-string and kill and yank one of those non-breaking space in the string to be replaced.
Hit the M-x key-combination (that is, hold meta key - alt on windows - and hit x) type replace-string and hit enter. You can then type [underscore] enter [space] enter.
In Emacs notation:
M-x replace-string RET _ RET " "
Should the previous answer not solve it: Remember that as a coding system error. Check with C-x = if it's char 95.
If not, check variables coding-system-for-read, coding-system-for-write, buffer-file-coding-system
Finally, get emacs core developers at help-gnu-emacs#gnu.org

How to write comma character in a SLIME EMACS window

How can I write a "," (comma) character in the SLIME emacs window? The , key brings up the SLIME command prompt automatically.
Thanks, a Lisp beginner
, only triggers REPL shortcut selection when input at the beginning of a line. In all other cases, you can input a comma by typing ,.
In the case of Common Lisp, since as long as you don't modify the reader, , can only occur within a quasi-quoted expression, this should not be a significant restriction.
If it really is a problem, refer to Deokhwan Kim's answer.
You can insert , by C-q, (Control-q and then comma). C-q is bound to quoted-insert, which can be generally used whenever you want Emacs to read a next input character and insert it instead of invoking a command bound to the input character.