Code Monkey home page Code Monkey logo

Comments (16)

ereOn avatar ereOn commented on May 30, 2024

@gonzaloserrano Have you tried selecting the lines in visual mode then using the built-in gw ?

from splitjoin.vim.

gonzaloserrano avatar gonzaloserrano commented on May 30, 2024

Hi, with gw i get $a = array( 1, 2); which is very close but not exactly what i want.

from splitjoin.vim.

AndrewRadev avatar AndrewRadev commented on May 30, 2024

At this time, splitjoin doesn't work in visual mode. Pressing gJ in visual mode will run the default gJ mapping (take a look at :help gJ). You can join your expression by typing gJ in normal mode with the cursor on array.

from splitjoin.vim.

gonzaloserrano avatar gonzaloserrano commented on May 30, 2024

Sorry i'm not able to join it, i tried placing the curson in many places including on array and does not work for me.

Also the map seems ok:

:nmap gJ
n  gJ          * :<C-U>call <SNR>115_Mapping(g:splitjoin_join_mapping, "<SNR>115_Join")<CR>

from splitjoin.vim.

AndrewRadev avatar AndrewRadev commented on May 30, 2024

Yes, but the map is set only in normal mode. The nmap command shows mappings in normal mode, not in visual mode.

Is it possible that you have an old version of the plugin? Could you try updating and see if it works? Also, are you sure you're in a file that Vim recognizes as a PHP file?

from splitjoin.vim.

AndrewRadev avatar AndrewRadev commented on May 30, 2024

Also, you say you've tried placing the cursor on array, but could you confirm that you did that in normal mode, not in visual mode?

from splitjoin.vim.

gonzaloserrano avatar gonzaloserrano commented on May 30, 2024

I'm in normal mode with version 0.8 and on the array word, but i found that depending on which keys i press i'm sometimes able to do it ok. E.g in the next screencast, after doing gS, i moved with cursor left 4 or 5 times and then pressing gJ worked.

http://recordit.co/Xn5JSjdo6y

from splitjoin.vim.

AndrewRadev avatar AndrewRadev commented on May 30, 2024

Hmm, that's definitely strange. It's a long shot, but is it possible that you have nomagic set somewhere in your .vimrc? Could you try :echo &magic and let me know what the result is?

Also, what about the other php splits and joins, do they work okay for you?

# Square-bracket lists

$one = [
  'two',
  'three',
  'four'
]

$one = ['two', 'three', 'four']

# If-clauses

if ($foo) {
  $a = "bar";
}

if ($foo) { $a = "bar"; }

# PHP markers

<?php
echo "OK";
?>

<?php echo "OK"; ?>

from splitjoin.vim.

gonzaloserrano avatar gonzaloserrano commented on May 30, 2024

:echo &magic prints 1

$one = [
  'two',
  'three',
  'four'
]

gJ didn't work.

$one = ['two', 'three', 'four']

gS did work.

if ($foo) {
  $a = "bar";
}

gJ didn't work.

if ($foo) { $a = "bar"; }

gS did work.

<?php
echo "OK";
?>

gJ didn't work.

<?php echo "OK"; ?>

gS didn't work.

Thanks for the effort!

from splitjoin.vim.

AndrewRadev avatar AndrewRadev commented on May 30, 2024

Well, this at least means the problem is consistent. Two things:

  1. Could you check if gJ also doesn't work for other filetypes, for instance HTML (you should be able to join html tags)?
  2. Instead of typing gJ, could you try executing the command :SplitjoinJoin with the cursor in the right place (for example, on the array word)?

from splitjoin.vim.

gonzaloserrano avatar gonzaloserrano commented on May 30, 2024

Hi again, two months after :-)

  1. does not work in HTML files
  2. :SplitjoinJoin did work when the cursor is over the array word !

From today's last master version.

from splitjoin.vim.

AndrewRadev avatar AndrewRadev commented on May 30, 2024

Well, this tells me that the problem is obviously in the mapping part of the plugin and not the actual workings of the plugin. I'm not sure what the exact problem is, however :/.

Another thing I'd like you to try is to set a different mapping using the plugin's settings. For example:

let g:splitjoin_join_mapping = "zJ"

And then let me know if zJ does the job correctly (you could also use a different mapping).

Apart from that, you could try creating the mapping yourself:

nnoremap gJ :SplitjoinJoin<cr>

This last part should work for you in all cases, but I'd like to figure out what the real issue is as well.

from splitjoin.vim.

gonzaloserrano avatar gonzaloserrano commented on May 30, 2024

Same issue with "zJ" map, and creating the mapping myself does not work either :S

When type :map zJ in vim i see this: n zJ * :<C-U>call <SNR>120_Mapping(g:splitjoin_join_mapping, "<SNR>120_Join")<CR>

Do you think it's correct?

from splitjoin.vim.

AndrewRadev avatar AndrewRadev commented on May 30, 2024

It does look correct, but I'm not sure why making the mapping yourself wouldn't work.

My theory right now is that there's something in the s:Mapping function that doesn't quite work in your setup, for whatever reason. But still, this should work:

let g:splitjoin_join_mapping = ''
nnoremap gJ :SplitjoinJoin<cr>

It could be that you hadn't put the first line in your vimrc, could you try it like this?

from splitjoin.vim.

gonzaloserrano avatar gonzaloserrano commented on May 30, 2024

I tried, and continue having this strange behaviour.

Since i'm using the spf13 vim distribution with many plugins maybe there is something weird there so i'll try to find the issue when i have the time.

Thanks

from splitjoin.vim.

AndrewRadev avatar AndrewRadev commented on May 30, 2024

Since I don't really know how to fix the issue, and I guess it might be related to a different plugin or something, I'll go ahead and close this for now.

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.