Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I send a command to a specific buffer?

Tags:

vim

If I have a buffer's name + number (it might even be hidden), how do I send a command to it while keeping the focus on my active buffer?

like image 390
Dane O'Connor Avatar asked Mar 08 '15 20:03

Dane O'Connor


People also ask

Which command moves 5 lines of text into a buffer named a?

Begin your edit session with the command: vi file1 file2<CR> to yank the five lines into the buffer named a.

What vi command would copy the current line into the buffer?

To copy text into a buffer, use the vi yank command. The most common uses are outlined below. The vi yy command "yanks" the current line into the vi general buffer. That is, it copies the line for you to put into the file immediately.

What is a buffer command?

Command buffers are the unit of work submission in Metal; they are created by the CPU and executed by the GPU. This relationship allows you to balance CPU and GPU work by adjusting the number of command buffers submitted per frame.

How do I copy 5 lines from current cursor position?

To copy text, place the cursor in the desired location and press the y key followed by the movement command. Below are some helpful yanking commands: yy - Yank (copy) the current line, including the newline character. 3yy - Yank (copy) three lines, starting from the line where the cursor is positioned.


1 Answers

You can't; instead, that hidden buffer must be (temporarily) activated in order to execute commands on it.

(The only exceptions are the getbufline() and get/setbufvar() functions, but you can't do much with them.)

My ingo-library plugin provides a handy ingo#buffer#visible#Execute( bufnr, command ) function that handles that for you.

like image 50
Ingo Karkat Avatar answered Oct 19 '22 16:10

Ingo Karkat