Code Monkey home page Code Monkey logo

splitjoin.vim's Introduction

Build Status

Usage

This plugin is meant to simplify a task I've found too common in my workflow: switching between a single-line statement and a multi-line one. It offers the following default keybindings, which can be customized:

  • gS to split a one-liner into multiple lines
  • gJ (with the cursor on the first line of a block) to join a block into a single-line statement.

I usually work with ruby and a lot of expressions can be written very concisely on a single line. A good example is the "if" statement:

puts "foo" if bar?

This is a great feature of the language, but when you need to add more statements to the body of the "if", you need to rewrite it:

if bar?
  puts "foo"
  puts "baz"
end

The idea of this plugin is to introduce a single key binding (default: gS) for transforming a line like this:

<div id="foo">bar</div>

Into this:

<div id="foo">
  bar
</div>

And another binding (default: gJ) for the opposite transformation.

This currently works for:

  • Various constructs in Ruby and Eruby
  • Various constructs in Coffeescript
  • Various constructs in Perl
  • Various constructs in Python
  • PHP arrays
  • Javascript object literals and functions
  • Tags in HTML/XML
  • CSS, SCSS, LESS style declarations.
  • YAML arrays and maps
  • Lua functions and tables
  • Go structs
  • Vimscript line continuations
  • TeX blocks
  • C if clauses and function calls
  • Do-blocks in Elixir

For more information, try :help splitjoin, or take a look at the help file online at doc/splitjoin.txt

For more examples and corner cases, you can explore the "examples" directory here: examples. It's not present in the downloadable zip file to avoid cluttering your vimfiles with useless stuff.

Contributing

If you'd like to hack on the plugin, please see CONTRIBUTING.md first.

Issues

Any issues and suggestions are very welcome on the github bugtracker.

splitjoin.vim's People

Contributors

andrewradev avatar lfdm avatar cehoffman avatar hardenedapple avatar kien avatar sietse avatar shemerey avatar grota avatar glittershark avatar kazark avatar deris avatar naquad avatar sktocha avatar

Watchers

James Cloos 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.