notes vim Notational Simplicity Nota

Found at: demu.red:70/blog/023-notational-velocity-linux-solution.md

Title: A Notational Velocity Stopgap Solution for Linux
Date: 2021-04-12 12:00
Category: notes
Tags: notes, CLI, vim
### Notational Velocity's Simplicity
[Notational Velocity] was a great tool I started using back in the days of yore, when I was on iBook running Mac OS X 10.4.
At its core you have three parts: A search box, a notes list, and a view of the selected note.
By typing in the search box you limit the listed notes to ones whose title/contents matched.
When you selected a note you started editing it, and if there was no match you started editing a new note.
Everything after that feature set is extras.
Due to how simple this setup is, it is also trivial to use :w
your file syncing method of choice ([syncthing] for me) to have your notes in other places.
### Linux
There have been a number of kludgey, mostly GUI alternatives to Notational Velocity.
Sadly many of the alternatives I tried attempt to do extras in an annoying way (forcing .md), didn't work well (glitchy), etc.
[NVpy] was one of the contenders, and at the time -- a few years ago now -- it just didn't function well.
[QOwnNotes] is one I came across recently and seems like it would be decent if you were just starting out moving to this note system. That being said, it does kind of do a *lot* at once.
Also, it does have some hiccups like requiring a restart after changing settings...
#### Previous Solution
Until recently I had been using `tv3` -- a resuscitation of [Terminal Velocity] -- to fill my note taking need.
`tv3` was a fork of the project to update for python3, but the original tv3 fork recently was deleted from github.
Anyway, Terminal Velocity had a nice little ncurses UI that gave you the search box and list, and would drop you into your `$EDITOR` when you selected your note.
### Finding a New Option
Unfortunately notational-fzf-vim has more dependencies than I want my vimrc to require...
Currently my vimrc can be dropped on a new workstation and automatically [vundle] install my plugins, and this would break that.
Down the road I might consider writing a per machine test for my vimrc, but not for now.
### A New Stopgap Solution
While what I came up with is lacking a few things, such as searching the contents of a file at the same time it is doing file name searches, it seems pretty decent for a few lines of code.
Here is the excerpt containing my shell function:
    ### Note ### {{{
    ## An aproximation of Notational Velocity and Terminal Velocity
    ## gensub currently replacing
    function note() {
        pushd ~/Notes 1>/dev/null && \
        vim $(fzf -i --cycle --reverse --preview-window=down --preview='cat {}' --print-query | gawk 'END{if($0 !~ /.txt$/){$0=gensub(" ","_","g",$0) ".txt"}; print $0}')
        popd 1>/dev/null
    ### End Note ### }}}
#### Function Explained
Starting from the edges and working in:
* `pushd`/`popd` - ensures we iterate over the notes directory or exit
* `vim` - which opens/makes the file returned
* `fzf` - to give us a nice Notational Velocity like UI and limit search
* `awk` - using magic to return either the file, or the new file name with spaces replaced.
### Conclusion
While there are some things missing, this certainly seems like a minimum viable replacement for my needs.
One which should have a low chance of no longer working in a few years too.
### Links
[Notational Velocity]  
[Terminal Velocity]  
[Notational Velocity]: https://notational.net/
[nvALT]: https://brettterpstra.com/projects/nvalt/
[syncthing]: https://syncthing.net/
[NVpy]: https://pypi.org/project/nvpy/
[QOwnNotes]: https://www.qownnotes.org/
[Terminal Velocity]: https://github.com/vhp/terminal_velocity
[notational-fzf-vim]: https://github.com/alok/notational-fzf-vim
[vundle]: https://github.com/VundleVim/Vundle.vim
[fzf]: https://github.com/junegunn/fzf