• One of the crucial skills to have when it comes to productivity, is note-taking. Whether you’re a student, a start-up creator or an experienced programmer , you will still find a space where you could to tweak your workflow.

In this post I’ll try to explain how to set up some tools and shell scripts that will boost your note-taking skills.

1. Organize your workflow

It’s really tempting for people to multitask … Or jump all over the place and not truly focus on the task at hand. This is not the right approach for several reasons :

  • Multitasking is a Waste of Time When you distractedly attempt to complete small tasks while also trying to complete a large one, you’ll soon see how they actually eat up more of your time rather than saving it. The mind has to reset to each task following the shift.

  • Inconsistent results Research by Stanford University concluded that heavy multitaskers couldn’t filter out irrelevant information and that affected their results in various tasks. Your results could be affected if you constantly try to keep several things on the go at once.

There are many other reasons but this is not what this post is about !

I was a multitasker myself or at least i can’t help it but to think about solutions of other things I’ll be doing.

This is where this shell script might come in handy!

Quickly write down whatever thoughts you might be having without disrupting your workflow.

2. NoteTaker

note="$HOME/doc/notes/note-$(date +%Y-%m-%d).md"
# We check if the file created exists and it's a regular file
# Each time we execute the script it'll have as title the current date
if [ ! -f $note ]; then
    echo "# Notes For $(date +%Y-%m-%d)" > $note
nvim -c "norm Go" \
    -c "norm Go## $(date +%H:%M)" \
    -c "norm G2o" \
    -c "norm zz" \
    -c "startinsert" $note

Code explanation

note="$HOME/doc/notes/note-$(date +%Y-%m-%d).md"

Here we have created a variable note that holds as value the name of the file as well as the date when it’s written.

nvim -c "norm Go" \
    -c "norm Go## $(date +%H:%M)" \
    -c "norm G2o" \
    -c "norm zz" \
    -c "startinsert" $note

nvim is a command line text editor similar to vim ( a fork of vim )

  • -c to execute the following nvim commands
  • norm is nvim normal mode or what we would usually type when editing a text file with nvim
  • Others are nvim navigation keys …

To run the script above

#I have named mine "notetaker"
chmod +x notetaker # Making the file an executable

3. Installation

Now let’s talk about the actual setup:

I’ll be using pandoc vim and a vim plugin called vimwiki.

  • Pandoc is a free-software document converter.

    • We will use pandoc to convert our markdown notes to either a nice webpage or pdf files.
    • Install Pandoc (Both MacOs and Windows are supported)
  • Vim a terminal based text editor.

  • Vimwiki is a personal wiki for Vim


Get started with Pandoc and vim

# Convert file to PDF (the output format is determined by file extension):
pandoc input.md -o output.pdf

Here is a simple script that converts markdown files to Html pages with nice CSS.

# The first cmd-line argument will be the name of the html file
# Toc ( enabling the table of content for better content referencing )
pandoc --toc \
	--metadata title="$(basename ${VAR%.html})" \
	-f markdown -t html5 ${VAR} -o $filename \
# -s or --self-contained will merge the css and html to one file 
	--self-contained \
$BROWSER $filename & 

Here is the link of the style.css file used. (The same one of the official vimwiki).

This script is better used with vim to quickly convert files within vim. Put this in your .vimrc file or init.vim for nvim.

augroup fileau
    autocmd FileType markdown nnoremap <leader>p :!pandoc_md_to_html %<cr>
augroup END

This will map <leader>p to run that command. (Don’t know what’s a vim leader key ? Click here)

Code explanation

  • autocmd are vim auto-commands that will be available whenever you open a markdown file.
  • nnoremap maps that key binding in the normal mode. (non recursively)
  • ! to execute external commands within vim
  • % means the name of the current file

So !pandoc_to_html %<cr> is equivalent to pandoc_to_html somefile.md from your shell.

Similarly you can create a script that converts markdown files to PDF files and have a vim keybinding for it. Here is an example:

# Zathura is a minimal pdf viewer ( with vim keybindings )
pandoc --toc $VAR -f markdown -t pdf -s -o $pdfname && zathura $pdfname &

How do I use markdown syntax for my wikis?

You have to configure your wiki(s) in your vimrc, then you can configure syntax and file extension. To set them to markdown and .md add the following configuration to you vimrc:

let g:vimwiki_list = [{'path': '~/vimwiki/',
                      \ 'syntax': 'markdown', 'ext': '.md'}]

Vimwiki considers every markdown-file as a wiki file

Vimwiki has a feature called “Temporary Wikis”, that will treat every file with configured file-extension as a wiki. To disable this feature add this to your vimrc:

let g:vimwiki_global_ext = 0

4. VimWiki Cheatsheet

[number] refers to the wiki number, set by the order in your vimrc. The default is 1.

Wiki Management

  • [number] <leader> ww - open wiki index file
  • [number] <leader> wt - open wiki index file in new tab
  • <leader> ws - list and select available wikis
  • <leader> wd - delete wiki page
  • <leader> wr - rename wiki page

Diary management

  • [number] <leader> wi - open diary index file for wiki
  • <leader> w <leader> i - update current diary index
  • [number] <leader> w <leader> w - open today’s diary file for wiki
  • [number] <leader> w <leader> t - open today’s diary file for wiki in new tab
  • <C-Up> - open previous day’s diary
  • <C-Down> - open next day’s diary
  • <CR> - follow/create wiki link
  • <C-S-CR> - follow/create wiki link in new tab
  • <backspace> - go back to previous wiki page
  • <Tab> - go to next link on current page
  • <S-Tab> - go to previous link on current page

Editing shortcuts

  • <C-Space> - toggle list item on/off
  • = - add header level
  • - - remove header level
  • + - create/decorate links
  • glm - increase indent of list item
  • gll - decrease indent of list item
  • gl* or gl8 - switch or insert “*” symbol
  • gl# or gl3 - switch or insert “#” symbol
  • gl- - switch or insert “-“ symbol
  • gl1 - switch or insert “1.” symbol

Table shortcuts

  • <A-Left> move column left
  • <A-right> move column right
  • <CR> (insert mode) go down/create cell
  • <Tab> (insert mode) go next/create cell
  • gqq or gww reformat table

Text objects

  • ah section between 2 headings including empty trailing lines
  • ih section between 2 headings excluding empty trailing lines
  • a\ table cell
  • i\ inner table cell
  • ac table column
  • ic inner table column