In Vim/Vi, how do you move the cursor to the end of the previous word?
Unfortunately it’s not a single key… but ge is what you’re looking for, I think.
Unfortunately it’s not a single key… but ge is what you’re looking for, I think.
Vim has a builtin help system. Running :h E212 inside Vim prints the following: For some reason the file you are writing to cannot be created or overwritten. The reason could be that you do not have permission to write in the directory or the file name is not valid. You might want to edit … Read more
% is replaced with the current file name, thus you can use: :w !sudo tee % (vim will detect that the file has been changed and ask whether you want to it to be reloaded. Say yes by choosing [L] rather than OK.) As a shortcut, you can define your own command. Put the following … Read more
You can use ^ or 0 (Zero) in normal mode to move to the beginning of a line. ^ moves the cursor to the first non-blank character of a line 0 always moves the cursor to the “first column” You can also use Shifti to move and switch to Insert mode.
Ctrl+O takes me to the previous location. Don’t know about location before the search. Edit: Also, `. will take you to the last change you made.
Pass to the _ register, the black hole. To delete a line without sticking it in the registers: “_dd See also :help registers. It’s probably safest, if you want to paste something over and over again, to yank it into a “named” register. “aY Yanks a line into the a register. Paste it with “ap.
Since you already know how to cut/yank text, here are a few ideas for pasting it back into another file: Edit the first file, yanking the text you want. Then open your second file from within vi (:e /path/to/other/file) and paste it Open both files together in a split window and navigate between them using … Read more
As ZyX said on #vim, this question sounds like “Why do Vim experts prefer tasty over warm?”. “Vim experts” don’t prefer buffers over tabs: they use buffers as the file proxies they are and tab pages as the workspaces they are. Buffers and tab pages have different purposes so preferring one to the other makes … Read more
If you are on the first line, pressing (upper case) J will join that line and the next line together, removing the newline. You can also combine this with a count, so pressing 3J will combine all 3 lines together.
If I want to swap one line with the line above I usually do the following ddkP Explanation dd will delete the line and add it to the default register. k will move up a line (j would move down a line) P will paste above the current line