Skip to content

arp242/lazy.vim

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

The really simple snippet manager.

Snippets are loaded per-filetype from g:lazy_snippets:

let g:lazy_snippets = #{
    \ go: #{
        \ err: "if err != nil {\n\treturn fmt.Errorf(\"\b: %w\", err)\n}",
    \ },
\ }

The cursor will be set to \b (that is, the BS character, 0x08). You can use \b inside ".." strings, but in '..' strings or external files you'll have to use a literal character; use <C-v><C-h> to insert one. You can use readfile() to load snippets from a file:

let g:lazy_snippets['go']['tt'] = readfile($HOME .. '/.vim/snip/tt.go')

Now press <C-s> in normal or insert mode to find a snippet based on the <cword>. If you want a different mapping:

nmap <C-t> <Plug>(lazy-insert-cword)
imap <C-t> <Plug>(lazy-insert-cword)

A popup will be shown if nothing matches. You can also use the :Lazy command to list snippets for the current filetype.

Note: many terminals eat <C-s> and will stop the terminal output (<C-q> to resume); you probably want to disable this in your shell config (setopt noflowcontrol in zsh; or stty -ixon quit undef).

Note 2: you need a fairly new Vim for this plugin to work, as I'm too lazy to make it more compatible 😅

Alternatives:

About

The really simple snippet manager

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published