Vim weekly tips - 2

  about 359 words   2 min

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]


Did you know that you can have the same kind of behaviour in vim.

How ?

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
  (O)k, (L)oad File, Load (A)ll, (I)gnore All:

Neaaaat !

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/
  :    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

Vim weekly tips

Vim weekly tips is a series of small articles that I intend to write every week to share tips about my favorite editor : Vim I want to start this collection by showing you one feature that a lot of people don't know about. In Vim, you can use the large panel of external commands available in the *nix ecosystem inside your terminal.

Read more

Vim, the only editor I use.

People around me know that I love to spend time in terminals. For them, I am probably a nerd that do a lot of obscure stuff in these little black windows. A lot of friends that look at my screen have the same reaction : Your computer doesn't work What the hell are you doing ? Can't you just have a normal laptop Since I'm using awesome as a window manager it keeps them even more dubious about how I'm using a computer.

Read more

Bypass firewall rules

At work, they changed a firewall and added a rule to block Youtube. I'm fine with that but some colleagues are quite annoyed by that change. They really want to watch tutorials or kitten on Youtube. What I like about ssh is how it helps you to bypass a lot of things 😉 What a lot of people don't know about ssh is that it include a SOCKS proxy out of the box that you need to configure in your browser to bypass a restriction.

Read more