Category Archives: Vim editor

Build a personal wiki using Vim

I used to have random notes in text files scattered on the disk. Then I tried being an organized person by using things like Google Docs… but, after some time I would find myself coming back to the simple text editor when in need of quick notes. On my openSUSE laptop I would either fire up Gedit or if the terminal is already open I’d use Vim.

A few days ago while searching for some packages in the openSUSE repo, I came across the vim-plugin-vimwiki package for Vim. It turned out to be a handy plugin for the Vim text editor.

sudo zypper in vim-plugin-vimwiki

At next launch of Vim, type ww and press “enter” to start the wiki.

gVim text editor

Screenshot of gVim

A folder named “vimwiki” will be created in the home directory of the user. For example for the user “ish”, the following message will appear upon typing ww:

Vimwiki: Make new directory: /home/ish/vimwiki
 [Y]es/[n]o?

A first blank file named “index.wiki” will be created in the “vimwiki” directory. The wiki has support for links, which are created using double brackets, e.g [[Hello Wiki]]. The text between the brackets become click-able and the file “~/vimwiki/Hello Wiki.wiki” is created.

Vim Wiki links

One can navigate through the pages by pressing “enter” while the cursor is on the “link text” and using the backspace button to go to the previous page.

What about existing text files?

The existing text files can be renamed with a .wiki extension and moved to the vimwiki directory. Then use the double brackets to link to that file.

I find the Vim Wiki being a simple & effective solution to take quick (re-usable) notes in an organized manner. Surely other solutions exist but at the moment I’d stick to Vim Wiki.

The post Build a personal wiki using Vim appeared first on HACKLOG.

Getting the job done with Vim

Last Friday, Cyril pinged for an after-office beer party. It’s all legitimate for a Friday evening :-)

beer-party-talk

At my workplace I in-turn bugged Kaviraj, a networking fellow who enjoys the usual geek talks.

We finished work and reached Flying Dodo some time after 19h00. Cyril and the others had taken the table outside. We could that way enjoy the cozy weather, not too warm neither cold, listen to the live band and have a chilled beer. To make it more fun I asked for pizza.

A while later Mike joined us. Kaviraj, Mike and I got into some fun chatting about CLI tools. Mike was talking about “vi” and we shared the handy tricks when editing config files.

Commenting multiple lines in Vim

To toggle between line numbering and without line numbers, do :set nu and :set nu!. The line numbers are useful when editing config files, say when you need to comment a block of directives (e.g from line 15 to 25). You would do :15,25s/^/#/g to comment and commenting out would be :15,25s/^#//g.

In-line replacement of a word

At times you find a long word in a line which you need to replace. While your cursor is at the beginning of the word, you press cw and enter the new word. It’s replaced. Is it difficult to remember cw ? Just remember “change word” :-)

Saving with “root” privilege

Ever edited a file and while saving you realise you actually require super-privilege? It happens when you are tinkering as a regular user and the file is owned by root. If you’re a sudoer then the following could save you time:

:w !sudo tee %

The ! symbol allows you to execute shell commands and the % signifies the current file. We’re thus saying update by sending the content to the current file with sudo privilege.

Find and replace

To trigger a find we could simply do /theword and press n to hop to the next occurrence of the word. We could search the whole file for a particular word and replace all occurrences:

:%s/theword/anotherword/g

We could also limit the find & replace within a block of lines.

:15,25s/theword/anotherword/g

For more fine-tuning of the search, regular expressions would come handy.


Kaviraj & I left Flying Dodo at 21h00. That was a short moment having a geek chit-chat with like-minded folks.

Getting the job done with Vim

Last Friday, Cyril pinged for an after-office beer party. It’s all legitimate for a Friday evening :-)

beer-party-talk

At my workplace I in-turn bugged Kaviraj, a networking fellow who enjoys the usual geek talks.

We finished work and reached Flying Dodo some time after 19h00. Cyril and the others had taken the table outside. We could that way enjoy the cozy weather, not too warm neither cold, listen to the live band and have a chilled beer. To make it more fun I asked for pizza.

A while later Mike joined us. Kaviraj, Mike and I got into some fun chatting about CLI tools. Mike was talking about “vi” and we shared the handy tricks when editing config files.

Commenting multiple lines in Vim

To toggle between line numbering and without line numbers, do :set nu and :set nu!. The line numbers are useful when editing config files, say when you need to comment a block of directives (e.g from line 15 to 25). You would do :15,25s/^/#/g to comment and commenting out would be :15,25s/^#//g.

In-line replacement of a word

At times you find a long word in a line which you need to replace. While your cursor is at the beginning of the word, you press cw and enter the new word. It’s replaced. Is it difficult to remember cw ? Just remember “change word” :-)

Saving with “root” privilege

Ever edited a file and while saving you realise you actually require super-privilege? It happens when you are tinkering as a regular user and the file is owned by root. If you’re a sudoer then the following could save you time:

:w !sudo tee %

The ! symbol allows you to execute shell commands and the % signifies the current file. We’re thus saying update by sending the content to the current file with sudo privilege.

Find and replace

To trigger a find we could simply do /theword and press n to hop to the next occurrence of the word. We could search the whole file for a particular word and replace all occurrences:

:%s/theword/anotherword/g

We could also limit the find & replace within a block of lines.

:15,25s/theword/anotherword/g

For more fine-tuning of the search, regular expressions would come handy.


Kaviraj & I left Flying Dodo at 21h00. That was a short moment having a geek chit-chat with like-minded folks.