### Install splitjoin.vim Manually (Vim Packages) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/README.md Provides the command to manually install the splitjoin.vim plugin by cloning it into the Vim 'start' directory. This method ensures the plugin is automatically loaded. ```bash git clone https://github.com/AndrewRadev/splitjoin.vim ~/.vim/pack/_/start/splitjoin ``` -------------------------------- ### Install Dependencies and Run Tests with Bundler Source: https://github.com/andrewradev/splitjoin.vim/blob/main/CONTRIBUTING.md Commands to install project dependencies using bundler and then execute the test suite with RSpec. ```shell $ bundle install $ bundle exec rspec spec ``` -------------------------------- ### Install Bundler Source: https://github.com/andrewradev/splitjoin.vim/blob/main/CONTRIBUTING.md Command to install the bundler gem, a dependency manager for Ruby projects. ```shell $ gem install bundler ``` -------------------------------- ### Install splitjoin.vim with vim-plug Source: https://github.com/andrewradev/splitjoin.vim/blob/main/README.md Instructions for installing the splitjoin.vim plugin using the vim-plug plugin manager. This is a common method for managing Vim plugins. ```vimscript Plug 'AndrewRadev/splitjoin.vim' ``` -------------------------------- ### Run Tests Automatically with Guard Source: https://github.com/andrewradev/splitjoin.vim/blob/main/CONTRIBUTING.md Command to start Guard, which automatically re-runs tests when spec or source files are changed. ```shell $ bundle exec guard ``` -------------------------------- ### Vimscript: Customizing Split/Join Mappings Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Configuration example for global settings to define custom key mappings for splitting and joining actions. ```vimscript let g:splitjoin_split_mapping = 'cS' let g:splitjoin_join_mapping = 'cJ' ``` -------------------------------- ### Splitting Ruby Hash Example Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates splitting a Ruby hash into a more readable multiline format. The cursor position influences the split outcome for Ruby hashes. ```ruby { :one => 'two', :three => 'four' } ``` ```ruby { :one => 'two', :three => 'four' } ``` -------------------------------- ### FASTA Sequence Formatting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates the structure of FASTA sequence entries, including header lines starting with '>' and the subsequent sequence data. ```fasta > E.coli_K12 Cysteine--tRNA ligase MLKIFNTLTRQKEEFKPIHAGEVGMYVCGITVYDLCHIGHGRTFVAFDVVARYLRFLGYKLKYVRNITDIDDK... > E.coli_K12 Cysteine--tRNA ligase MLKIFNTLTRQKEEFKPIHAGEVGMYVCGITVYDLCHIGHGRTFVAFDVVARYLRFLGYK LKYVRNITDIDDKIIKRANENGESFVAMVDRMIAEMHKDFDALNILRPDMEPRATHHIAE ... ``` -------------------------------- ### Configure splitjoin.vim Mappings in Vim Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt This Vimscript example shows how to configure custom mappings for the Splitjoin.vim plugin's split and join commands. It also demonstrates how to disable default mappings and assign new ones for joining and splitting lines, offering flexibility in workflow. ```vimscript let g:splitjoin_split_mapping = '' let g:splitjoin_join_mapping = '' nmap j :SplitjoinJoin nmap s :SplitjoinSplit ``` ```vimscript nmap sj :SplitjoinSplit nmap sk :SplitjoinJoin ``` -------------------------------- ### Joining Ruby Hash within If Statement Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows an example of joining a multiline Ruby hash within an 'if' statement. The documentation notes that joining is typically initiated from the start of the structure (e.g., the opening brace). ```ruby if foo? { :one => :two, :three => :four } end ``` -------------------------------- ### C If Clause Splitting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Provides examples of splitting C 'if' clauses into multiple lines for better readability. This functionality aims to improve the formatting of complex conditional statements. ```c if (val1 && val2 || val3); ``` ```c if (val1 && val2 || val3); ``` -------------------------------- ### Vimscript: Disabling Join Functionality for Filetype Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Example of setting a buffer-local variable to disable the join functionality for a specific filetype (e.g., Ruby). ```vimscript let b:splitjoin_join_callbacks = [] ``` -------------------------------- ### Configure HTML Attribute Hanging Style (splitjoin.vim) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Determines if the first HTML attribute stays on the same line when splitting (1, 'hanging' style) or if all attributes start on new lines (0, default). ```vim let g:splitjoin_html_attributes_hanging = 1 ``` -------------------------------- ### Configure Ruby Hanging Arguments Style Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Determines the style for splitting function arguments. A value of 1 (default) uses the 'hanging' style where subsequent arguments are indented. A value of 0 places each argument on a new line, aligned to the start of the arguments list. ```vimscript let g:splitjoin_ruby_hanging_args = 0 ``` -------------------------------- ### Go Struct Initialization Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates the initialization of structs in Go, showing both inline and multi-line assignments. ```go StructType{one: 1, two: "asdf", three: []int{1, 2, 3}} StructType{ one: 1, two: "asdf", three: []int{1, 2, 3}, } ``` -------------------------------- ### Manually Load splitjoin.vim (Vim Packages) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/README.md Shows how to manually load the splitjoin.vim plugin if it has been placed in the 'opt' directory of Vim's packages. This requires an explicit command in the .vimrc. ```vimscript packadd splitjoin ``` -------------------------------- ### Initialize and Update Git Submodules Source: https://github.com/andrewradev/splitjoin.vim/blob/main/CONTRIBUTING.md Commands to initialize and update git submodules, which are necessary for the testing environment. ```shell $ git submodule init $ git submodule update ``` -------------------------------- ### Vimscript Dictionary and Command Splitting/Joining Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates splitting and joining of Vimscript dictionaries and commands, showing how multi-line structures are handled. ```vimscript let example_one = { \ \'one': \'two\', \ \'three': \'four\' \ } " is joined (one line at a time) into: let example_one = { \'one\': \'two\', \'three\': \'four\' } command! Foo if one \ \ \'two\' \ \ else \ \ \'three\' \ \ endif " is joined (one line at a time) into: command! Foo if one \| \'two\' \| else \| \'three\' \| endif ``` -------------------------------- ### Structs (Rust) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates splitting and joining Rust struct initializations. The plugin handles both single-line and multi-line struct definitions. ```rust Scanner { source: String::new(), line: 1 } Scanner { source: String::new(), line: 1 } ``` -------------------------------- ### CUE: Split/Join Structs Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates splitting and joining CUE structs, which are similar to JSON objects but with a cleaner syntax. ```cue a: foo: { x: bar: baz: bool, y: bar: baz: int, z: bar: baz: string } a: foo: { x: bar: baz: bool y: bar: baz: int z: bar: baz: string } ``` -------------------------------- ### Function Definitions, Calls, and Arrays (Rust) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates splitting and joining for Rust function definitions, calls, and array literals. It supports generic functions and different ways of calling them. ```rust fn function_call(values: Vec, s: &'static str) -> (); fn function_call( values: Vec, s: &'static str, ) -> (); function_call(Vec::::new(), &ref); function_call( Vec::::new(), &ref, ); vec![one, two, three]; vec![ one, two, three, ]; ``` -------------------------------- ### LaTeX Begin-End Block Splitting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates splitting of LaTeX 'align*' environments with multi-line content. ```tex \begin{align*} x = y\ y = z \end{align*} \begin{align*} x = y\ y = z \end{align*} ``` -------------------------------- ### Match Clauses (Rust) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows how the plugin handles splitting and joining Rust `match` clauses, including simple patterns and those with block bodies. ```rust match one { Ok(two) => some_expression(three), } match one { Ok(two) => { some_expression(three) }, } ``` -------------------------------- ### Elixir: Split/Join Do-blocks Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates splitting and joining Elixir do-blocks for various constructs like functions, lets, and if statements. ```elixir def function(arguments) when condition, do: body def function(arguments) when condition do body end let :one, do: two() |> three(four()) let :one do two() |> three(four()) end if(foo, do: bar, else: baz) if foo do bar else baz end ``` -------------------------------- ### Hare Function Definitions, Calls, and Arrays Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows Hare syntax for function definitions, function calls, and array literals, including multi-line formatting. ```hare fn function_def(values: []u8, s: str) void = {}; fn function_def( values: []u8, s: str, ) void = {}; function_call(values: []u8, s: str); function_call( values: []u8, s: str, ); let x = [1, 2, 3]; let x = [ 1, 2, 3, ]; ``` -------------------------------- ### Closures (Rust) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates splitting and joining Rust closures, including those with single expressions and block bodies. ```rust function_call(|x| x.to_string(), y); function_call(|x| { x.to_string() }, y); ``` -------------------------------- ### Empty Matches and If-Let (Rust) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows how the plugin handles splitting and joining for `if let` statements and empty `match` patterns in Rust. ```rust if let Some(value) = iterator.next() { println!("do something with {}", value); } match iterator.next() { Some(value) => { println!("do something with {}", value); }, _ => (), } ``` -------------------------------- ### CUE: Split/Join Lists Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates splitting and joining CUE lists, which behave like JSON lists. ```cue foo: [ 'x:y:z', "\xFFFF0000", a.foo.y ] foo: [ 'x:y:z', "\xFFFF0000", a.foo.y ] ``` -------------------------------- ### Go Import Statements Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows different ways to declare import statements in Go, both single and grouped imports. ```go import "fmt" import ( "fmt" ) ``` -------------------------------- ### Go Variable Declarations Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates variable and constant declarations in Go, including single and grouped declarations. ```go var foo string var ( foo string ) ``` -------------------------------- ### Split/Join Perl Word Lists Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Formats Perl word lists created with `qw()` by splitting elements onto new lines. ```perl my @var = qw(one two three); ``` ```perl my @var = qw( one two three ); ``` -------------------------------- ### Import Lists (Rust) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates splitting and joining Rust import statements. It covers splitting individual imports from a list and joining them back, as well as joining imports with common paths. ```rust use std::io::{Read, Write, Process}; use std::io::Read; use std::io::Write; use std::io::Process; use std::io::{Read, Write}; use std::io::{ Read, Write }; ``` -------------------------------- ### CUE: Split/Join Function Arguments Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows how to split and join function arguments in CUE. The cursor should be positioned inside the parentheses for splitting. ```cue bar: m.Baz(foo[2].bar.baz, 42, true) bar: m.Baz( foo[2].bar.baz, 42, true ) ``` -------------------------------- ### Java Lambda Function Formatting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates the syntax for lambda functions in Java, showing single-line and multi-line body representations. ```java some_function(foo -> "bar"); some_function(foo -> { return "bar"; }); ``` -------------------------------- ### Eruby: Split/Join Hashes Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates splitting and joining Eruby hashes, including option hashes. ```eruby <% foo = { :bar => 'baz', :one => :two, :five => 'six' } %> <% foo = { :bar => 'baz', :one => :two, :five => 'six' } %> ``` -------------------------------- ### Handlebars Component Usage Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates the syntax for using Handlebars components, including simple and block component forms with attribute passing. ```handlebars {{some/component-name foo=bar bar=baz}} {{some/component-name foo=bar bar=baz }} {{#component-name foo=bar}}Some content{{/component-name}} {{#component-name foo=bar}} Some contents {{/component-name}} ``` -------------------------------- ### Split HTML Element to Multi-Line (HTML) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/README.md Shows how to transform a single-line HTML element into a multi-line representation for improved readability. This is one of the supported transformations in splitjoin.vim. ```html
bar
``` -------------------------------- ### Clojure List Splitting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates splitting Clojure lists, including function calls and vector/set literals, into multiline formats for improved clarity. ```clojure (map (fn [x] (.toUpperCase x)) (.split "one two three" " ")) ``` ```clojure (map (fn [x] (.toUpperCase x)) (.split "one two three" " ")) ``` ```clojure [::namespace/function one two three] ``` ```clojure [::namespace/function one two three] ``` ```clojure #{:a :b :c :d} ``` ```clojure #{:a :b :c :d} ``` -------------------------------- ### Question Mark Operator (Rust) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Explains the plugin's behavior with Rust's `?` operator for `Result` and `Option`. It details how the plugin splits `?` into `match` and joins them back, with specific logic for context awareness. ```rust let file = File::open("foo.txt")?; let file = match File::open("foo.txt") { Ok(value) => value, Err(e) => return Err(e.into()), }; let thing = Some(3)?; let thing = match Some(3) { None => return None, Some(value) => value, }; ``` -------------------------------- ### Split Ruby Module Namespacing Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Splits or joins Ruby module namespaces. This functionality relies on the `matchit` Vim plugin and will silently fail if `matchit` is not available. ```ruby module Foo ``` -------------------------------- ### Elm: Split/Join Records and Tuples Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates splitting and joining Elm records and tuples, focusing on updating record fields. ```elm myUpdatedRecord = {myPreviousRecord | firstName = "John", lastName = "Doe"} myUpdatedRecord = { myPreviousRecord | firstName = "John" , lastName = "Doe" } ``` -------------------------------- ### Javascript: Split/Join If Clauses Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates splitting and joining 'if' clauses in Javascript, including handling assignments and ternary operators. ```javascript console.log bar if foo? if foo? then console.log bar if foo? console.log bar ``` -------------------------------- ### Javascript: Split/Join Object Literals Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates splitting and joining object literals in Javascript. ```javascript one = { one: "two", three: "four" } one = one: "two" three: "four" ``` -------------------------------- ### Java Function Call Formatting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates formatting options for function calls in Java, including splitting arguments across multiple lines. ```java myfunction(arg1, arg2, arg3, arg4); myfunction(arg1, arg2, arg3, arg4); ``` -------------------------------- ### Split One-Liner to Multi-Line Statement (Ruby) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/README.md Demonstrates splitting a concise Ruby one-liner into a more readable multi-line format. This function is a core feature of the splitjoin.vim plugin. ```ruby puts "foo" if bar? ``` -------------------------------- ### HTML Attribute Formatting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates the formatting of HTML attributes, showcasing both inline and multi-line attribute lists. ```html ``` -------------------------------- ### JavaScript Object Formatting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows how to split and format JavaScript object literals, allowing for improved readability with multi-line key-value pairs. ```javascript var one = {one: "two", three: "four"}; var one = { one: "two", three: "four" }; ``` -------------------------------- ### Split/Join Perl Hashes Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Formats Perl hashes by splitting key-value pairs across multiple lines for better readability. ```perl my $info = {name => $name, age => $age}; ``` ```perl my $info = { name => $name, age => $age, }; ``` -------------------------------- ### CSS: Split/Join Style Definitions Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates splitting and joining CSS style definitions, where properties are moved to separate lines. ```css a { color: #0000FF; text-decoration: underline; } a { color: #0000FF; text-decoration: underline; } ``` -------------------------------- ### Join HTML Element to Single-Line (HTML) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/README.md Demonstrates joining a multi-line HTML element back into a single line. This is the complementary operation to splitting an HTML element. ```html
bar
``` -------------------------------- ### Split/Join PHP Short Arrays Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Reformats PHP short array syntax (`[]`) into a multi-line format for improved readability. ```php $one = ['two', 'three', 'four'] ``` ```php $one = [ 'two', 'three', 'four' ] ``` -------------------------------- ### LaTeX Enumeration Splitting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows how splitjoin.vim handles splitting of LaTeX 'enumerate' environments with list items. ```tex \begin{enumerate} \item item1 \item item2 \end{enumerate} \begin{enumerate} \item item1 \item item2 \end{enumerate} ``` -------------------------------- ### Line Continuation with Backslash (Shell) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates how the plugin splits lines containing pipes (`|`) using a backslash for continuation in shell scripts. It also describes the joining behavior for such lines. ```shell echo "one" | wc -c echo "one" \ | wc -l ``` -------------------------------- ### C Function Call Splitting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates splitting C function calls with multiple arguments across several lines. This helps in managing long function signatures. ```c myfunction(arg1, arg2, arg3, arg4); ``` ```c myfunction(arg1, arg2, arg3, arg4); ``` -------------------------------- ### Module Namespacing in RSpec (Ruby) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates how to split and join RSpec tests that use module namespacing. The plugin helps manage the structure of tests within modules. ```ruby module Foo RSpec.describe Bar do it "does stuff" do end end end RSpec.describe Foo::Bar do it "does stuff" do end end ``` -------------------------------- ### Javascript: Split/Join Assignments with If Clauses Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows how splitjoin.vim handles assignments within 'if' clauses in Javascript, including squeezing assignments into split lines and moving variables for joined lines. ```javascript foo = if bar? then 'baz' else 'qux' if bar? foo = 'baz' else foo = 'qux' foo = if bar? then 'baz' else 'qux' ``` -------------------------------- ### Method Continuations (Ruby) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates splitting and joining method calls with chained or broken continuations. It highlights the directionality of the operation, favoring joining over splitting for ambiguity. ```ruby one. two.three(foo, bar) one .two.three(foo, bar) one.two.three(foo, bar) ``` -------------------------------- ### Split/Join PHP Arrays Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Formats PHP arrays by splitting key-value pairs into a multi-line structure. ```php foo = array('one' => 'two', 'two' => 'three') ``` ```php foo = array( 'one' => 'two', 'two' => 'three' ) ``` -------------------------------- ### Join Multi-Line Statement to One-Liner (Ruby) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/README.md Illustrates joining a multi-line Ruby statement back into a concise single-line expression. This is the inverse operation of splitting a line. ```ruby if bar? puts "foo" puts "baz" end ``` -------------------------------- ### Split Ruby Caching Constructs Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Splits Ruby caching constructs (e.g., `||=`) that use single-line expressions into multi-line `begin...end` blocks for more complex assignments. ```ruby @two ||= 1 + 1 ``` ```ruby @two ||= begin 1 + 1 end ``` -------------------------------- ### Ruby 3.0 Endless Def (Ruby) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows the splitting and joining of Ruby 3.0's endless `def` syntax. The plugin facilitates converting between standard and endless method definitions. ```ruby def foo(one, two) bar end def foo(one, two) = bar ``` -------------------------------- ### CoffeeScript Function Splitting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows how to split CoffeeScript functions, particularly those with arrow syntax, into single-line and multiline formats. ```coffeescript (foo, bar) -> console.log foo ``` ```coffeescript (foo, bar) -> console.log foo ``` -------------------------------- ### Split/Join PHP Markers Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Converts PHP short echo tags to standard blocks and vice-versa, useful for code formatting. ```php ``` ```php ``` -------------------------------- ### Configure Textwidth for Fasta File Splitting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Determines the line width for splitting Fasta files. If set to a value greater than 0, that value is used; otherwise, the plugin defaults to 100 if the global 'textwidth' is 0. ```vim let g:splitjoin_fasta_textwidth = 100 ``` -------------------------------- ### CoffeeScript Conditional Splitting Configuration Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Mentions a configuration variable that controls how multiline CoffeeScript conditional statements (if/unless/while/until) are joined, specifically whether they become postfix or suffix variants. -------------------------------- ### Hare Struct Definitions Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates the syntax for defining anonymous structs in Hare, supporting both inline and multi-line field declarations. ```hare struct { source: str, line: 1 }; struct { source: str, line: 1, }; ``` -------------------------------- ### Configure Perl Brace Placement Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Determines the placement of curly braces for if-clauses in Perl. With the default value of 1, the opening brace is on the same line (`if (...) {`). Setting it to 0 places the opening brace on a new line (`if (...) {`). ```vimscript let g:splitjoin_perl_brace_on_same_line = 0 ``` -------------------------------- ### Elixir: Split Pipelines Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates splitting Elixir pipelines, moving the pipe operator to a new line for better readability. Note: This does not currently work properly for multi-line arguments. ```elixir String.length("splitjoin") "splitjoin" |> String.length() String.length( Enum.join([ "split", "join" ]) ) if true do "splitjoin" end |> String.length() ``` -------------------------------- ### YAML Map Splitting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows the splitting of YAML maps (dictionaries), including nested structures and inline/block formats. ```yaml root: one: { foo: bar } two: { three: ['four', 'five'], six: seven } root: one: foo: bar two: three: ['four', 'five'] six: seven ``` -------------------------------- ### Splitting Ruby Hash based on Cursor Position Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows how the cursor's location within a method call affects the splitting of multiple Ruby hashes, ensuring the desired hash is split. ```ruby foo 1, 2, { :bar => :baz }, { :baz => :qux } ``` ```ruby foo 1, 2, { :bar => :baz }, { :baz => :qux } ``` ```ruby foo 1, 2, { :bar => :baz }, { :baz => :qux } ``` -------------------------------- ### Split/Join Python Tuples Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Formats Python tuples by splitting elements across multiple lines. Ensure the cursor is within the tuple. ```python spam = (1, 2, 3) ``` ```python spam = (1, 2, 3) ``` -------------------------------- ### Unwrap/Expect Match Split (Rust) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Details the splitting functionality for `unwrap()` and `expect()` calls in Rust. The plugin converts these into `match` statements, requiring the cursor to be on the method call. ```rust let foo = Some::value(chain).of(things).unwrap(); let foo = match Some::value(chain).of(things) { } ``` -------------------------------- ### Eruby: Split/Join Tags Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows splitting and joining HTML tags within Eruby templates. ```eruby
bar
bar
``` -------------------------------- ### YAML Array Splitting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates how splitjoin.vim splits YAML arrays, showing both inline and block list representations. ```yaml root: one: [1, 2] two: ['three', 'four'] root: one: - 1 - 2 two: - 'three' - 'four' ``` -------------------------------- ### Java If-Clause Condition Formatting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows how complex boolean conditions in Java if-statements can be split across multiple lines for readability. ```java if (val1 && val2 || val3) body(); if (val1 && val2 || val3) body(); ``` -------------------------------- ### Hare Question Mark Operator Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates the use of the question mark operator in Hare for error handling, specifically showing splitting of the operator. ```hare const num = getnumber()?; const num = match (getnumber()) { case error => abort(); case let t: type => yield t; }; ``` -------------------------------- ### JavaScript Function Argument Formatting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates how function arguments in JavaScript can be split across multiple lines for better readability, especially with numerous or long arguments. ```javascript var foo = bar('one', 'two', 'three'); ``` -------------------------------- ### Semicolon Separation (Shell) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Explains the basic support for splitting and joining shell commands separated by semicolons. This functionality is compatible with Bash, ZSH, and other shells. ```shell echo "one"; echo "two" echo "one" echo "two" ``` -------------------------------- ### Split Ruby Block &-shorthand Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Transforms Ruby's block &-shorthand (e.g., `&:to_s`) into explicit multi-line `do...end` blocks, facilitating the addition of more complex logic within the block. ```ruby [1, 2, 3].map(&:to_s) ``` ```ruby [1, 2, 3].map do |i| i.to_s end ``` -------------------------------- ### Eruby: Split/Join If/Unless Clauses Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates splitting and joining Eruby if/unless clauses, converting inline conditionals to block forms. ```eruby <%= foo if bar? %> <% if bar? %> <%= foo %> <% end %> ``` -------------------------------- ### Split Ruby Blocks Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Converts Ruby blocks from single-line `{}` syntax to multi-line `do...end` syntax for better readability, especially with longer block bodies. ```ruby Bar.new { |b| puts b.to_s } ``` ```ruby Bar.new do |b| puts b.to_s end ``` -------------------------------- ### Elixir: Join Comma-Separated Method Calls Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows joining comma-separated method calls within a for comprehension in Elixir. Note: This is join-only functionality. ```elixir for a <- 1..10, Integer.is_odd(a) do a end for a <- 1..10, Integer.is_odd(a) do a end ``` -------------------------------- ### Erb Link Generation Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Generates HTML anchor tags using the Rails `link_to` helper. Supports inline and block-style attribute definitions. ```erb %!DOCTYPE html <%= link_to 'Google', 'http://google.com', :class => 'google', :id => 'google-link' %> <%= link_to 'Google', 'http://google.com', { :class => 'google', :id => 'google-link' } %> ``` -------------------------------- ### Split/Join PHP If-clauses Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Splits and joins PHP if-clauses, allowing for single-line or multi-line conditional blocks. ```php if ($foo) { $a = "bar"; } ``` ```php if ($foo) { $a = "bar"; } ``` -------------------------------- ### Split/Join Perl And/Or Clauses Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Splits and joins Perl 'and'/'or' clauses, primarily focusing on splitting. Joining an 'if' clause is also supported. ```perl open PID, ">", $pidfile or die; ``` ```perl unless (open PID, ">", $pidfile) { die; } ``` -------------------------------- ### Configure Full PHP Method Chain Splitting (splitjoin.vim) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Controls whether all arrows in a PHP method chain are split onto new lines after the cursor (1) or if only the arrow immediately after the cursor is split (0, default). ```vim let g:splitjoin_php_method_chain_full = 1 ``` -------------------------------- ### Joining Ruby If Statement Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates joining a multiline Ruby 'if' statement into a single line. The cursor must be on the 'if' clause line for the join to work. ```ruby if foo? bar end ``` ```ruby bar if foo? ``` -------------------------------- ### Java If-Clause Body Formatting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates various ways to format the body of an if-statement in Java, including single statements and block statements. ```java if (isTrue()) doSomething(); if (isTrue()) doSomething(); if (isTrue()) { doSomething(); } if (isTrue()) { doSomething(); } ``` -------------------------------- ### Configure Ruby Array Expansion for Options Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Enables the expansion of the last hash in an array to 'options' format. When set to 1, arrays containing hashes at the end will be reformatted to use key: value syntax for the hash elements. The default value is 0. ```vimscript let g:splitjoin_ruby_expand_options_in_arrays = 1 ``` -------------------------------- ### Vimscript: Mapping Fallback Behavior Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Configures the fallback behavior for mappings when no splitting or joining action can be performed. ```vimscript let g:splitjoin_mapping_fallback = 0 ``` -------------------------------- ### Splitting Ruby Hash with Condition Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Illustrates how the plugin prioritizes splitting conditional statements (like 'if' clauses) over other structures, even if the cursor is within a different block. ```ruby { :one => 'two', :three => 'four' } if foo? ``` ```ruby if foo? { :one => 'two', :three => 'four' } end ``` -------------------------------- ### Split R Function Arguments Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Splits arguments within R function calls into multiple lines, with options for different alignment styles to improve readability. ```r print(1, 2, 3) ``` ```r # with g:r_indent_align_args = 0 print( 1, 2, 3 ) ``` ```r # with g:r_indent_align_args = 1 print(1, 2, 3) ``` -------------------------------- ### Configure HTML Attribute Bracket Placement (splitjoin.vim) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Specifies if the closing angle bracket '>' for HTML attributes should be on a new line (1) or on the same line as the last attribute (0, default). ```vim let g:splitjoin_html_attributes_bracket_on_new_line = 1 ``` -------------------------------- ### Split/Join Perl Lists Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Splits and joins Perl lists, including array and list literal formats. ```perl my $var = ['one', 'two', 'three']; ``` ```perl my $var = [ 'one', 'two', 'three' ]; ``` ```perl my @var = ('one', 'two', 'three'); ``` ```perl my @var = ( 'one', 'two', 'three' ); ``` -------------------------------- ### Split Python Ternary Assignment Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Converts Python ternary conditional assignments into standard if-else blocks for enhanced readability or debugging. ```python max_x = x1 if x1 > x2 else x2 ``` ```python if x1 > x2: max_x = x1 else: max_x = x2 ``` -------------------------------- ### HAML Evaluated Ruby Expressions Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows how to embed and evaluate Ruby expressions within HAML templates using the '=' and '-=' syntax. ```haml %div= 1 + 2 %div = 1 + 2 ``` -------------------------------- ### CSS: Split/Join Multiline Selectors Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows splitting and joining CSS selectors that span multiple lines. ```css h1, h2, h3 { font-size: 18px; font-weight: bold; } h1, h2, h3 { font-size: 18px; font-weight: bold; } ``` -------------------------------- ### Control Ruby do-block Conversion Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Manages the conversion of block splits to their 'do' form in Ruby. When set to 1 (default), blocks like `{ |n| n ** 2 }` are converted to `do |n| ... end`. Setting it to 0 preserves the original block syntax. ```vimscript g:splitjoin_ruby_do_block_split ``` -------------------------------- ### Nested Definitions (SCSS/LESS) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates splitting and joining nested rules in SCSS and LESS. The plugin extracts nested rules into separate definitions or joins them up, depending on cursor position and nesting level. ```scss ul li { a { padding: 10px; } } ul li a { padding: 10px; } ``` -------------------------------- ### Split/Join Lua Functions Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Splits and joins Lua functions, attempting to connect body lines with ';'. Primarily for inlining small functions. ```lua function example () print("foo"); print("bar") end ``` ```lua function example () print("foo") print("bar") end ``` ```lua local something = other(function (one, two) print("foo") end) ``` ```lua local something = other(function (one, two) print("foo") end) ``` -------------------------------- ### Split/Join PHP Method Chains Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Splits method chains in PHP, with an option (`splitjoin_php_method_chain_full`) to affect all arrows or just the current one. ```php $var = $one->two->three()->four(); ``` ```php $var = $one ->two->three()->four(); ``` ```php # OR $var = $one ->two ->three() ->four(); ``` -------------------------------- ### Configure Python Bracket Placement Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Controls whether Python lists and tuples are split with brackets on separate lines. When set to 1, the opening bracket is placed on its own line, enhancing readability for long sequences. The default value is 0. ```vimscript let g:splitjoin_python_brackets_on_separate_lines = 1 ``` -------------------------------- ### Split/Join JavaScript Fat-arrow Functions Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Handles splitting and joining of fat-arrow functions in JavaScript, facilitating conversion between concise and block body forms. ```javascript some_function(foo => "bar"); ``` ```javascript some_function(foo => { return "bar"; }); ``` -------------------------------- ### Configure C Argument Newline Placement (splitjoin.vim) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Similar to Java, these settings control newline placement around C arguments during splitting. `split_first_newline` to 1 adds a newline before the first argument, and `split_last_newline` to 1 adds one after the last argument. Defaults are 0. ```vim let g:splitjoin_c_argument_split_first_newline = 1 let g:splitjoin_c_argument_split_last_newline = 1 ``` -------------------------------- ### Configure Python Bracket Placement (splitjoin.vim) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Controls whether closing brackets in Python code are placed on separate lines when splitting. Setting to 1 places them on new lines, while 0 keeps them on the same line as the last argument. ```vim let g:splitjoin_python_brackets_on_separate_lines = 1 ``` ```vim let g:splitjoin_python_brackets_on_separate_lines = 0 ``` -------------------------------- ### Split/Join JavaScript Functions Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Splits and joins curly braces for JavaScript functions. Useful for converting one-line functions to multi-line. ```javascript var foo = bar( 'one', 'two', 'three' ); ``` ```javascript var callback = function (something, other) { something_else; }; ``` ```javascript var callback = function (something, other) { something_else; }; ``` -------------------------------- ### Javascript: Split Multiline Strings Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Shows how multiline strings are split in Javascript, specifically at the end of the line to avoid conflicts with other splitting types. Supports interpolation and escaped quotes. ```javascript foo = "example with #{interpolation} and \"nested\" quotes" foo = """ example with #{interpolation} and \"nested\" quotes """ bar = 'example with single quotes' bar = ''' example with single quotes ''' ``` -------------------------------- ### Configure Handlebars Closing Bracket Placement (splitjoin.vim) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Determines if the closing '}}' for Handlebars components stays on the same line as the last element (1) or moves to its own line (0, default). ```vim let g:splitjoin_handlebars_closing_bracket_on_same_line = 1 ``` -------------------------------- ### Split/Join Python Dicts Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Formats Python dictionaries by splitting key-value pairs across multiple lines. Requires the cursor to be within the dictionary. ```python knights = {'gallahad': 'the pure', 'robin': 'the brave'} ``` ```python knights = { 'gallahad': 'the pure', 'robin': 'the brave' } ``` -------------------------------- ### Enable Alignment with splitjoin.vim Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Enables alignment of code constructs by a specified character, such as the '=>' symbol in Ruby hashes. Requires the Tabular or Align plugin. When enabled, it complements whitespace normalization by ensuring proper visual alignment. ```vimscript let g:splitjoin_align = 1 ``` -------------------------------- ### Split/Join JavaScript One-line If Conditionals Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Splits and joins one-line if conditionals in JavaScript. Allows for clearer formatting of simple conditional statements. ```javascript if (isTrue()) { doSomething(); } ``` ```javascript if (isTrue()) doSomething(); ``` -------------------------------- ### Configure Ruby Options as Arguments Splitting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Controls how Ruby options are split along with arguments. If set to 1, both arguments and options are split when the cursor is on arguments. If the cursor is on options, only options are split. The default is 0. ```vimscript let g:splitjoin_ruby_options_as_arguments = 1 ``` -------------------------------- ### Configure Ruby Heredoc Type Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Specifies the type of heredoc string delimiter used when splitting strings in Ruby. Options are '<<-', '<<~' (default), and '<<'. Each option affects indentation and whitespace handling within the heredoc. ```vimscript let g:splitjoin_ruby_heredoc_type = '<<-' ``` -------------------------------- ### JavaScript Array Formatting Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Demonstrates splitting and formatting JavaScript array literals, which is useful for long arrays or arrays with complex elements. ```javascript var one = ['two', 'three', 'four']; var one = [ 'two', 'three', 'four' ]; ``` -------------------------------- ### Configure Java Argument Newline Placement (splitjoin.vim) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Controls the placement of newlines around Java arguments during splitting. Setting `split_first_newline` to 1 adds a newline before the first argument, and `split_last_newline` to 1 adds one after the last argument. Defaults are 0. ```vim let g:splitjoin_java_argument_split_first_newline = 1 let g:splitjoin_java_argument_split_last_newline = 1 ``` -------------------------------- ### Configure Python Import Style (splitjoin.vim) Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Defines the style for splitting Python imports. 'round_brackets' encloses imports in parentheses, while 'newline_escape' (default) uses line escapes. ```vim let g:splitjoin_python_import_style = 'round_brackets' ``` -------------------------------- ### Split Ruby Method Arguments Source: https://github.com/andrewradev/splitjoin.vim/blob/main/doc/splitjoin.txt Splits Ruby method arguments into multiple lines when there isn't a trailing option hash. The `splitjoin_ruby_hanging_args` variable influences the alignment style. ```ruby params.permit(:title, :action, :subject_type, :subject_id, :own) ``` ```ruby params.permit(:title, :action, :subject_type, :subject_id, :own) ``` ```ruby # with splitjoin_ruby_hanging_args == 0 params.permit( :title, :action, :subject_type, :subject_id, :own ) ```