Giter VIP home page Giter VIP logo

abridge's Introduction

This is a mirror of http://www.vim.org/scripts/script.php?script_id=4878

Easily create custom snippets automatically expanded when recognized, or use the default ones provided. No need to hit <TAB> or some other key combinations.

See GitHub for most recent version : https://github.com/justindomingue/Abridge
Animated screenshot : https://github.com/justindomingue/Abridge/blob/master/screenshot.gif

= Example Workflow

In a c or c++ file,

      for<space>i = 0,,i < 10,,++i,,

will become

      for(i = 0; i < 10; ++i) {
      
       }

Once you hit <space>, vim recognized `for` and expands the snippet as defined in abridge.vim (easily modified). ",," selects the next placeholder (you could change it to <TAB> if you wanted, see below).

= Usage

Abridge comes with some default snippets. The goal is not to be exahaustive, but rather to define commonly use snippets.

You can define your own very easily. Add the command in your .vimrc :

call Abridge("to", "from", "filetype")
        from : abbreviation (contains <1> - see note below)
          to : expanded expression
    filetype : file type on which to apply the abbreviation ('*' for all file types)
This command will create an abbreviation for to which will expand to from in file with type filetype.

Note from must contain <1>. This is where the cursor will be positioned after the expansion.

For example,

call Abridge("for","for(<1>; <2>; <3>) {<CR><4><CR>}", "c,cpp")
will expand for<non-keyword character> to

for(<1>; <2>; <3>) {
  <4>
}
Note <non-keyword character> helps vim recognize the abbreviation : <ESC>, <CR>, <space>

- Mapping

,, : go to next <\d> and substitute (if not match is found, insert ",,")

-- Disable Mapping

To overwrite the mapping keys, set g:abridge_map_keys to your preferred keys. For example,

let g:abridge_map_keys = "<tab>"

-- Disable Default Snippets

Add let abridge_default_abb = 0 to your vimrc.

abridge's People

Contributors

justindomingue avatar

Watchers

 avatar  avatar  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.