Code Monkey home page Code Monkey logo

Comments (6)

AndrewRadev avatar AndrewRadev commented on May 30, 2024

There's no perl for now, because I don't really know perl, but probably won't be difficult to add. I'm going to leave it for the weekend, I'll write back here when I've got something working.

from splitjoin.vim.

AndrewRadev avatar AndrewRadev commented on May 30, 2024

I've pushed some simple Perl support. Splitting and joining if clauses should now work. Could you check it out and let me know if it does?

from splitjoin.vim.

mowgli avatar mowgli commented on May 30, 2024

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi Andrew,

Am Mo den 16. Apr 2012 um 8:02 schrieb Andrew Radev:

I've pushed some simple Perl support. Splitting and joining if clauses should now work. Could you check it out and let me know if it does?

Thanks. That was fast.

Works partly. Well, it works pretty good but usually I use the Gnu
style for open braces. And this is not seen by splitjoin.

So for examples (Real code):
if (fork)
{
exit 0;
}

But there are even more styles that are more or less identical:
open PID, ">", $pidfile or die;

unless (open PID, ">", $pidfile)
{
die;
}

die unless (open PID, ">", $pidfile)

Regards
Klaus


Klaus Ethgen http://www.ethgen.ch/
pub 4096R/4E20AF1C 2011-05-16 Klaus Ethgen [email protected]
Fingerprint: 85D4 CA42 952C 949B 1753 62B3 79D0 B06F 4E20 AF1C
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQGcBAEBCgAGBQJPjA6cAAoJEKZ8CrGAGfas4lcL/Ri7zduqlmS/55ORRbQWYudV
w/m+etnIQ2Ypr7mwQ3zuk7oBHwStkDPMRjDFSQ8ELqoHn0QDZuyGphLgdq4fQmT6
yrTxBXqcHRCbo3acOhTdu/MRYvQ7Bh/91k1go0JNIjf3lQ/761Ji7L7Tu52y1v6O
GgkSn8mordKTI6snNmIPeNdzKjwBPuYP2rqbGZNJY3mDLBhlTwK50O6S20l5mPnU
z+z9x7BZ3HlIHHVTI9fByPMWB9Ni1ponJ7elnWvAQS71KyWLVfkygxL0QbS1vOVp
JCKVF9gcXTQUGbYMDL9YX2rH1bM4svIbQXpZ7dh8nDBIMq6us10vgg1vYDA7+Anz
7GuPC0nc1PyHpnOpzrOzN/XH3Vs42db/UFt6CPTjXKRcjI/B5gxgh89wbpiu7rsP
TB3kII/I5TFdQInA9AQ/aZdfDykMKNqeXsJ43E5W8GeP8B3YGDgw2UIU6wXOm4uO
6+vAWwBQpn/NNtIjweYbTPPgDRRTuQXTNVamuKIGhA==
=6kVp
-----END PGP SIGNATURE-----

from splitjoin.vim.

AndrewRadev avatar AndrewRadev commented on May 30, 2024

I'd forgotten about the brace styles. Been coding too much ruby, I suppose :). I put a variable to control the brace placement, g:splitjoin_perl_brace_on_same_line. If it's 1 (the default), you get this:

if ($debug) {
  print "a = $a\n";
}

If it's set to 0, it'll split into this:

if ($debug)
{
  print "a = $a\n";
}

So basically, you just need to put let g:splitjoin_perl_brace_on_same_line = 0 somewhere in your .vimrc.

I was thinking about maybe making a variable with a replacement string that you can set to {\n%s\n}, or \n{\n%s\n} to get your behaviour, but for now I think the simple setting is enough. I doubt there are any more styles for that anyway.

I also implemented splitting lines with or and and in them to unless and if clauses. This works only for splitting though, joining if/unless clauses leads to suffix if/unless clauses.

from splitjoin.vim.

mowgli avatar mowgli commented on May 30, 2024

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Am So den 22. Apr 2012 um 13:13 schrieb Andrew Radev:

I'd forgotten about the brace styles. Been coding too much ruby, I suppose :). I put a variable to control the brace placement, g:splitjoin_perl_brace_on_same_line. If it's 1 (the default), you get this:

if ($debug) {
  print "a = $a\n";
}

If it's set to 0, it'll split into this:

if ($debug)
{
  print "a = $a\n";
}

So basically, you just need to put let g:splitjoin_perl_brace_on_same_line = 0 somewhere in your .vimrc.

Nice work. Will try.

I was thinking about maybe making a variable with a replacement string that you can set to {\n%s\n}, or \n{\n%s\n} to get your behaviour, but for now I think the simple setting is enough. I doubt there are any more styles for that anyway.

Basically that would be also my approach but the simple setting might be
better.

I also implemented splitting lines with or and and in them to unless and if clauses. This works only for splitting though, joining if/unless clauses leads to suffix if/unless clauses.

Uh, fine, thanks. :-)

Regards
Klaus

Ps. You are number two who I owe a Beer in a local pub for cool vim
plugin if you ever met me near Zürich. :-)


Klaus Ethgen http://www.ethgen.ch/
pub 4096R/4E20AF1C 2011-05-16 Klaus Ethgen [email protected]
Fingerprint: 85D4 CA42 952C 949B 1753 62B3 79D0 B06F 4E20 AF1C
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQGcBAEBCgAGBQJPlVgeAAoJEKZ8CrGAGfasl9AL/3yvVqomzfi4DWtebm1wSPUC
I4JVvZcgwFat+NY/NTgBnIzGIHLfLYLActcWYYMkUYq0aHTCRw/NaX5BvdTn4ahs
XUQakuV/2zlMrMUvX+mybOOECAs67hy7CbLv8qxWvIlC9QNmZwgBhggU/EQ+P2ZE
mnYbiu4QwsogCglso0xGJSicIZBs3gIE/NM8vJEfTnjkeY3iWRQcgfFNKt5i8QwB
0YVUNWMQLPHXfGmxE4JIqLDxgT5bYkwrBSqUuNevLSvjMX5F63iqnzP0RXV7AVMG
L5m9+VTalma9P2wcE6OKwkD6Z1WzDgUSK08TGSkq45wthprOZny5y9IiPvbJaIip
20leiR4YtJ2tqSNITENQKHVYucNRHpFUl/qNj4wSwEK3ImFWfuRQPrLQ+9CqRQS0
8i9CBDz5whOR4Q50YDdflK724mY8CFohKUx2Wg5wVrRZ+hjhO9SgUPXUaZBZDqBQ
8jr05tFXJJgrVw2pQt9JFy8/ajA3v+j11+JdWyBrvA==
=rgTH
-----END PGP SIGNATURE-----

from splitjoin.vim.

AndrewRadev avatar AndrewRadev commented on May 30, 2024

You are number two who I owe a Beer in a local pub for cool vim plugin if you ever met me near Zürich. :-)

Thanks, I'll keep that in mind :). I'll close the issue for now, write back if you run into any problems.

from splitjoin.vim.

Related Issues (20)

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.