vim-swoop by pelodelfuego

vim swoop

Vim swoop is directly inspired from helm-swoop we can find as emacs' plugin.

It allows you to find and replace occurrences in many buffers being aware of the context.

An animation means more than a boring speech...

You can edit the swoop buffer and the changes you applied will be save for all corresponding files by saving the buffer

Especially usefull to refactor a name in multiple files and keep control on it...

Usage

When you start vim-swoop (multi or single buffer mode) you get 2 windows.

First one contain context, the other is the swoop buffer. As you move the cursor to a match, the display windows will show the context.

From the swoop buffer, you can:

single buffer mode

Start in insert mode, first line contains the search pattern.

As you type the pattern, results will interactivly be displayed bellow.

multi buffer mode

Start in insert mode, first line contains the buffer pattern, no pattern means all buffers.

Buffer will be displayed interactivly bellow:

Second line contains the search pattern just like in single buffer mode:

Interactions

KeyMap

Default mapping to use vim-swoop are:

nmap <Leader>l :call Swoop()<CR>
vmap <Leader>l :call SwoopSelection()<CR>
nmap <Leader>ml :call SwoopMulti()<CR>
vmap <Leader>ml :call SwoopMultiSelection()<CR>

NB: if you are in visual mode, you will land in normal mode

You can disabledefault mapping by:

let g:swoopUseDefaultKeyMap = 0

Function

Those 2 action are also exposed by the following function:

:call SwoopPattern(pattern)

For all buffer

:call SwoopMultiPattern(searchPattern)

For specific buffer

:call SwoopMultiPattern(searchPattern, bufPattern)

Command

A third way to acces Swoop is by a direct command:

For single buffer mode

:Swoop <pattern>

For all buffer mode

:Swoop! <pattern>

Configuration

Behaviour

let g:swoopIgnoreCase = 1
let g:swoopPatternSpaceInsertsWildcard = 0
let g:swoopAutoInserMode = 0

User interface

let g:swoopWindowsVerticalLayout = 1
let g:swoopLazyLoadFileType = 0
let g:swoopHighlight = ["hi! link SwoopBufferLineHi Warning", "hi! link SwoopPatternHi Error"]
let g:defaultWinSwoopWidth = 12

or:

let g:defaultWinSwoopHeight = 15

Tips and Tricks

Interaction with other plugin or option

The main issue you will have will be displaying the context, to have compatibility 2 functions are exposed:

call SwoopFreezeContext()
call SwoopUnFreezeContext()

If you need anything else to enchance compatibility with other plugin, please open an issue.

Installation and dependencies

Vim-Swoop is a pure vimscript plugin, no other dependancies.

Pathogen

git clone https://github.com/pelodelfuego/vim-swoop ~/.vim/bundle/vim-swoop

Vundle

Plugin 'pelodelfuego/vim-swoop'

Credit

Special thanks to Shingo Fukuyama for his amazing idea which has juste been ported to vim.