* Re: A few simple questions
2003-05-10 5:18 A few simple questions Wang Yin
@ 2003-05-10 6:50 ` Jonas Steverud
2003-05-10 7:00 ` Friedrich Dominicus
` (3 subsequent siblings)
4 siblings, 0 replies; 20+ messages in thread
From: Jonas Steverud @ 2003-05-10 6:50 UTC (permalink / raw)
Wang Yin <wang-y01@mails.tsinghua.edu.cn> writes:
> Hi,
>
> I have a few simple questions to ask about Emacs. They are so simple,
> yet it seems that I can't find them in the manual and FAQ:
>
> 1. How can I do something like f command in vi? When I'm looking at a
> line, I want to move to a charater, say 'a'. How can I do something
> like "fa" in Emacs, and how to I repeat this command to go to
> following a's?
Since I never used the eVIl one I don't know exactly what f pretends
to do, but according to your description, I would say to look for
isearch-forward in Emacs. That is; C-s a to look for the next a and
then repeat with C-s. C-r is the same but backwards.
See the info node Searching and Replacement in Emacs' info file.
C-h i d m emacs RET g search RET
> 3. How do I change DOS lineend file into UNIX lineend file quickly? I
> don't like to C-x RET c ....-unix C-x C-f...!
Do you want to do that for all your files, i.e. forever, or for some
files?
--
( http://hem.bredband.net/steverud ! Wei Wu Wei )
( Meaning of U2 Lyrics, Roleplaying ! To Do Without Do )
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: A few simple questions
2003-05-10 5:18 A few simple questions Wang Yin
2003-05-10 6:50 ` Jonas Steverud
@ 2003-05-10 7:00 ` Friedrich Dominicus
2003-05-10 14:03 ` Wang Yin
2003-05-10 8:59 ` Eli Zaretskii
` (2 subsequent siblings)
4 siblings, 1 reply; 20+ messages in thread
From: Friedrich Dominicus @ 2003-05-10 7:00 UTC (permalink / raw)
Wang Yin <wang-y01@mails.tsinghua.edu.cn> writes:
> Hi,
>
> I have a few simple questions to ask about Emacs. They are so simple,
> yet it seems that I can't find them in the manual and FAQ:
>
> 1. How can I do something like f command in vi? When I'm looking at a
> line, I want to move to a charater, say 'a'. How can I do something
> like "fa" in Emacs, and how to I repeat this command to go to
> following a's?
C-s a
for repeated searches just type C-s again
>
> 2. How do I move like "W" in vi. That is, move to the next white space
> delimited "Word"?
M-f alternatively for more word C-u 3 M-f
>
> 3. How do I change DOS lineend file into UNIX lineend file quickly? I
> don't like to C-x RET c ....-unix C-x C-f...!
M-x replace-regexp C-q RET$ RET RET
You can save it as a macro, name it and just call the macro.
Regards
Friedrich
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: A few simple questions
2003-05-10 7:00 ` Friedrich Dominicus
@ 2003-05-10 14:03 ` Wang Yin
2003-05-10 14:15 ` Friedrich Dominicus
` (3 more replies)
0 siblings, 4 replies; 20+ messages in thread
From: Wang Yin @ 2003-05-10 14:03 UTC (permalink / raw)
Friedrich Dominicus <frido@q-software-solutions.com> writes:
> Wang Yin <wang-y01@mails.tsinghua.edu.cn> writes:
>
> > Hi,
> >
> > I have a few simple questions to ask about Emacs. They are so simple,
> > yet it seems that I can't find them in the manual and FAQ:
> >
> > 1. How can I do something like f command in vi? When I'm looking at a
> > line, I want to move to a charater, say 'a'. How can I do something
> > like "fa" in Emacs, and how to I repeat this command to go to
> > following a's?
> C-s a
> for repeated searches just type C-s again
I don't mean that. I want something faster that doesn't need
interaction.
I want something just like a zap-to-char, but instead of killing the
characters, move the pointer.
> >
> > 2. How do I move like "W" in vi. That is, move to the next white space
> > delimited "Word"?
> M-f alternatively for more word C-u 3 M-f
I mean how can I jump over something like "emacs-21.2.tar.gz" as a
whole, not as 5 words. I want to jump to the next white space.
> >
> > 3. How do I change DOS lineend file into UNIX lineend file quickly? I
> > don't like to C-x RET c ....-unix C-x C-f...!
> M-x replace-regexp C-q RET$ RET RET
>
> You can save it as a macro, name it and just call the macro.
>
> Regards
> Friedrich
--
Wang Yin
DA Lab, Tsinghua University,
100084
Beijing China
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: A few simple questions
2003-05-10 14:03 ` Wang Yin
@ 2003-05-10 14:15 ` Friedrich Dominicus
2003-05-10 14:19 ` Marco Parrone
` (2 subsequent siblings)
3 siblings, 0 replies; 20+ messages in thread
From: Friedrich Dominicus @ 2003-05-10 14:15 UTC (permalink / raw)
Wang Yin <wang-y01@mails.tsinghua.edu.cn> writes:
> Friedrich Dominicus <frido@q-software-solutions.com> writes:
>
> > Wang Yin <wang-y01@mails.tsinghua.edu.cn> writes:
> >
> > > Hi,
> > >
> > > I have a few simple questions to ask about Emacs. They are so simple,
> > > yet it seems that I can't find them in the manual and FAQ:
> > >
> > > 1. How can I do something like f command in vi? When I'm looking at a
> > > line, I want to move to a charater, say 'a'. How can I do something
> > > like "fa" in Emacs, and how to I repeat this command to go to
> > > following a's?
> > C-s a
> > for repeated searches just type C-s again
>
> I don't mean that. I want something faster that doesn't need
> interaction.
Well how should one now for what you are looking without interaction?
and it is the opposite of what you write "how to I repeat this
command", which means you interact with the System
>
>
> > >
> > > 2. How do I move like "W" in vi. That is, move to the next white space
> > > delimited "Word"?
> > M-f alternatively for more word C-u 3 M-f
>
> I mean how can I jump over something like "emacs-21.2.tar.gz" as a
> whole, not as 5 words. I want to jump to the next white space.
Well emacs things a dot is the end of a word which seems to be a very
reasonable assumption, if you dont't think so than modify the syntax
table to your liking e.g exclude the . or use forward-whitepace
Regards
Friedrich
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: A few simple questions
2003-05-10 14:03 ` Wang Yin
2003-05-10 14:15 ` Friedrich Dominicus
@ 2003-05-10 14:19 ` Marco Parrone
2003-05-10 14:23 ` Marco Parrone
` (2 more replies)
2003-05-10 17:39 ` Eli Zaretskii
[not found] ` <mailman.5930.1052588693.21513.help-gnu-emacs@gnu.org>
3 siblings, 3 replies; 20+ messages in thread
From: Marco Parrone @ 2003-05-10 14:19 UTC (permalink / raw)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Wang Yin <wang-y01@mails.tsinghua.edu.cn> writes:
> > > I have a few simple questions to ask about Emacs. They are so simple,
> > > yet it seems that I can't find them in the manual and FAQ:
> > >
> > > 1. How can I do something like f command in vi? When I'm looking at a
> > > line, I want to move to a charater, say 'a'. How can I do something
> > > like "fa" in Emacs, and how to I repeat this command to go to
> > > following a's?
> > C-s a
> > for repeated searches just type C-s again
>
> I don't mean that. I want something faster that doesn't need
> interaction.
>
> I want something just like a zap-to-char, but instead of killing the
> characters, move the pointer.
You can put this in your .emacs:
(defun go-to-char (arg char)
"Go to ARG'th occurrence of CHAR.
Case is ignored if `case-fold-search' is non-nil in the current buffer.
Goes backward if ARG is negative; error if CHAR not found."
(interactive "p\ncGo to char: ")
(search-forward (char-to-string char) nil nil arg))
(define-key global-map (kbd "C-c g") 'go-to-char)
This is derived for zap-to-char.
> > > 2. How do I move like "W" in vi. That is, move to the next white space
> > > delimited "Word"?
> > M-f alternatively for more word C-u 3 M-f
>
> I mean how can I jump over something like "emacs-21.2.tar.gz" as a
> whole, not as 5 words. I want to jump to the next white space.
Put this in you .emacs:
(defun go-to-non-alphanum (arg)
"Search forward for a whitespace."
(interactive "p")
(re-search-forward "[^A-Za-z1-9]" nil nil arg))
(define-key global-map (kbd "C-c n") 'go-to-char)
GoodBye
- --
Marco Parrone - marc0@autistici.org
www.autistici.org/marc0
2143 9E77 D5E6 115A 48AD A170 D0EE F736 (4E88 99C2)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>
iD8DBQE+vQpd0O73Nk6ImcIRArpsAJ95CGqEf0CeeJRerBV4SyOgJJrWtACdGhQO
XJ6gT4oZ3eCmkeTQPneUOQI=
=/Par
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: A few simple questions
2003-05-10 14:19 ` Marco Parrone
@ 2003-05-10 14:23 ` Marco Parrone
2003-05-10 14:35 ` Marco Parrone
2003-05-10 14:58 ` Wang Yin
2 siblings, 0 replies; 20+ messages in thread
From: Marco Parrone @ 2003-05-10 14:23 UTC (permalink / raw)
> This is derived for zap-to-char.
M-% for RET from RET
> (define-key global-map (kbd "C-c n") 'go-to-char)
M-% go-to-char RET go-to-non-alphanum RET
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: A few simple questions
2003-05-10 14:19 ` Marco Parrone
2003-05-10 14:23 ` Marco Parrone
@ 2003-05-10 14:35 ` Marco Parrone
2003-05-10 14:58 ` Wang Yin
2 siblings, 0 replies; 20+ messages in thread
From: Marco Parrone @ 2003-05-10 14:35 UTC (permalink / raw)
> (defun go-to-non-alphanum (arg)
> "Search forward for a whitespace."
> (interactive "p")
> (re-search-forward "[^A-Za-z1-9]" nil nil arg))
>
> (define-key global-map (kbd "C-c n") 'go-to-char)
I'm very sorry, I should be less instinctive, this should work.
(defun go-to-whitespace (arg)
"Search forward for a whitespace."
(interactive "p")
(re-search-forward " \\|\n\\|\t" nil nil arg))
(define-key global-map (kbd "C-c w") 'go-to-whitespace)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: A few simple questions
2003-05-10 14:19 ` Marco Parrone
2003-05-10 14:23 ` Marco Parrone
2003-05-10 14:35 ` Marco Parrone
@ 2003-05-10 14:58 ` Wang Yin
2003-05-10 15:28 ` Marco Parrone
2 siblings, 1 reply; 20+ messages in thread
From: Wang Yin @ 2003-05-10 14:58 UTC (permalink / raw)
Thank you very much!
And I want a fast way to repeat your go-to-char, since the position I
first go to may not be the position I want, and I think doing a
C-c n <char>
again is too slow. I mean, is there a function like ";" in vi?
Thanks :)
--
Wang Yin
DA Lab, Tsinghua University,
100084
Beijing China
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: A few simple questions
2003-05-10 14:58 ` Wang Yin
@ 2003-05-10 15:28 ` Marco Parrone
2003-05-11 0:28 ` Wang Yin
0 siblings, 1 reply; 20+ messages in thread
From: Marco Parrone @ 2003-05-10 15:28 UTC (permalink / raw)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Wang Yin <wang-y01@mails.tsinghua.edu.cn> writes:
> Thank you very much!
> And I want a fast way to repeat your go-to-char, since the position I
> first go to may not be the position I want, and I think doing a
>
> C-c n <char>
>
> again is too slow. I mean, is there a function like ";" in vi?
(setq last-go-to-char "")
(defun go-to-char (arg char)
"Go to ARG'th occurrence of CHAR.
Case is ignored if `case-fold-search' is non-nil in the current buffer.
Goes backward if ARG is negative; error if CHAR not found."
(interactive "p\ncGo to char: ")
(setq last-go-to-char (char-to-string char))
(search-forward last-go-to-char nil nil arg))
(defun go-to-char-again (arg)
"Repeat the previous go-to-char command."
(interactive "p")
(search-forward last-go-to-char nil nil arg))
(defun go-to-whitespace-not-whitespace (arg)
"Search forward for a whitespace followed by a non-whitespace."
(interactive "p")
(re-search-forward "[ \n\t][^ \n\t]" nil nil arg)
(goto-char (- (point) 1)))
(define-key global-map (kbd "C-c f") 'go-to-char)
(define-key global-map (kbd "C-c ;") 'go-to-char-again)
(define-key global-map (kbd "C-c W") 'go-to-whitespace-not-whitespace)
GoodBye
- --
Marco Parrone - marc0@autistici.org
www.autistici.org/marc0
2143 9E77 D5E6 115A 48AD A170 D0EE F736 (4E88 99C2)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>
iD8DBQE+vRpI0O73Nk6ImcIRAuYIAKCvisB2pHzl6IPy4YYyiWKlCgASyQCg9B2s
V2lEeQ2/UXZ4tD/sRFqUW3o=
=1zKf
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: A few simple questions
2003-05-10 15:28 ` Marco Parrone
@ 2003-05-11 0:28 ` Wang Yin
2003-05-12 12:50 ` Oliver Scholz
0 siblings, 1 reply; 20+ messages in thread
From: Wang Yin @ 2003-05-11 0:28 UTC (permalink / raw)
good!
What about change the repeat mechanism of C-c f like C-x z z z z z ... ?
--
Wang Yin
DA Lab, Tsinghua University,
100084
Beijing China
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: A few simple questions
2003-05-11 0:28 ` Wang Yin
@ 2003-05-12 12:50 ` Oliver Scholz
2003-05-12 12:56 ` Oliver Scholz
0 siblings, 1 reply; 20+ messages in thread
From: Oliver Scholz @ 2003-05-12 12:50 UTC (permalink / raw)
Wang Yin <wang-y01@mails.tsinghua.edu.cn> writes:
> good!
> What about change the repeat mechanism of C-c f like C-x z z z z z ... ?
(defvar wy-go-to-char-key ?f)
(defun wy-go-to-char (n char)
"Move forward to Nth occurence of CHAR.
Typing `wy-go-to-char-key' again will move forwad to the next Nth
occurence of CHAR."
(interactive "p\ncGo to char: ")
(search-forward (string char) nil nil n)
(while (char-equal (read-char)
wy-go-to-char-key)
(search-forward (string char) nil nil n))
(setq unread-command-events (list last-input-event)))
(define-key global-map `[?\C-c ,wy-go-to-char-key] 'wy-go-to-char)
Type `C-c f a' to move to the next "a". Type `f f f f ...' to move to
the following "a"s.
Oliver
--
23 Floréal an 211 de la Révolution
Liberté, Egalité, Fraternité!
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: A few simple questions
2003-05-12 12:50 ` Oliver Scholz
@ 2003-05-12 12:56 ` Oliver Scholz
0 siblings, 0 replies; 20+ messages in thread
From: Oliver Scholz @ 2003-05-12 12:56 UTC (permalink / raw)
Oliver Scholz <alkibiades@gmx.de> writes:
> Wang Yin <wang-y01@mails.tsinghua.edu.cn> writes:
>
>> good!
>> What about change the repeat mechanism of C-c f like C-x z z z z z ... ?
>
[Lisp code]
> Type `C-c f a' to move to the next "a". Type `f f f f ...' to move to
> the following "a"s.
Come to think about it, maybe it's nicer to hit the key for the char
you are looking for repeatedly: `C-c f a a a a ...'. I might even
consider using this myself.
(defun wy-go-to-char (n char)
"Move forward to Nth occurence of CHAR.
Typing `wy-go-to-char-key' again will move forwad to the next Nth
occurence of CHAR."
(interactive "p\ncGo to char: ")
(search-forward (string char) nil nil n)
(while (char-equal (read-char)
char)
(search-forward (string char) nil nil n))
(setq unread-command-events (list last-input-event)))
(define-key global-map (kbd "C-c a") 'wy-go-to-char)
Oliver
--
23 Floréal an 211 de la Révolution
Liberté, Egalité, Fraternité!
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: A few simple questions
2003-05-10 14:03 ` Wang Yin
2003-05-10 14:15 ` Friedrich Dominicus
2003-05-10 14:19 ` Marco Parrone
@ 2003-05-10 17:39 ` Eli Zaretskii
[not found] ` <mailman.5930.1052588693.21513.help-gnu-emacs@gnu.org>
3 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2003-05-10 17:39 UTC (permalink / raw)
> From: Wang Yin <wang-y01@mails.tsinghua.edu.cn>
> Newsgroups: gnu.emacs.help
> Date: 10 May 2003 22:03:12 +0800
> > C-s a
> > for repeated searches just type C-s again
>
> I don't mean that. I want something faster that doesn't need
> interaction.
I think you misunderstood: the next time you simply type "C-s C-s",
which doesn't need any interaction.
^ permalink raw reply [flat|nested] 20+ messages in thread
[parent not found: <mailman.5930.1052588693.21513.help-gnu-emacs@gnu.org>]
* Re: A few simple questions
2003-05-10 5:18 A few simple questions Wang Yin
2003-05-10 6:50 ` Jonas Steverud
2003-05-10 7:00 ` Friedrich Dominicus
@ 2003-05-10 8:59 ` Eli Zaretskii
2003-05-10 14:33 ` Kai Großjohann
2003-05-10 17:07 ` Kai Großjohann
4 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2003-05-10 8:59 UTC (permalink / raw)
> From: Wang Yin <wang-y01@mails.tsinghua.edu.cn>
> Newsgroups: gnu.emacs.help
> Date: 10 May 2003 13:18:04 +0800
>
> I have a few simple questions to ask about Emacs. They are so simple,
> yet it seems that I can't find them in the manual and FAQ:
FAQ is not the first place you should look into to find such
information, not in Emacs, anyway. The first place to look is in the
on-line manual.
> 1. How can I do something like f command in vi? When I'm looking at a
> line, I want to move to a charater, say 'a'. How can I do something
> like "fa" in Emacs, and how to I repeat this command to go to
> following a's?
You actually want to _search_ for a character. So, type "C-h i d m
emacs RET" (or click Help->Read the Emacs Manual" from the menu bar),
which will get you into the Emacs manual, then type "g Search RET" to
get to the "Search" node, and read there. As others suggested, "C-s a"
is all you need.
> 2. How do I move like "W" in vi. That is, move to the next white space
> delimited "Word"?
The manual has a section named "Moving Point" which describes the
various commands for cursor motion. You want "M-f" or "C-<rightarrow>".
> 3. How do I change DOS lineend file into UNIX lineend file quickly? I
> don't like to C-x RET c ....-unix C-x C-f...!
After you visit the file with "C-x C-f", type "C-x RET f unix RET" and
save the file. (You could have found this yourself by using the
index-search command in the Emacs manual" type "i DOS-to-Unix RET",
and Emacs will land you in the appropriate place in the manual.)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: A few simple questions
2003-05-10 5:18 A few simple questions Wang Yin
` (2 preceding siblings ...)
2003-05-10 8:59 ` Eli Zaretskii
@ 2003-05-10 14:33 ` Kai Großjohann
2003-05-10 17:07 ` Kai Großjohann
4 siblings, 0 replies; 20+ messages in thread
From: Kai Großjohann @ 2003-05-10 14:33 UTC (permalink / raw)
Wang Yin <wang-y01@mails.tsinghua.edu.cn> writes:
> 1. How can I do something like f command in vi? When I'm looking at a
> line, I want to move to a charater, say 'a'. How can I do something
> like "fa" in Emacs, and how to I repeat this command to go to
> following a's?
People have mentioned C-s before. It's not the same as vi's f
command, but maybe good enough.
> 2. How do I move like "W" in vi. That is, move to the next white space
> delimited "Word"?
I think this doesn't exist in Emacs. Emacs has the equivalent of
"w", but no equivalent of "W". Maybe C-M-f comes close: whereas M-f
would stop at the dash in foo-bar, C-M-f would not. (M-f is the
Emacs equivalent of vi's "w".)
> 3. How do I change DOS lineend file into UNIX lineend file quickly? I
> don't like to C-x RET c ....-unix C-x C-f...!
Emacs automatically recognizes the EOL convention of files it reads.
So, normally, C-x C-f is enough. After that, saving with C-x C-s
preserves the EOL convention.
--
file-error; Data: (Opening input file no such file or directory ~/.signature)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: A few simple questions
2003-05-10 5:18 A few simple questions Wang Yin
` (3 preceding siblings ...)
2003-05-10 14:33 ` Kai Großjohann
@ 2003-05-10 17:07 ` Kai Großjohann
2003-05-11 0:33 ` Wang Yin
4 siblings, 1 reply; 20+ messages in thread
From: Kai Großjohann @ 2003-05-10 17:07 UTC (permalink / raw)
Wang Yin <wang-y01@mails.tsinghua.edu.cn> writes:
> I have a few simple questions to ask about Emacs. They are so simple,
> yet it seems that I can't find them in the manual and FAQ:
It seems you're a vi user. Maybe you will like viper. It's really
cool. It lets you combine the vi movement commands with Emacs. I
don't use it all the time, but from time to time I feel like it and I
really like it.
--
file-error; Data: (Opening input file no such file or directory ~/.signature)
^ permalink raw reply [flat|nested] 20+ messages in thread