0

I have a big sheet of data that I constantly input more into. It gets to a point that is hard to use, especially when I do a search of a certain topic.

I am having tough time managing the data of the same topic were entered several time at different location.

I know there are line number on the left side telling me this data is at which line. But it is hard for me to imagine and remember numbers.

Is there way to have vim to display where on page the search results are located "graphically" ?

I found Kate has this very good side bar that enables me to know where the search results are located. Hence I purposely switch to kate just to group my "duplicated topics."

I did it in kate within a few seconds, while in vim, I got dizzy from navigating the search results (it "scrolls" so fast, and there is not indicator at which position the cursor now is).

enter image description here

0

2 Answers 2

2

The feature in your screenshot (in Kate editor) is called “minimap” and it was introduced/popularized by the SublimeText editor.

There are a few implementations of minimap for Vim, but they tend to have a few limitations. Since Vim is primarily an editor for the terminal, it doesn't really support displaying multiple font sizes in the same window, which can make it hard to implement exactly this feature.

Still, take a look at the following plug-ins, see if any of them helps:

  • wfxr/minimap.vim: This is a modern, well maintained plug-in, with focus on good performance. It uses block characters to try and produce a file outline that lets you see some structure from line lengths and blank lines. It requires installation of a separate program called code-minimap, which is written in Rust, so you might have to do some work to install this additional external dependency.

  • severin-lemaignan/vim-minimap: This is a similar plug-in, but uses a Python library to produce the minimap (and requires a Vim with +python3 support.) It's not a very active project anymore, it doesn't seem to have gotten any updates in a couple of years, as of this writing.

  • koron/minimap-vim: This is a different style of plug-in. Instead of using block characters to produce an outline of the file, it shows the actual contents of the file using a very small font. Due to the limitations of Vim (not being able to mix up font sizes), it implements this by opening a second, separate window, running GVim/MacVim, and it adds hooks to keep the two windows (two instances of GVim/MacVim) in sync. Since it relies on multiple windows and changing font sizes, it only works with GVim/MacVim and not the terminal version of Vim. This plug-in hasn't had updates in quite a few years, so not sure how much luck you'll get trying to run it, and I'd expect it might not work (without modifications) on NeoVim, even while using a GUI version such as neovim-qt.

3
  • 1
    Wonderful.. minimap.. Thanks. the first minimap already makes me smile.. it looks just like the one in kate.. Maybe just what i want. My friend told me once that by adding plug in into vim, it will makes it not as stable as it is... and slower .. I have never use any plug in before. no idea how to use it.. i only have scripts in vimrc.. Will this plugin bring any con to vim may i ask ? Thx
    – purityKEF
    Dec 31, 2021 at 22:25
  • Well maintained and popular plug-ins should be just fine. In particular, the first one seems to be focused on performance, so I doubt it would be using some implementation that might slow down your text editing... (Sure, it's possible for plug-ins to big down your Vim, for example if they do a lot of operations on every keystroke, and some plug-ins have a hard time avoiding that. Doesn't seem to be the case here.)
    – filbranden
    Dec 31, 2021 at 22:32
  • 1
    I have installed wfxr/ minimap.vim plugin for vim.. it is wonderful. I am using new vim, hence i install it natively (no plugin manager used). It just work. *However, because the content of my file is way way too long, hence i need to page up 3 times in order for the minimap to move a step . Any search result within 3 pages; minimap will not be moving. *This file will only get longer and longer,, hence it the future, it will be more page up/down for minimap to move 1 step. Anyway, so far it works that's the most important. Thx for the recommendation.
    – purityKEF
    Feb 4, 2022 at 21:02
1

Not a direct answer, but a good way to have vim 'remember' a particular line (and column) is to use 'marks (think 'bookmarks' in the file). See :help mark-motions.'

You can set one mark for each letter on the keyboard. When you set one, it 'marks' where the cursor is. So to set the 'a' mark, you would do: ma and then jump to it again with 'a to get to the same line.

Using an uppercase letter for a mark means it's a global mark and you can use 'A to jump to it from an entirely different file.

1
  • 1
    I do use mark myself.. but i don't think it will be of any help when i need to "visualize" where my search results are located.
    – purityKEF
    Dec 31, 2021 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.