With the COVID-19 rise during last week and different government announcements, I was quie busy organizing my personal life and work. But here we are and her come some the weekly tips !
I'm a big fan of zsh and on my own servers I use it exclusively instead of bash. The first tip this week is one that will remind you a zsh behaviour.
zsh completion style menu
If you're a zsh user, you are probably familiar with the completion menu style that displays all suggestions as soon as you hit the TAB key.
05:15:06 ~/terraform-skel [master] % ls [tab] files env/ instances.tf main.tf output.tf README.md sg.tf variable.tf vpc.tf
Did you know that you can have the same kind of behaviour in vim.
Just add these two lines in your .vimrc :
set wildmenu set wildmenu=full
Now if you type an :Ex Command, you should be able to scroll through all of the suggestions that vim finds for you.
Save a file as root
Everybody once in a while opened a file in /etc to change a quick conf and got stucked because he opened it with a regular user and not as root. In that case, here what you can do instead of quitting your session and changes and opening it again as root or sudoing it :
:w !sudo tee % >/dev/null Password: (O)k, (L)oad File, Load (A)ll, (I)gnore All:
Command line window
Last little tip of this week is about the command line window.
A useful way te execute again a command is to use the command line window.
In command mode, just press q: and you will see a pop window at the bottom of your screen that gets the focus. Basically, that windows helps you to go through the last :Ex commands you typed and executes them by hitting [Enter].
: 6 q! : 5 read content/about.md : 3 w : 2 q : 1 w
As any buffer in Vim, you can change one of your last command and hit [Enter] key to get it executed. Just try it !
Voila ! That's all for this week 😉
vim tips editor