3 karma · joined Jul 7, 2021 (5y ago) · 2 submissions
comment 5y ago · link · parent
For anyone who uses vim or anyone interested reading, because the setup is pretty simple, I managed to put together a similar setup in vim.
I'm using bookmarks.txt for web and files.txt for local files (I have a TON of pdfs, books, .md, .txt, .doc, etc. to cross reference).
For web I need to open urls with different profiles (firefox/opera/chrome).
"Add chrome folder to env variables
nnoremap <Leader>j :silent execute "!chrome <C-r><C-a>"<CR>
"Add firefox folder to env variables
nnoremap <Leader>k :silent execute "!firefox <C-r><C-a>"<CR>
For files I'm using cmd (windows) to open the files using the default applications under the cursor. "https://stackoverflow.com/questions/23316272/gvim-windows-7-netrw-open-url-under-text-cursor
"https://vi.stackexchange.com/questions/26007/getting-gx-to-open-a-url
"https://vi.stackexchange.com/questions/26052/select-word-under-cursor
"https://stackoverflow.com/questions/21224865/what-does-the-number-1-in-the-shellescape-function-mean-in-vim
nnoremap <Leader>h :silent execute '!explorer ' . shellescape(expand('<cfile>'), 1)<CR>
I picked FZF to find the files quickly in the terminal. Also using FZF Vim plugin to search tags in bookmarks.txt and files.txt. It has similar behavior to how you described swiper.From https://github.com/junegunn/fzf/blob/master/README-VIM.md#ex..., I send the FZF buffer line results to the quickfix window so results persist and jump easily to each bookmark. Use :BLines, "tag1 tag2 keyword" or "tag: tag1 tag2", <ctrl-a> selects all results, then <ctrl-q> sends it to the quickfix results.
Didn't modify the code from the example at all:
" An action can be a reference to a function that processes selected lines
function! s:build_quickfix_list(lines)
call setqflist(map(copy(a:lines), '{ "filename": v:val }'))
copen
cc
endfunction
let g:fzf_action = {
\ 'ctrl-q': function('s:build_quickfix_list'),
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
I would have liked to use the location list instead of the quickfix window. Unfortunately, I couldn't get the location list to work for the buffer lines results. Seems like it only works for file results. See: https://github.com/junegunn/fzf/issues/1885.Using <f2> to open the quickfix window. Then using <ctrl+shift+n> (next) and <ctrl+shift+p> (previous) to jump to each results.
command! -nargs=0 JojoToggleQuickFix if empty(filter(getwininfo(), "v:val.quickfix")) | copen | else | cclose | endif
nnoremap <f2> :JojoToggleQuickFix<CR>
nnoremap <C-S-n> :cnext<CR>
nnoremap <C-S-p> :cprevious<CR>
I type "bmk" and it will expand to the following snippet. title:
link:
tags:
date: @2021-07-07
description:
This is the abbreviation in vim. "Bookmark/File snippet
iabbrev bmk title:<CR>
\link:<CR>
\tags:<CR>
\date: <C-R>=strftime("@%Y-%m-%d")<CR><CR>
\description:<CR>
I setup custom syntax highlighting (title:, link:, tags:, date:, description:, and tags) for .txt files in vim. title: "Pixologic ZBrush - YouTube"
tags: @youtube @zbrush @3d @modeling @learn
link: https://www.youtube.com/c/PixologicZBrush/videos
description: Industry standard 3D sculpting application.
Also using AutoHotkey to open files in the clipboard: ;https://www.autohotkey.com/docs/misc/Clipboard.htm
:R*:````q::
run, "%Clipboard%"
return
I'm using this when I'm outside of vim.comment 5y ago · link · parent
Couple questions:
How do you handle mistyping the wrong tag? Is there something you use that could lint mistakes?
Is there a way to show all the tags that's available or you've used? Like grepping to show all the unique tags, but in emacs.
How do you handle stale links (links you no longer visit)? Delete them, move them, mark them stale or something?
If you wanted to see everything related to say tag1, tag2, keyword1, and keyword2, is there some way to like "grab" all those links and view them in a separate buffer? I guess it's more like filtering and reactively changing the list to show you what you want.