In this walk through, we will be going through the Toolbox: Vim room from Tryhackme. We will learn about vim, a universal text editor that can be incredibly powerful when used properly. From basic text editing to editing of binary files, Vim can be an important arsenal in a security toolkit. So, let’s get started without any delay.
Table of Contents
Task 1 – Task 1
Question 1 – Install Vim
Done
Question 2 – Launch Vim
Done
Task 2 – Task 2
Question 1 – How do we enter “INSERT” mode?
i
Question 2 – How do we start entering text into our new Vim document?
typing
Question 3 – How do we return to command mode?
esc
Question 4 – How do we move the cursor left?
h
Question 5 – How do we move the cursor right?
l
Question 6 – How do we move the cursor up?
k
Question 7 – How do we move the cursor down?
j
Question 8 – How do we jump to the start of a word?
w
Question 9 – How do we jump to the end of a word?
e
Question 10 – How do we insert (before the cursor)
I
Question 11 – How do we insert (at the beginning of the line?)
I
Question 12 – How do we append (after the cursor)
A
Question 13 – How do we append (at the end of the line)
a
Question 14 – How do we make a new line under the current line?
o
Task 3 – Task 3
Question 1 – How do we write the file, but don’t exit?
:w
Question 2 – How do we write the file, but don’t exit- as root?
:w !sudo tee %
Question 3 – How do we write and quit?
:wq
Question 4 – How do we quit?
:q
Question 5 – How do we force quit?
:q!
Question 6 – How do we save and quit, for all active tabs?
:wqa
Task 4 – Task 4
Question 1 – How do we copy a line?
YY
Question 2 – how do we copy 2 lines?
2YY
Question 3 – How do we copy to the end of the line?
y$
Question 4 – How do we paste the clipboard contents after the cursor?
P
Question 5 – How do we paste the clipboard contents before the cursor?
P
Question 6 – How do we cut a line?
DD
Question 7 – How do we cut two lines?
2DD
Question 8 – How do we cut to the end of the line?
D
Question 9 – How do we cut a character?
x
Task 5 – Task 5
Question 1 – How do we search forwards for a pattern (use “pattern” for your answer)
/pattern
Question 2 – How do we search backwards for a pattern (use “pattern” for your answer)
?pattern
Question 3 – How do we repeat this search in the same direction?
n
Question 4 – How do we repeat this search in the opposite direction?
N
Question 5 – How do we search for “old” and replace it with “new”
:%s/old/new/g
Question 6 – How do we use “grep” to search for a pattern in multiple files?
:vimgrep
Also Read: Tryhackme – Tech_Supp0rt: 1
So that was “Toolbox: Vim” for you. We looked into the vim text editor in detail. We started off with a basic introduction, then looked into some modes vim offers. Next, we took a dive into writing, saving and editing in vim. Moving on, we looked into cut, copy and paste commands and at last had a peek on vimgrep and concluded the room. On that note, i would take your leave and will meet you in next one. Till then, “Happy hacking”.