Skip to content

Instantly share code, notes, and snippets.

View girishji's full-sized avatar

girishji girishji

View GitHub Profile
@girishji
girishji / python.vim.md
Last active March 11, 2024 14:29
Extend scope.vim to search python files

You can extend scope.vim to fuzzy search python defs, classes, and keywords.

Place this file in ~/.vim/after/ftplugin/python.vim.

if exists('g:loaded_scope')
    import autoload 'scope/popup.vim'
    def Things()
        var things = []
        for nr in range(1, line('$'))
@girishji
girishji / find_file.vim.md
Created March 10, 2024 14:36
Async list update with fuzzy search in scope.vim

Here is a representative example of asynchronous list update, and fuzzy searching on the items using scope.vim.

This example spawns a job to obtain a list of files using fd command. Output of fd command is checked every 100ms.

import autoload 'scope/task.vim'
import autoload 'scope/popup.vim'

# Helper function: Filter a list of files using fuzzy matching on typed string
@girishji
girishji / vim9cmdline.md
Last active June 6, 2024 09:14
Vim Tip: Vim9script in Command Line

Note: This gist is now part of VimBits plugin.

As a Vim user, you might prefer the new vim9script over the legacy script, and wish to use it in the command line. While there's no direct option to switch the command line to parse vim9script, you can execute vim9script commands by simply prepending each command with vim9.

However, remember that execution occurs in the global context, not the script-local context. This means you need to declare variables with the g: prefix, like g:foo = 'bar'.

Common commands such as visual mode select ('<,'>), shell commands (!), substitution (s//), and global (g//) work as expected, even with vim9 prepended.

@girishji
girishji / HighlightedYank.md
Last active June 6, 2024 09:14
Vim Tip: Highlight on Yank -- HighlightedYank Plugin Made Easy

Note: This gist is now part of VimBits plugin.

The HighlightedYank plugin is a handy tool for ensuring that the text you intended to yank is actually yanked. This can help prevent surprises when you paste, especially if you accidentally hit the wrong keys.

Vim already has enough scaffolding now to implement this using a short snippet. Put the following code in your .vimrc.