2021-07-27

Vim-Netrw and the notes folder

VIM has its own built-in file explorer, Netrw, which is installed by default and not as a plugin. Typically you can open Netrw by typing :Explore in normal mode, in my .vimrc file I remapped the keystroke combination leader e to open the explorer window on the left-hand side of the current buffer.

    nnoremap <leader>e <esc>:Lexplore<cr>
    

Wintermnote (version > 0.1.2) includes the following .vimrc in the selected notes folder.

    let g:netrw_banner = 0
    let g:netrw_list_hide = '\=/\=$,tags,.pickle,.ico,.ini,.vimrc,.bib'
    let g:netrw_hide = 1
    let g:netrw_browse_split = 2
    let g:netrw_altv = 1
    let g:netrw_liststyle = 4
    let g:netrw_menu =1
    let g:netrw_winsize = 40
    "netrw will set the browsing directory to the working directory.
    let g:netrw_keepdir= 0

    " please no folding
    set nofoldenable
    let g:session_autoload = 'no'  
    

This .vimrc extension located in the notes directory is automatically sourced with:

   set exrc

in the main .vimrc file. Now, when I open my VIM file explorer it will just show my notes and filter out all the support files. This gives me another option for browsing my saved notes as shown in the video below.

WinSCP

Netrw has the ability to read and write text files located across the network, as an example,

   :Nread stfp://username@server.com/.vimrc

it will open locally the remote .vimrc file. On Windows, sftp is usually located in the directory C:\Windows\System32\OpenSSH, alternatively can be installed via Cygwin/Msys2/Mingw64.

Another option for editing remote files is to use WinSCP, it can be installed from the PowerShell command line with :

   winget install winscp

Wintermnote provides a simple script that opens urls, email, and sftp remote files, when you press l in the note's menu, as shown below.