Coder Social home page Coder Social logo

wildfire.vim's Introduction

wildfire.vim

With Wildfire you can quickly select the closest text object among a group of candidates. By default candidates are i', i", i), i], i}, ip and it.

Learn more about text objects with :help text-objects.

Preview

Installation

Install either with Pathogen, Vundle, NeoBundle, or your favorite plugin manager.

Usage

Press <ENTER> in normal mode to select the closest text object. Keep pressing <ENTER> for selecting the next closest text object. To go the other way round, that is, to select the previously selected text object, press <BS>.

To speed things up, if you want to select the nth closest text object you can press a number followed by <ENTER> (e.g. pressing 2<ENTER> will select the second closest text object).

You can change default mappings with:

" This selects the next closest text object.
map <SPACE> <Plug>(wildfire-fuel)

" This selects the previous closest text object.
vmap <C-SPACE> <Plug>(wildfire-water)

By default, Wildfire selects any of the text objects i', i", i), i], i}, ip and it. You can decide the ones to consider with the following option:

let g:wildfire_objects = ["i'", 'i"', "i)", "i]", "i}", "ip", "it"]

Advanced usage

Sometimes considering certain kinds of text objects can be quite annoying. This is the case of Html, where, for example, you may want to select just tag objects.

Wildfire allows you to be selective about which text objects are considered with different filetypes:

" use '*' to mean 'all other filetypes'
" in this example, html and xml share the same text objects
let g:wildfire_objects = {
    \ "*" : ["i'", 'i"', "i)", "i]", "i}"],
    \ "html,xml" : ["at", "it"],
\ }

One problem with the solution above is that with html and xml files we loose the ability to select the text objects i', i", i), i] and i}. To solve this problem, Wildfire allows you to use different mappings for different text object candidates:

map <SPACE> <Plug>(wildfire-fuel)
let g:wildfire_objects = {
    \ "*" : ["i'", 'i"', "i)", "i]", "i}"]
\ }

cal wildfire#triggers#Add("<ENTER>", {
    \ "html,xml" : ["at", "it"],
\ })

Quick selection

A visual explanation often works far better than plain old words.

Preview

Wildfire does not set a default mapping for quick selection. Be sure to put something like the following line in your .vimrc:

nmap <leader>s <Plug>(wildfire-quick-select)

By default, quick selection use text objects in g:wildfire_objects to set "selection marks". Have a look at the example below if you want to use different text object without having to change g:wildfire_objects.

cal wildfire#triggers#AddQs("<leader>s", {
    \ "*" : ["i)", "i]"],
\ })

Similar plugins

Wildfire is not the only plugin who can smartly select text object. Be sure to have a look at the following plugins if Wildfire doesn't suit your needs:

wildfire.vim's People

Contributors

itchyny avatar gcmt avatar mattn avatar pgilad avatar shougo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.