Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: move to a certain character, forwards and backwards

Tags:

emacs

In vim, I can use f to move the cursor forwards to a certain character and F to do this backwards. How to do it in Emacs? I know you can use C-z or M-z to delete until a certain character, and you can also first delete then paste to achieve a motion. But 1) is there a better way to do this, only movement, without delete? and 2) how to do this backwards?

like image 854
gefei Avatar asked Mar 25 '12 13:03

gefei


People also ask

How to move point in Emacs?

You can also move point using the arrow keys present on most keyboards: RIGHT, LEFT , DOWN, and UP; however, many Emacs users find that it is slower to use the arrow keys than the control keys, because you need to move your hand to the area of the keyboard where those keys are located.

What are the Emacs commands that work on lines?

Unlike C-n and C-p, most of the Emacs commands that work on lines work on logical lines. For instance, C-a ( move-beginning-of-line) and C-e ( move-end-of-line) respectively move to the beginning and end of the logical line. Whenever we encounter commands that work on screen lines, such as C-n and C-p, we will point these out.

How do I use the backspace key in Emacs?

You can do some work just by typing in the window once emacs comes to life. The backspace or delete key should do what you think it does. In the list below, C- means "control key", M- means "meta key" (escape). For meta commands, press the meta key, then the other key.

How do I return a specific line in Emacs?

To go to a specific line: Type M-x goto-line <return>, then type the line number followed by <return>. There a shortcuts. Type the command "help -q emacs goto " in a local window to find out about it. (Local shortcut is M-x #). Emacs has an excellent on-line help tutorial. To use it, start up emacs.


2 Answers

Forward incremental search is C-s, and reverse incremental search is C-r.

Responding to comment:

To delete from the current position backwards to a specific character, you can use

C-<space> to mark the current position, then C-r <char> <RET> to locate the search character, and C-w to delete between current position and mark.

To get more help on doing things in emacs, you should look at the tutorial. Typing C-h t will open the tutorial in a new buffer.

like image 112
Don Roby Avatar answered Oct 18 '22 16:10

Don Roby


jump-char was designed specifically for this task.

To delete, use zap-to-char or activate the mark by pressing C-spc before jumping, then C-w.

like image 43
event_jr Avatar answered Oct 18 '22 16:10

event_jr