Save read-only edited in vi/vim
w !sudo tee %
What the command does:
:w = Write a file.
!sudo = Call shell sudo command.
tee = The output of the vi/vim write command is redirected using tee.
% = Triggers the use of the current filename.
Simply put, the ‘tee’ command is run as sudo and follows the vi/vim command on the current filename given.
Navigating in vim
ctrl uandctrl dto scroll up & down.Ggoes to the last line.gggoes to the first line.%, which moves to the next or previous related item.- Move to the end of the next word, use
e. The opposite isb
Delete till next character
:d]}
Here d means delete, ] till you find next character which is }