You can use several different buffers. For example, you might also delete text from one location and add it to several others. To delete 12 lines into the named buffer b , type " b12dd ".
To insert the text, precede the p or P command with n , where n is the named buffer. For example, to insert the lines saved in buffer b , type " bP ". You can overwrite named buffers with new lines. The buffers are saved until you exit vi. When you use named buffers, you can safely delete and yank other text without affecting the lines you have already saved in the named buffers -- unless, of course, you purposely overwrite the named buffer. After typing the first couple of characters, you can press Tab for completion of the name.
For example, if a buffer is named example. If the command fails because more than one buffer matches , press : then Up arrow to recall the command, then press Tab to choose the wanted name.
Vim keeps a history of all the jumps you make in your buffers. You can go to any place you jumped from with the Ctrl-O and Ctrl-I command normal mode. This also works across buffers. You can use :split and :vsplit to divide the current area into two windows with the same buffer.
If you supply an argument then one of the new windows is created with the argument as a file name used for the buffer in the new window. To gain more control over how the splits are created, you can combine the :vertical , :leftabove and :rightbelow commands. Also of use are the the :sfind and :sb commands. Buffers are a convenient way to manage multiple files within a project in Vim.
If you are managing multiple projects, consider opening a separate Vim for each project. Type "fP to insert the lines copied into buffer f before the current line.
If you wish, you can insert the contents of buffer f in multiple places in your file. If you use the vi p or P commands before making any other changes to the file, the deleted line will be put into the file just after p or just before P the line on which the cursor is resting.
If you use the vi p or P commands before making any other changes to the file, the deleted lines will be put into the file just after p or just before P the line on which the cursor is resting. For example, "g6dd would delete six lines from your file but retain them in the buffer g for the rest of your current vi work session. Sign in to leave feedback. Blank Blank. Blank Details. Article ID: Related Articles 4.
Unix: Getting started with vi. Unix: More information about vi. Unix: The vi text editor. Unix: Vi Tip Sheet. Recipient s - separate email addresses with a comma. A buffer is a computer's memory, that acts as a temporary holding place for data that is being sent to or received from an external device like keyboard, hard disk, printer etc.
There are 36 buffers in vi to store text. Command starts with " character. The vi editor doesn't allow direct modification of the file, instead it makes a copy of the edited file which is saved in buffer. Here a is one of the buffer out of 36 buffers, dd is the command to delete a line. This command will delete the current line and will save it in buffer a. Look at the above snapshot, after pressing command "add, current line fourth line is deleted and is saved in buffer a.
Here also a is one of the buffer out of 36 buffers, p is the command to paste. This command will paste a line from buffer a after the current cursor position. Look at the above snapshot, we want to paste a line from buffer a after the current cursor position.
Look at the above snapshot, after passing "ap command, line which was saved in buffer a in last example is pasted back after the current position that is at the last. JavaTpoint offers too many high quality services.
0コメント