This article covers how you can move your cursor from anywhere in the file to the beginning or end of the file. Instead of that, you can also use the Esc + Ctrl + Home key combination to move your cursor to the first line of any file. I prefer using gg instead of 1G as it is easy to type 2G and end up on the second line. Typing gg has the same impact on cursor location - the cursor is moved to the first column of the first row. This command tells vim to move the cursor to line 1, as specified in the command. To jump back to the first line of the file, you can use either one of the following commands: 1G Since these are Vim commands, make sure that you are in Normal mode (use Esc key) before pressing any keys. There are several ways you can jump to the first line in Vim. Shift and g key together) in Normal mode, and your cursor will move to the first character of the last line.Īnother way to jump to the end of a file is by using the Esc + Ctrl + End or ]] key combination. It does not matter which row or column you are in Vim, to move your cursor to the last line, simply press an uppercase G (i.e. Just like Apple's phrase "There's an app for that", in Vim, "There's a command for that". Use the Esc key to enter the command mode, and then use the above-mentioned keys. You need to be in normal mode (also known as command mode) to use these keyboard shortcuts.
#VI EDITOR PAGE DOWN SHORTCUT HOW TO#
It is good to know how to move the cursor from anywhere in the file to either the first line or to the last line. You can use a movement command or up, down, right, and left arrow keys.If you open a very long file in Vim, it can get tough to navigate the file. Move the cursor to the end of the text you want to copy or cut. In this mode, the text is selected by rectangle blocks.Įntering the visual mode also marks a starting selection point. Press Ctrl+v to enter visual block mode.Press V to enter visual line mode, where the text is selected by line.Place the cursor on the line you want to begin copping or cutting. Vim’s visual mode allows you to select and manipulate text. To put the yanked or deleted text, move the cursor to the desired location and press p to put (paste) the text after the cursor or P to put (paste) before the cursor. For example dw, deletes to the start of the next word, and d^ deletes everything from the cursor to the start of the line. The movement commands that apply for yanking are also valid for deleting. d$ - Delete (cut) everything from the cursor to the end of the line.3dd - Delete (cut) three lines, starting from the line where the cursor is positioned,.dd - Delete (cut) the current line, including the newline character.Move the cursor to the desired position and press the d key, followed by the movement command. In normal mode, d is the key for cutting (deleting) text. Useful to copy text between matching brackets. By default supported pairs are (),, and. y% - Yank (copy) to the matching character.yw - Yank (copy) to the start of the next word.y^ - Yank (copy) everything from the cursor to the start of the line.y$ - Yank (copy) everything from the cursor to the end of the line.3yy - Yank (copy) three lines, starting from the line where the cursor is positioned.yy - Yank (copy) the current line, including the newline character.To copy text, place the cursor in the desired location and press the y key followed by the movement command. Copy is called yank ( y), cut is called delete ( d), and paste is called put ( p). Vim has its own terminology for copying, cutting, and pasting. To go back to normal mode from any other mode, just press the Esc key. In this mode, you can run Vim commands and navigate through the file. When you launch the Vim editor, you’re in the normal mode. This article shows how to copy, cut, and paste in Vim / Vi editor. Knowing the basics of Vim is helpful in a situation where your favorite editor is not available. Vim or its precursor Vi comes preinstalled on macOS and almost all Linux distributions. When working with text files, copying, cutting, and pasting text is one of the most commonly performed tasks.