all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Replace all tab characters in buffer with newline
@ 2014-01-15 16:41 Angus Comber
  2014-01-15 16:47 ` Guido Van Hoecke
  2014-01-15 16:51 ` Angus Comber
  0 siblings, 2 replies; 4+ messages in thread
From: Angus Comber @ 2014-01-15 16:41 UTC (permalink / raw)
  To: help-gnu-emacs

I have eg:

text1<tab>text2<tab>text3
text4<tab>text5<tab>text6

I want to transform into:

text1
text2
text3
text4
text5
text6


Using c-m-% I tried this:

c-m=% Used C-Q for quorted then entered tab key on keyboard

For replacement I used C-Q (quoted) then entered <enter> key

But then I end up with:

text1^Mtext2^Mtext3
text4^Mtext5^Mtext6

How should I have done it?

Platform is Windows by the way.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Replace all tab characters in buffer with newline
  2014-01-15 16:41 Replace all tab characters in buffer with newline Angus Comber
@ 2014-01-15 16:47 ` Guido Van Hoecke
  2014-01-15 16:51 ` Angus Comber
  1 sibling, 0 replies; 4+ messages in thread
From: Guido Van Hoecke @ 2014-01-15 16:47 UTC (permalink / raw)
  To: Angus Comber; +Cc: help-gnu-emacs

On 15 January 2014 17:41, Angus Comber <anguscomber@gmail.com> wrote:
> I have eg:
>
> text1<tab>text2<tab>text3
> text4<tab>text5<tab>text6
>
> I want to transform into:
>
> text1
> text2
> text3
> text4
> text5
> text6
>
>
> Using c-m-% I tried this:
>
> c-m=% Used C-Q for quorted then entered tab key on keyboard
>
> For replacement I used C-Q (quoted) then entered <enter> key

Try C-Q C-J instead of C-Q <enter>

>
> But then I end up with:
>
> text1^Mtext2^Mtext3
> text4^Mtext5^Mtext6
>
> How should I have done it?
>
> Platform is Windows by the way.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Replace all tab characters in buffer with newline
  2014-01-15 16:41 Replace all tab characters in buffer with newline Angus Comber
  2014-01-15 16:47 ` Guido Van Hoecke
@ 2014-01-15 16:51 ` Angus Comber
  2014-01-16  6:30   ` Kevin Rodgers
  1 sibling, 1 reply; 4+ messages in thread
From: Angus Comber @ 2014-01-15 16:51 UTC (permalink / raw)
  To: help-gnu-emacs

Hi I found a way to do this:

c-m-% then C-Q <tab> replace with: C-Q C-J

C-j is the key thing that works.

Reason is that C-J means a newline and if you just press enter that is interpretted by emacs as the end of the command.  (Or anyway is interpretted differently).




On Wednesday, 15 January 2014 16:41:08 UTC, Angus Comber  wrote:
> I have eg:
> 
> 
> 
> text1<tab>text2<tab>text3
> 
> text4<tab>text5<tab>text6
> 
> 
> 
> I want to transform into:
> 
> 
> 
> text1
> 
> text2
> 
> text3
> 
> text4
> 
> text5
> 
> text6
> 
> 
> 
> 
> 
> Using c-m-% I tried this:
> 
> 
> 
> c-m=% Used C-Q for quorted then entered tab key on keyboard
> 
> 
> 
> For replacement I used C-Q (quoted) then entered <enter> key
> 
> 
> 
> But then I end up with:
> 
> 
> 
> text1^Mtext2^Mtext3
> 
> text4^Mtext5^Mtext6
> 
> 
> 
> How should I have done it?
> 
> 
> 
> Platform is Windows by the way.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Replace all tab characters in buffer with newline
  2014-01-15 16:51 ` Angus Comber
@ 2014-01-16  6:30   ` Kevin Rodgers
  0 siblings, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2014-01-16  6:30 UTC (permalink / raw)
  To: help-gnu-emacs

On 1/15/14 9:51 AM, Angus Comber wrote:
> Hi I found a way to do this:
>
> c-m-% then C-Q<tab>  replace with: C-Q C-J
>
> C-j is the key thing that works.
>
> Reason is that C-J means a newline and if you just press enter that is interpretted by emacs as the end of the command.  (Or anyway is interpretted differently).

[Please don't top-post.]

For a precise explanation of that interpretation:

1. C-h f read-event

    Note that evaluating (read-event "Event: ") in the *scratch* buffer and then
    hitting the Enter key returns [return] i.e. a vector with 1 element which
    is a symbol.

2. C-h f read-key

    Note that evaluating (read-key "Key: ") in the *scratch* buffer and then
    hitting the <Enter> key returns 13, which is the ASCII code for Control-M:

    (format "%c" 13) returns "^M" i.e. a string with 1 character which is
    Control-M.

3. See the "Named ASCII Chars" node in the Emacs manual.

4. See the "Function Keys" and "Translation Keymaps" nodes in the Emacs Lisp
    manual.

5. C-h v local-function-key-map

You can get C-q <Enter> to behave as you expected with this:

(defadvice quoted-insert (around translate-enter-to-newline activate)
   (let ((local-function-key-map  (copy-keymap local-function-key-map)))
     (define-key local-function-key-map [return] [?\C-j])
     ad-do-it))

 > On Wednesday, 15 January 2014 16:41:08 UTC, Angus Comber  wrote:
 >> I have eg:
 >>
 >> text1<tab>text2<tab>text3
 >> text4<tab>text5<tab>text6
 >>
 >> I want to transform into:
 >>
 >> text1
 >> text2
 >> text3
 >> text4
 >> text5
 >> text6
 >>
 >> Using c-m-% I tried this:
 >>
 >> c-m=% Used C-Q for quorted then entered tab key on keyboard
 >>
 >> For replacement I used C-Q (quoted) then entered<enter>  key
 >>
 >> But then I end up with:
 >>
 >> text1^Mtext2^Mtext3
 >> text4^Mtext5^Mtext6
 >>
 >> How should I have done it?
 >>
 >> Platform is Windows by the way.



-- 
Kevin Rodgers
Denver, Colorado, USA




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-01-16  6:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-15 16:41 Replace all tab characters in buffer with newline Angus Comber
2014-01-15 16:47 ` Guido Van Hoecke
2014-01-15 16:51 ` Angus Comber
2014-01-16  6:30   ` Kevin Rodgers

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.