LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-11-2003, 06:56 PM   #1
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
emacs keystroke


im having to work on a solaris system and they have installed a very old nasty antequated version of vim so i find myself having to use emacs which i dont know very well. the problem is im really missing some commands from vim and i hope someone can guide me to the appropriate keystroke in emacs. im after equivelents for:

cw, c$, cf[char here], .

cheers
 
Old 07-11-2003, 07:45 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
I might be able to help, but since I don't use vi, I don't have any idea what the commands you mention are supposed to do...
 
Old 07-11-2003, 08:05 PM   #3
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Ok, so I don't know what exactly a "change" command does. So this may not be what you want.

cw => change word
M-d is the keystoke in emacs to "kill word". It will kill everything from point/cursor to the next word break. For me the Meta key is escape... depends on your keymap though. You can also execute it like so:
M-x kill-word X
Where you replace X with the number of times to "kill word"

If you're looking to search-and-replace, the keystroke is M-%

c$ => Change to end of line
C-k will delete everything on the line from point/cursor to the end of the line. Hitting C-k twice in succession will not only delete the contents to the end of the line but also delete the newline as well

cf => could not find an online reference that mentioned it

and no emacs command list should be without:

Undo: C-_

Last edited by Dark_Helmet; 07-11-2003 at 08:07 PM.
 
Old 07-11-2003, 08:35 PM   #4
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Original Poster
Rep: Reputation: 51
change is essentially delete and enter insert mode. so M-d and C-k are exactly what im looking for, cf isnt really important, it changes the text between the current cursor and the first occurence of the character after f eg

printf("hello world");

if the cursor was at the beginning of the line then fhcfd would move to the h in hello then delete everything upto the d in world and put me into insert mode essentially changing the text in the quotes. but it was really the M-d i was after.
 
Old 07-11-2003, 09:47 PM   #5
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Glad I could help. Need any more commands? I always feel so alone since everybody else uses vi... I guess I'm just weird. I really don't like having two different 'modes'. I'm an impatient, instant gratification type I guess. When I hit 'G', I want to see a G put into the document...
 
Old 07-15-2003, 07:31 AM   #6
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Original Poster
Rep: Reputation: 51
is it possible to do find and replace within a selected region?
 
Old 07-15-2003, 12:38 PM   #7
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Yes, I'm sure it's possible. I don't know it off-hand though. I'll look it up when I get back to the house.
 
Old 07-15-2003, 10:44 PM   #8
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Here you go...

Define a region by setting mark (either C-@ or C-space), and move the cursor to the end of the region you want to modify.

This command restricts your buffer to your selection (n: narrow)
C-x n n

Do your search-and-replace

This command returns you to the original buffer (w: widen)
C-x n w

Last edited by Dark_Helmet; 07-15-2003 at 10:48 PM.
 
Old 07-16-2003, 06:13 AM   #9
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Original Poster
Rep: Reputation: 51
that is a great command, how did you find it? i feel like ive trawled through miles of documentation and never saw anything like it. can i also do code folds?
 
Old 07-16-2003, 10:15 AM   #10
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
I remembered someone telling me that it was possible to restrict yourself to a sub-buffer like that. Unfortunately, I'd forgotten the command since then. So I started searching for references to regions, then rectangles, and then by a stroke of luck, google turned up a message thread that someone mentioned it in.

In my version of Xemacs, when I execute the command, it says it's "disabled" but allows me to run it. That might be why it was difficult to find it. Perhaps the maintainers don't want to support that command anymore... dunno.

Until they rip it out completely or offer an alternative, I'd say it's fair game.

I can't say that I've seen code folds implemented. If they have, it's probably been someone's custom LISP implementation. Then again, those people tend to post their LISP code. So it's possible.

Last edited by Dark_Helmet; 07-16-2003 at 10:17 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
where is the .emacs file in the emacs source code tarball? aizkorri Programming 2 01-13-2007 02:05 PM
emacs not responding to .emacs file in Mandriva 2005 LE. Please help LaptopLinux Mandriva 1 06-08-2005 08:36 AM
keystroke logger??? paugros Linux - Security 18 03-24-2005 12:06 PM
edb (emacs database) won't open file - emacs 20 & 21 tip184 Linux - Software 0 04-03-2004 07:31 AM
keystroke macros squip Programming 1 10-09-2003 12:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration