WEBVTT
Kind: captions
Language: en

00:00:00.000 --> 00:00:08.708
I use VimWiki, so everything I ever need to remember can 
be easily accessed without taking my hands off the keyboard.

00:00:09.609 --> 00:00:18.651
I just open up a terminal, enter Vim, hit the leader key 
combination, and I'm right in my own personal wiki.

00:00:18.651 --> 00:00:26.926
I can even maintain a work journal with another quick combination, 
and boom, a new diary page is ready for info.

00:00:26.926 --> 00:00:33.700
And because they're all just text files, it's trivial to sync them with 
other devices, such as my phone.

00:00:33.700 --> 00:00:35.935
It's kind of like magic,

00:00:35.935 --> 00:00:39.506
and today I'll show you how I set it up.

00:00:39.973 --> 00:00:44.978
♫ [Chiptunes and Guitars, yes that's a SID chip] ♫

00:00:45.879 --> 00:00:50.817
Greetings! And welcome to another Vimtastic episode of 
Veronica Explains. 

00:00:50.817 --> 00:00:53.586
I'm Veronica, and today I'm going to show

00:00:53.586 --> 00:00:57.757
you how I use VimWiki to keep a personal wiki filled with 
notes, 

00:00:57.757 --> 00:01:02.662
tasks, a work diary, and the scripts from these videos.

00:01:02.662 --> 00:01:08.068
I've used VimWiki for a number of years now to 
organize my thoughts right from the terminal,

00:01:08.068 --> 00:01:14.641
and because it's just generating a bunch of text files, it pairs nicely 
with file sync programs.

00:01:14.641 --> 00:01:18.578
Now, if you just want written instructions for how I set this up,

00:01:18.578 --> 00:01:23.616
I've got a blog post over on my website: vkc.sh.

00:01:23.616 --> 00:01:27.787
And I'll also be doing a VimWiki Q&amp;A stream shortly 

00:01:27.787 --> 00:01:33.560
for Patrons and Ko-Fi supporters, who make unsponsored videos like these possible.

00:01:33.927 --> 00:01:38.098
The GitHub for VimWiki, where you can download the package and view the official instructions,

00:01:38.998 --> 00:01:44.504
is at github.com/vimwiki/vimwiki.

00:01:44.504 --> 00:01:51.044
Now, you can use VimWiki with 
either Vim, or Neovim, but I tend to prefer using Vim

00:01:51.044 --> 00:01:54.147
because I'm old and it's what I know. 

00:01:54.147 --> 00:01:56.683
And as VimWiki is just a plug-in,

00:01:56.683 --> 00:01:58.718
the process of procuring the package is

00:01:58.718 --> 00:02:02.622
predicated primarily on your personal plug-in provider preferences.

00:02:02.622 --> 00:02:05.992
Now, I tend to use the native Vim packages

00:02:05.992 --> 00:02:13.867
instead of a third-party package manager because it enables 
easily updating your plugins from source via Git.

00:02:13.867 --> 00:02:19.139
If you want to see a future video about Vim plug-ins, you should 
make sure to... 

00:02:19.139 --> 00:02:21.708
hang on. I can't read the teleprompter. 

00:02:21.708 --> 00:02:26.346
[struggling to read the line]
"Insert comment farming banter here?" 

00:02:26.346 --> 00:02:31.151
To start with, I'm going to set three prerequisites in .vimrc.

00:02:31.151 --> 00:02:39.292
"set nocompatible" allows enhancements to Vim that aren't compatible with the older Vi implementation.

00:02:39.292 --> 00:02:45.398
"filetype plugin on" enables loading plugins for specific file types.

00:02:45.398 --> 00:02:52.539
And "syntax on" makes sure that syntax 
highlighting is set as expected by VimWiki. 

00:02:52.539 --> 00:02:55.508
Then just save and quit Vim.

00:02:55.508 --> 00:03:02.115
If we re-enter the file, we can see that 
syntax highlighting is working as expected. 

00:03:02.115 --> 00:03:05.385
Now since I'm using the native Vim packages,

00:03:05.385 --> 00:03:11.324
I can simply follow the  directions on Github and clone the repo into my Vim plug-ins directory.

00:03:11.324 --> 00:03:18.131
Then we can run Vim real quick with the help tags 
option to rapidly generate documentation for VimWiki. 

00:03:18.131 --> 00:03:19.499
And that's it!

00:03:19.499 --> 00:03:26.673
VimWiki's installed now, and I didn't need an external package manager. Of course, if you prefer to use a

00:03:26.673 --> 00:03:29.008
package manager, that's an option. 

00:03:29.008 --> 00:03:33.246
VimWiki is packaged all over the place and shouldn't be too hard to integrate into

00:03:33.246 --> 00:03:39.953
your existing config. I've used it with Pathogen and Vim-Plug 
in the past, and it was fine. 

00:03:39.953 --> 00:03:46.492
It's just that now that Vim has its own native packaging solution, for me, that's just what I prefer.

00:03:46.492 --> 00:03:49.429
Once it's installed, relaunch Vim, and you

00:03:49.429 --> 00:03:56.970
And you can now enter VimWiki anytime Vim is open with the command sequence, backslash-w-w. 

00:03:56.970 --> 00:04:01.274
backslash, of course, being the default leader key,

00:04:01.274 --> 00:04:05.478
which is a special key in Vim that you can allocate to plugins. 

00:04:05.478 --> 00:04:07.947
The first time you run VimWiki,

00:04:07.947 --> 00:04:12.452
it will prompt you to make a new directory. And if you 
aren't importing existing notes, 

00:04:12.452 --> 00:04:15.722
that default directory is probably fine.

00:04:15.722 --> 00:04:22.262
That said, you can customize this directory in .vimrc, and I'll show you that in a minute.

00:04:22.262 --> 00:04:27.867
When it creates a new directory, it drops you into a blank index file. 

00:04:27.867 --> 00:04:31.337
Think of this as the root of your wiki. Here you can

00:04:31.337 --> 00:04:35.608
Here you can write something in your wiki, and then when you save the file,

00:04:35.608 --> 00:04:41.948
a .wiki file is generated inside the VimWiki subdirectory of your home folder.

00:04:41.948 --> 00:04:47.020
It'll save the files here, regardless of where you were when you started Vim,

00:04:47.020 --> 00:04:49.989
and to me, I think that's pretty nice.

00:04:49.989 --> 00:04:56.629
By default, VimWiki uses a custom syntax, which admittedly isn't my favorite, and I

00:04:56.629 --> 00:05:01.000
typically swap it to Markdown, and I'll show you how I do 
that in a minute. 

00:05:01.000 --> 00:05:04.837
MediaWiki is also a syntax option, but I

00:05:04.837 --> 00:05:09.475
personally prefer Markdown, since it pairs well with external applications.

00:05:09.475 --> 00:05:12.445
With the default syntax, surrounding

00:05:12.445 --> 00:05:16.649
a header with these equal sign wings will create a 
highlighted header, 

00:05:16.649 --> 00:05:20.320
and using dual square brackets will create a link.

00:05:20.320 --> 00:05:28.094
VimWiki fully supports creating folders and customizing a file name with the familiar Markdown-like syntax,

00:05:28.094 --> 00:05:33.666
putting the file path first, then a pipe followed by the 
friendly name of the link. 

00:05:33.733 --> 00:05:40.840
In normal mode, bringing the cursor to a link and pressing enter will automatically create a new document.

00:05:40.840 --> 00:05:42.975
It's pretty slick.

00:05:43.176 --> 00:05:48.247
Lists are straightforward, and list items should be automatically generated, 

00:05:48.247 --> 00:05:52.518
and you can pretty much put any text in here that you want.

00:05:52.518 --> 00:05:58.424
A neat feature is that you can make check boxes 
with single square brackets with a space in the middle.

00:05:58.424 --> 00:06:05.798
And then from normal mode, if you hit control-space, that's 
going to check them off from anywhere on that line.

00:06:05.798 --> 00:06:14.107
And you can even nest those check boxes and make little in-progress indicators inside the parent check box. 

00:06:14.207 --> 00:06:21.314
What I like about this approach to note-taking, using the terminal instead of a GUI application like Obsidian,

00:06:21.314 --> 00:06:28.221
is that for me, it often feels less cluttered to keep the interface intentionally simple.

00:06:28.221 --> 00:06:33.159
The text is all the same size, and there's no graphics,

00:06:33.159 --> 00:06:40.967
no big headers, no lists of hashtags, no tree view 
getting in my mind's way. 

00:06:40.967 --> 00:06:45.138
Plus, I'm already in Vim anyway as it's my editor of choice,

00:06:45.138 --> 00:06:51.344
so the idea of simply dropping into VimWiki from whatever I'm working on is effectively seamless.

00:06:51.344 --> 00:06:56.816
And because it's Vim, the customization options 
are nearly endless. 

00:06:56.816 --> 00:07:00.887
There's no way I could ever cover every single customization,

00:07:00.887 --> 00:07:07.627
but I'll share the two VimWiki specific customization options that I use every day in my work.

00:07:07.627 --> 00:07:16.269
Adding customizations is done with a dictionary in the 
vimwiki_list global, which you can update in your .vimrc.

00:07:16.269 --> 00:07:22.642
Here, for instance, I've modified the syntax to be Markdown, because I spend much more time working in

00:07:22.642 --> 00:07:29.715
Markdown, and it's just an easier default for me. This 
involves modifying two variables in the list.

00:07:29.816 --> 00:07:33.920
"syntax" which we'll assign the value "markdown", 

00:07:33.920 --> 00:07:38.157
and "ext" which we'll assign the value "md". 

00:07:38.157 --> 00:07:41.227
This should tell VimWiki to create Markdown

00:07:41.227 --> 00:07:45.198
files and assign them the .md extension. 

00:07:45.198 --> 00:07:47.867
Now, while I prefer Markdown, 

00:07:47.867 --> 00:07:52.171
there is a benefit to using the default VimWiki syntax instead,

00:07:52.171 --> 00:07:55.208
and that's the built-in HTML converter. 

00:07:55.641 --> 00:07:59.712
See, you can easily generate an HTML version of your wiki thanks

00:07:59.712 --> 00:08:05.718
to the :VimwikiAll2HTML command, and you can serve this however you'd like.

00:08:06.018 --> 00:08:11.357
But only if you use the default syntax and not Markdown or MediaWiki.

00:08:11.624 --> 00:08:18.197
That said, there's no shortage of powerful tools to turn Markdown into webpages, and

00:08:18.197 --> 00:08:23.970
it's pretty trivial to use VimWiki along with whatever 
static site generator you prefer. 

00:08:23.970 --> 00:08:27.306
Maybe I'll make a video about that someday!

00:08:27.306 --> 00:08:28.808
[Windows 3.x "tada" sound]

00:08:28.808 --> 00:08:36.716
Another customization that I typically make is to change the default VimWiki folder to match my existing Nextcloud Notes folder.

00:08:36.883 --> 00:08:43.623
Nextcloud is a cool self-hosted alternative to Dropbox or Google Drive, and it has a

00:08:43.623 --> 00:08:52.632
perfectly reasonable notes application that can easily sync 
across all of my devices, including a native Android application.

00:08:52.632 --> 00:08:59.372
This gives me rapid access to my VimWiki Markdown files from virtually anywhere on the planet.

00:08:59.372 --> 00:09:07.513
I can write a note on my phone using the Nextcloud Notes app, and within seconds it's available right in VimWiki.

00:09:07.513 --> 00:09:14.253
And aside from Nextcloud, there's all sorts of reasons you might want to use a custom path for your wiki.

00:09:14.253 --> 00:09:17.757
And luckily doing so is pretty straightforward.

00:09:17.757 --> 00:09:22.795
We just add another dictionary item to the vimwiki_list global.

00:09:22.795 --> 00:09:32.772
This time, using "path" as the key, and in my case because I'm using Nextcloud, "~/Nextcloud/Notes" as the value.

00:09:32.772 --> 00:09:40.580
Of course, you should replace that directory with whatever 
makes sense for you and your needs. And if you're like me

00:09:40.580 --> 00:09:44.684
and regularly using Markdown outside of VimWiki, 

00:09:44.684 --> 00:09:49.221
you might want to add another option to .vimrc to restrict VimWiki

00:09:49.221 --> 00:09:52.024
to just the paths that we've set here. 

00:09:52.024 --> 00:10:00.533
You can do that with the global variable vimwiki_global_ext, which you can set to 0.

00:10:00.533 --> 00:10:06.138
This will restrict VimWiki's operation to only those paths listed in .vimrc,

00:10:06.138 --> 00:10:10.476
which can make the navigational tools a bit more succinct.

00:10:10.476 --> 00:10:14.947
Navigational tools like searching your wiki for specific text.

00:10:15.481 --> 00:10:18.217
Because these are ultimately just text files, 

00:10:18.217 --> 00:10:23.356
you can find notes by any UNIX-friendly means that you have at your disposal.

00:10:23.456 --> 00:10:27.660
Loads of people use ripprep for this. And that's a fine option.

00:10:27.660 --> 00:10:33.833
But VimWiki helpfully includes a search feature to search your entire wiki for a specific string.

00:10:33.899 --> 00:10:39.572
And that's :VimwikiSearch or helpfully :VWS. 

00:10:39.572 --> 00:10:42.208
From VimWiki in normal mode,

00:10:42.508 --> 00:10:48.748
simply hit colon then capital V-W-S, and then type the search pattern that you're looking for.

00:10:48.748 --> 00:10:52.685
VimWiki will automatically parse this through your entire wiki,

00:10:52.685 --> 00:10:57.723
and you can go back and forth between matches using :lnext and :lprevious.

00:10:58.157 --> 00:11:04.363
And aside from search, there's a bunch of useful 
navigation built into VimWiki. 

00:11:04.363 --> 00:11:06.465
When Vim is in normal mode,

00:11:07.099 --> 00:11:14.940
tab and shift-tab will function like they do in a web form 
and jump you from one link to the next on your page.

00:11:14.940 --> 00:11:21.681
The backspace key goes back a link in your wiki, kind of like 
having a back button for your notes.

00:11:21.681 --> 00:11:28.387
And if you're a tab stack Vim user, you can open the index in a new tab with leader-wt, 

00:11:28.387 --> 00:11:32.024
leader being set as default to the backslash key.

00:11:32.591 --> 00:11:38.431
And you can look at all of the VimWiki key bindings with 
the vimwiki-mappings help option.

00:11:38.431 --> 00:11:45.438
Some of these bindings might conflict with your terminal's defaults though, so luckily it's all very customizable. 

00:11:45.538 --> 00:11:55.915
My favorite option here is leader-w-leader-w, which opens a new diary wiki file, already named with the current date on it.

00:11:55.915 --> 00:12:05.424
I use this all the time as a work journal, keeping notes about phone calls, infrastructure bugs, and even shopping lists.

00:12:05.424 --> 00:12:12.131
And because I sync it all with Nextcloud Notes, it's pretty 
much always at my fingertips if I'm away from my computer.

00:12:12.932 --> 00:12:17.103
VimWiki's been critical infrastructure for my brain for a 
while now. 

00:12:17.103 --> 00:12:21.574
I know about a thousand commenters are probably clacking away right now,

00:12:21.574 --> 00:12:27.012
wondering why I don't use Obsidian or Evernote or something else. 

00:12:27.012 --> 00:12:32.017
And as always, *you* should use what *you* like.

00:12:32.051 --> 00:12:35.454
Years ago, learning Vim broke my brain.

00:12:35.454 --> 00:12:39.592
[chuckling]
and now whenever I don't have a modal editor, I'm missing it.

00:12:39.859 --> 00:12:47.066
But even if those fancy GUI tools supported a Vim 
binding, I don't think I'd be all that interested in switching...

00:12:47.066 --> 00:12:56.208
...when Vim and VimWiki pretty much do exactly 
what I want right now. It's just text, distraction-free.

00:12:56.375 --> 00:12:58.978
Those fancier tools are great, but...

00:12:58.978 --> 00:13:04.316
...in my opinion, it's a little like comparing a blockbuster motion picture to a good book.

00:13:04.650 --> 00:13:07.086
I mean, both are nice, don't get me wrong, 

00:13:07.086 --> 00:13:15.561
but I know that I want to spend less time being dazzled and more time with my own imagination. Maybe you do too.

00:13:15.561 --> 00:13:16.929
[Child shouting] "1, 2, 3, 4!"

00:13:16.929 --> 00:13:33.412
♫ [punk rock outro music plays] ♫

00:13:33.679 --> 00:13:36.215
From "Vick"... from "VickWiki..." 

00:13:36.215 --> 00:13:39.018
...I'm going to keep saying "VickWiki," aren't I?

