sponsor Vim development Vim logo Vim Book Ad

splitjoin.vim : A plugin that helps with switching between single-line and multiline code

 script karma  Rating 58/18, Downloaded by 5969  Comments, bugs, improvements  Vim wiki

created by
Andrew Radev
script type
Github repo is at https://github.com/AndrewRadev/splitjoin.vim

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.

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"

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

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

Into this:

    <div id="foo">

And another binding for the opposite transformation.

This currently works for various constructs in the following languages:

- C
- Coffeescript
- Elixir
- Eruby
- Go
- HTML (and HTML-like markup)
- Handlebars
- Javascript (within JSX, TSX, Vue.js templates as well)
- Lua
- Perl
- Python
- Ruby
- Rust
- SCSS and Less
- Shell (sh, bash, zsh)
- Tex
- Vimscript

For more information, including examples for all of those languages, try `:help
splitjoin`, or take a look at the full help file online at https://github.com/AndrewRadev/splitjoin.vim/blob/master/doc/splitjoin.txt

If you encounter any bugs or have an idea for a new feature, the issue tracker is on github, at https://github.com/AndrewRadev/splitjoin.vim/issues.
install details
Download splitjoin.zip.

If you're using pathogen (vimscript #2332), extract it to a directory in your bundles or just clone the git repository at https://github.com/AndrewRadev/splitjoin.vim

Alternatively, extract it to your vimfiles root (~/.vim on *nix, ~/vimfiles on Windows).

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
splitjoin.zip 1.1.0 2022-04-03 7.4 Andrew Radev - New integrations: Elm, Clojure, R, Java
- Improvements to support for: YAML, Elixir, Rust, Go, JSX, Ruby
- Filetypes that delegate to existing support: svelte, javascriptreact, typescriptreact
- Various fixes and smaller improvements
splitjoin.zip 1.0.0 2019-12-23 7.0 Andrew Radev - (Additional) support for: C#, Rust, SCSS/Less, Handlebars, PHP, Go
- Lots of bugfixes
- Documentation improvements
splitjoin.zip 0.8.0 2015-01-27 7.0 Andrew Radev - Ruby case statements
- PHP arrays
- LaTeX begin-end blocks
- Perl hashes
- Go imports
- C if-clauses, function calls
- HTML attributes
- Javascript function arguments
- Various fixes
splitjoin.zip 0.7.0 2014-01-18 7.0 Andrew Radev - Lua tables
- YAML maps
- Go support
- Simple bash support (semicolons)
- Various bugfixes
splitjoin.zip 0.6.0 2012-11-18 7.0 Andrew Radev - Default mappings: gJ and gS
- Python lists, tuples, imports
- Ruby heredocs
- HTML tags in PHP code
- Various bugfixes
splitjoin.zip 0.5.2 2012-07-14 7.0 Andrew Radev Various bugfixes
splitjoin.zip 0.5.1 2012-05-24 7.0 Andrew Radev - Split ternary operators in coffeescript
- Perl support
- Various bugfixes
splitjoin.zip 0.5.0 2012-04-09 7.0 Andrew Radev Initial PHP support, thanks to Giuseppe Rota (https://github.com/grota)
splitjoin.zip 0.4.2 2012-04-08 7.0 Andrew Radev Support for multiline strings in coffeescript
splitjoin.zip 0.4.1 2012-03-18 7.0 Andrew Radev Fix for small indenting problem with coffeescript.
splitjoin.zip 0.4.0 2012-03-18 7.0 Andrew Radev - Coffeescript support
- LESS support (same as SCSS)
- Various bugfixes
splitjoin.zip 0.3.0 2011-11-12 7.0 Andrew Radev - Support for ruby 1.9-style hashes
- Vimscript support
- Initial Lua support
- Initial YAML support
- Various bugfixes
splitjoin.zip 0.2.2 2011-08-17 7.0 Andrew Radev Bugfix for repeat.vim regression, thanks to kien (https://github.com/kien)
splitjoin.zip 0.2.1 2011-08-06 7.0 Andrew Radev Bugfix for eruby.
splitjoin.zip 0.2.0 2011-08-01 7.0 Andrew Radev - Javascript support
- Python support
- Option to omit curly braces when splitting ruby option hashes
- Refactoring and various bugfixes
splitjoin.zip 0.1.3 2011-06-30 7.0 Andrew Radev - Support for auto-aligning ruby hashes and CSS declarations using Tabular (https://github.com/godlygeek/tabular) or Align (vimscript #294)
- Support for repeat.vim (vimscript #2136) thanks to kien (https://github.com/kien)
- Various bugfixes
splitjoin.zip 0.1.2 2011-06-18 7.0 Andrew Radev - CSS support
- Various bugfixes
splitjoin.zip 0.1.1 2011-06-03 7.0 Andrew Radev Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.