Final Replace: Mar 25, 2023
Like most “hardcore” Linux/Unix hackers I like Vi/Vim, and I’ve discovered there isn’t any finish to the issues you may study Vim so I made a decision so as to add a number of command line tips that I simply realized lately.
I’m going to make use of “file.txt” as our instance file.
Listed below are some cool Vim command line tips:
1. Open on the finish of a file
The plus signal added earlier than the file identify opens up the file with the cursor on the finish of the file. This may be helpful in case you have an enormous textual content file you and also you don’t wish to scroll down.
2. Open file at particular line
In the event you add a quantity (change n with a quantity in case you hadn’t guessed) the cursor will go precisely to that line quantity. Extraordinarily helpful for big textual content information or error messages that specify a line quantity in a config or supply file.
3. Open file at a sample
vi **+/_pattern_** file.txt
This may open the file on the identical line because the sample you specify (first occasion of it). That is nice in case you have a selected phrase to seek for.
4. Recuperate a file after a crash
Use -r to open a file and get well it after a crash. This might save your butt sometime.
5. Run a script towards a file
vi **-s** file.txt < script.sh
This trick could possibly be tremendous highly effective, but in addition harmful. This lets you run a script towards the file whereas opening, normally a search or one thing of that kind.
I hope this helps, I’m going to put up extra stuff as I be taught it, there’s a motive they’ve written complete books about Vim, it has a ton of options. If individuals take pleasure in the following pointers, I’ll add some extra later.
Wish to be taught extra about Linux? After all you do. Try this Linux Fundamentals course.
You may join a free trial right here and take it right this moment!
GIPHY App Key not set. Please check settings