VIM text editor
Morten Hansen • July 22, 2021
VIM - text editor
General use of VIM
So I've decided to move on from nano as my text-editor and over to VIM. I've used it for some weeks now and can already see the benefits of using VIM. One of the struggles in the start is how to navigate inside the editor. This has resulted in some Googling and self-study in order to find the shortkeys/hotkeys that I think would benefit me the most.
After reading online I've compiled a collection of shortkeys that I think would give me a good start in order to start using VIM. Like many other programs there is the possibility to create a ~/.vimrc file which you can modify and adjust to your own preferences! This is quite genius and can for example get VIM to open text with syntax when files are ending in the correct format, instead of having to type :syntax on every time you access the file.
I also like the possibility to run commands and edit HEX-values directly from VIM.

general
vim <filename>creates a file, or opens an existing one.:wqwrite and quitienter insert mode (write mode)o/Oenter insert mode and creates a newline under/over markerescexit current modeh,l,j,kmove cursor left,right, down, up.repeat last action~change case (ctrl + ^in order to get~)uundo last change
marking, pointer
emove cursor to the end of wordgg/Gmoves to the start/end of the file0/$move cursor to start/end of the linew/bmove cursor to the start of next/previous word)/(move cursor to end/ start of next sentence}/{moves to the start/end of next paragraphV/vmark lines / single characters
delete
xremoves one letterdremoves marked textdd/dwremoves line / wordd0removes from mark and to start of lineDremoves from mark and rest of line
copy
ycopyyw/yycopy word / liney$copy from cursor and rest of liney0copy from start of line and up to cursorp- paste in selection
windows and tabs
vim -O \<filname\> \<filname\>opens two files and splits the view in the middle.:vsplit \<filname\>splits windows with new filevim -p <\filename> <\filename\>splits view in tabs.ctrl+shift arrow/gtin order to switch between tabs.:sp <filename>opens new file and splits windows horizontalt:vsp <fileename>opens new file and splits vericalctrl + wswitch between windowsctrl + ws/ctrl + wvsplits windowctrl + wqquit window
search in file
/<text>in order to search in documentn/Nmove to next/previous hit in search result.ggn/GNjump to first/last result in search?<text>in order to search in reverse direction from current point in document
commands
:! + commandin order to run a command like ex.:! ls. If you want to specify current file just append%like ex.:! wc %.:! sh/:shellgives a shell from VIM (can be used to escalate privileges)
Hex-editing
%:!xxdto edit hex-values%:!xxd -rto return to text version (from hex)
Sources
VIM
VIM - faq
keycdn
howtoforge
rachaellappan