Hello everyone I hope you are best and doing well. I am m3ta_c1ph4r back with another writeup but this time I am doing a walkthrough of one tool named Vim!!. Yeah most of the people knows that it is only a text editor but it is more than that.
So there is one room in TryHackme name “Toolbox: Vim”. So today we are going to solve this room.
So there are three basic modes in Vim:
- Command mode is where you can run commands. This is the default mode in which Vim starts up
- Insert mode is where you insert i.e. write the text
- Visual mode is where you visually select a bunch of text so that you can run a command/operation only on that part of the text.
Question 1:-How do we enter “INSERT” mode?
I think you have installed vim. So before giving the answer let’s see help. Type :help and then you will see a help of vim.
So this is vim help and in this you can see for entering into insert mode you have to type i.
Question 2:-How do we start entering text into our new Vim document?
So after entering into input mode what you can do now?
Question 3:-How do we return to command mode?
Answer_3:-esc. Press esc key for changing the mode.
Question 4:-How do we move the cursor left?
Answer_4:-Press h for moving cursor left in command mode. You can use left arrow key also.
Question 5:-How do we move the cursor right?
Answer_5:-Press l for moving cursor right in command mode.
Question 6:-How do we move the cursor up?
Answer_6:-Press k for moving cursor up in command mode.
Question 7:- How do we move the cursor down?
Answer_7:-Press j for moving cursor down in command mode.
Question 8:-How do we jump to the start of a word?
So you have to move cursor to the word and then press w. You will see the cursor is at starting of the word and if you add word in between them.
Question 9:-How do we jump to the end of a word?
Question 10:-How do we insert (before the cursor)?
Answer_10:-i (insert mode)
Question 11:-How do we insert (at the beginning of the line?)
Question 12:-How do we append (after the cursor)
Question 13:-How do we append (at the end of the line)
Question 14:-How do we make a new line under the current line?
Answer_14:-o(this is going to help you a lot)
In this task You will get some answers in the help.
Question 1:-How do we write the file, but don’t exit?
Question 2:-How do we write the file, but don’t exit- as root?
Answer_2:-:w !sudo tee %
Question 3:-How do we write and quit?
Question 4:-How do we quit?
Question 5:-How do we force quit?
Question 6:-How do we save and quit, for all active tabs?
Question 1:-How do we copy a line?
Question 2:-how do we copy 2 lines?
Question 3:-How do we copy to the end of the line?
Question 4:-How do we paste the clipboard contents after the cursor?
Question 5:-How do we paste the clipboard contents before the cursor?
Question 6:-How do we cut a line?
Question 7:-How do we cut two lines?
Question 8:-How do we cut to the end of the line?
Question 9:-How do we cut a character?
Question 1:-How do we search forwards for a pattern (use “pattern” for your answer)
Question 2:-How do we search backwards for a pattern (use “pattern” for your answer)
Question 3:-How do we repeat this search in the same direction?
Answer_3:-n (this is quite helpful I think)
Question 4:-How do we repeat this search in the opposite direction?
Question 5:-How do we search for “old” and replace it with “new”
Question 6:-How do we use “grep” to search for a pattern in multiple files?
Answer_6:-:vimgrep (so you have to add word after this like “ :vimgrep hello”)
Make sure that you don’t use the commands in insert mode otherwise they will behave as text. Press esc before typing any command.