With Emacs, I like to break it down into “four parts.”

How did you do that? In Emacs terms, the area used to display a buffer is called a window. In Emacs terms, the area used to display a buffer is called a window. The outermost form, often called window, is called frame.

After this, I can press c-Tab several times (I have bound the shortcut key to the other-window command) to rotate the currently focused window in the order of top left, bottom left, top right, and bottom right.

If you need to copy content from other Windows to paste in the current window, the operation is a little cumbersome. For example, if the upper right corner requires the lower left corner:

  1. According to the three timesC-TabGo to window in the lower left corner — use the shortcut keys because I don’t want to move the mouse;
  2. According to thekorjMove the cursor up and down to the target line withkandjBecause of the use ofevil-modePlug-ins (seeThis article);
  3. Copy the content and press againC-TabLet’s go back to the window and paste it.

That sounds like a lot of trouble.

Fortunately, Emacs has a very handy plug-in that combines steps 1 and 2 together.

avy

This very useful plugin is Avy, which provides the Avy-goto-line function to complete steps 1 and 2 above in one step.

You can install it using Emacs’ package manager

M-x package-install RET avy RET
Copy the code

Next, bind a favorite shortcut for the command avy-goto-line

(global-set-key (kbd "M-g f") 'avy-goto-line)
Copy the code

At this point, you can happily use m-g f in Emacs to quickly jump to lines in the current window or another window. Seeing is believing. I’ll show you.

avy-goto-line

As you know, I use org-mode to keep track of my learning schedule, and I save some of the code I’m working through into an org-mode entry. For example, I want to copy the definitions of the three functions in window in the lower left corner into the code block in the upper right corner

So I’m going to press M minus g, f, and I’m going to have avy give each line a mark

I want to go to the first line of window in the lower left corner, so I’m going to press j

At this point, all tags that don’t start with the letter J in the previous screenshot are gone, and only the j tags that start with the second character are left.

Press l again to switch the focus to window in the lower left corner and move the cursor to the beginning of the first line. Then just select the content, copy it, and return to the original window and paste it. The complete process is as follows

Afterword.

If the M-g – f combination is followed by a numeric key, avy-goto-line assumes that the user intends to jump to the specified line. It continues to wait in the Emacs minibuffer for more numbers to be entered or enter. I don’t use this feature much, though, because I don’t have Emacs display line numbers, and it’s not convenient for me to jump by line numbers.

Read the original