12/3/2023 0 Comments Most useful vim shortcuts![]() ![]() You’re still working in myfile.txt though. This saves the current state of the file, let’s say it is named myfile.txt, to a file otherfile.txt in the home directory. First here’s a basic but often overlooked trick before an important edit to a file: In the last line mode, you can do a lot more than saving and quitting your file. gg to jump to the first line of the file.Display line numbers in your file:Īlso, a bit basic, but navigation wise I use these shortcuts daily, in command mode: vimrc file, but that’s probably for a later post. When you’re in a file, you can set the line numbers. And not unimportantly, the user you are attempting this with needs sudo privileges. When you’re in a file and you have to edit it with elevated permissions, you can also do this from the last line mode:īoth can also be run with w, where you only write the file instead of writing and quiting. This only works when you have enough privileges to the file to begin with. When you’re done you can write and exit with the ! to write the file anyway: Let’s say I’m in view mode and decide I DO want to edit the line, for instance comment the current line out, I can do so by adding or inserting like normal (a or i). I use view when I’m certain I’m not going to or don’t want to edit the file: This is the same with the read only variant of vim: view. To open the file and immediately jump to the correct line (in this example line number 114): In no order.Īn error (in a log, PHP error, whatever) often comes with a line number where the error originates. Here are things I’m using every day, so it should be a very practical post. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |