Learning NVim, TryHackMe, Resources

This post will be a walkthrough of the Vim room on TryHackMe, in addition to various learning resources I find helpful.  As I encounter helpful examples for penetration testing, I will post those as well. 

  • TryHackMe room: https://tryhackme.com/room/toolboxvim
    • This room teaches you to reference the vim documentation or search the web for answers to questions about basic commands. 
  • Daniel Miessler’s  (author of infamous SecLists repo) Vim study guide: https://danielmiessler.com/study/vim/
    • This article breaks down the verb-modifier-noun language of Vim, along with an abundance of examples to reference.
  • Vim-Adventures browser game: https://vim-adventures.com/
    • Vim-Adventures is a level-based game that requires the purchase of a $25 license after Level 3.  This game focuses on a couple commands in each level (14 levels!), and makes practicing and learning Vim fun!


Neovim came preinstalled on ParrotOS, but can be installed on all operating systems from their github page: https://github.com/neovim/neovim/wiki/Installing-Neovim


The documentation for neovim says the config file is located at `$XDG_CONFIG_HOME/nvim/init.vim` but the environment variable $XDG_CONFIG_HOME was not set by default on my OS.  Instead, the configuration file can be found in my home directory: /home/.config/nvim/init.vim

Here are the contents of my configuration file:

set number

set expandtab
set autoindent
set softtabstop=4
set shiftwidth=2
set tabstop=4

"Enable mouse click for nvim
set mouse=a
"Fix cursor replacement after closing nvim
set guicursor=
"Shift + Tab does inverse tab

"See invisible characters
set list listchars=tab:>\ ,trail:+,eol:$

"set the absolute path for swap files
set directory^=$HOME/.config/nvim/tmp//
"highlight search results
set hlsearch
"ignore case in search results
set ignorecase
"show search results as you type
set incsearch


Some of these configuration settings are recommended by Daniel Miessler.  He also recommended to swap the ESC key for ‘jk’ so that your fingers never leave the home-row, but because I am learning this for pentesting, and would likely use the preinstalled vim or vi on target machines, I did not want to modify any keys from default.  Another recommendation is to remap the modifier key ‘/’ to the single quote (‘) but I am choosing to leave the key mappings as default.  

TryHackMe | Toolbox: Vim Room

Most of the answers were found by referencing the vim help documentation (:help command) which has a web version on https://vimhelp.org/.  The other answers were found by referencing https://vim.famdom.com/wiki/.  

Task 2


How do we enter “INSERT” mode?
How do we start entering text into our new Vim document?
How do we return to command mode?

How do we move the cursor?
h left
j down
k up
l right

How do we jump to the start of a word?
How do we jump to the end of a word?

How do we insert (before the cursor)
How do we insert (at the beginning of the line?)
How do we append (after the cursor)
How do we append (at the end of the line)
 How do we make a new line under the current line?


https://vimhelp.org/editing.txt.html (writing, write-quit)
How do we write the file, but don’t exit?
How do we write the file, but don’t exit- as root? https://stackoverflow.com/questions/2600783/how-does-the-vim-write-with-sudo-trick-work
:w !sudo tee %
How do we write and quit?
How do we quit?
How do we force quit?
How do we save and quit, for all active tabs?

Task 4

How do we copy a line?
how do we copy 2 lines?
How do we copy to the end of the line?
How do we paste the clipboard contents after the cursor?
How do we paste the clipboard contents before the cursor?
How do we cut a line?
How do we cut two lines?
How do we cut to the end of the line?
How do we cut a character?

Task 5

How do we search forwards for a pattern (use “pattern” for your answer)
How do we search backwards for a pattern (use “pattern” for your answer)
How do we repeat this search in the same direction?
How do we repeat this search in the opposite direction?
How do we search for “old” and replace it with “new” https://vim.fandom.com/wiki/Search_and_replace
How do we use “grep” to search for a pattern in multiple files?

Leave a Reply