4

splitjoin.vim 1.1.0 -- A plugin that helps with switching between single-line an...

 2 years ago
source link: https://www.vim.org/scripts/script.php?script_id=3613%231.1.0
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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

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

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

created by Andrew Radev   script type utility   description 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"
    end

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">
      bar
    </div>

And another binding for the opposite transformation.

This currently works for various constructs in the following languages:

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

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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK