LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   emacs keystroke (https://www.linuxquestions.org/questions/programming-9/emacs-keystroke-71990/)

kev82 07-11-2003 06:56 PM

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

Dark_Helmet 07-11-2003 07:45 PM

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... :)

Dark_Helmet 07-11-2003 08:05 PM

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-_

kev82 07-11-2003 08:35 PM

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.

Dark_Helmet 07-11-2003 09:47 PM

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... :)

kev82 07-15-2003 07:31 AM

is it possible to do find and replace within a selected region?

Dark_Helmet 07-15-2003 12:38 PM

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.

Dark_Helmet 07-15-2003 10:44 PM

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

kev82 07-16-2003 06:13 AM

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?

Dark_Helmet 07-16-2003 10:15 AM

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.


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