From kwrite-devel Mon Apr 21 11:08:45 2014 From: =?utf-8?q?Miquel_Sabat=C3=A9_Sol=C3=A0?= Date: Mon, 21 Apr 2014 11:08:45 +0000 To: kwrite-devel Subject: Re: Review Request 117660: vimode: make the S and C commands change the whole line in visual-line mo Message-Id: <20140421110845.3533.36994 () probe ! kde ! org> X-MARC-Message: https://marc.info/?l=kwrite-devel&m=139807853621539 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============7427055603091431839==" --===============7427055603091431839== Content-Type: multipart/alternative; boundary="===============5764233582407636539==" --===============5764233582407636539== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit > On April 20, 2014, 7:24 p.m., Michal Humpula wrote: > > There is a precedence with normal mode "Y" command, i.e. it does the "correct" thing in kate but not in vim = yanking to the end of line, no the whole line. From my point of view, this applies here to. Having capitalized commands work on "from here to the end of line". I agree that visual line mode is a bordeline case, but I don't see the point of changing behaviour of this command in this one case, when the user can still use "c" to the the job. > > Miquel Sabaté Solà wrote: > Yes, I agree with you. However, in my opinion, the current behavior in Kate of the C and S commands in visual-line mode doesn't make any sense right now. For example, if you type "lVCX" in the following text: > > Hello > World > > You end up with: > > WXorld > > This doesn't make sense. Yes, the user should've used the c command to do the right thing. But I got to this patch because by accident I typed C instead of c and I ended up in an unexpected situation ;) > > So this patch basically says that in visual-line mode, C and S are the same as c and s, because that's in my opinion the expected thing to happen in visual-line mode :) > > Michal Humpula wrote: > What about doing something like this > > HX > World > > ? > > Miquel Sabaté Solà wrote: > This would certainly make more sense than the current behavior, and it's the same behavior as in normal mode. However, this is not normal mode, this is visual mode, and therefore we have a certain text selected. Since this is visual-line mode, the whole line is selected. Therefore, if you perform a "change" command, the change should affect the selection, that is, the whole line. Therefore, the text should imo end up like this (which is how it looks with my patch applied ;) ): > > X > World > > > Michal Humpula wrote: > ok, then only way to delete to the end of line and jump to insert would be "Di", right? And what about this example: > > start: > aaaa > bbbbbbb > ccc > > input: 2lV2jCX > > expected: > aaX > bbX > ccX > > wouldn't it make more sense? Please notice that you cann't use visual block mode to "delete after second column" (it will not select the to the end of second line). > > Michal Humpula wrote: > To put it differently: I was at the impression that vim selection is a way to give a commands hint on area to operate on and it's up to the command to choose from that hint what it needs. For example substition command, no matter how you do selection, is interested only on first and last line selected so it knows where to start substituting and where it should end. Column information is ignored in this case. The "C" should in my opinion behave similarly. > > Miquel Sabaté Solà wrote: > > ok, then only way to delete to the end of line and jump to insert would be "Di", right? > > Well, the current behavior is more like: "Da". Also note that in visual-line mode, "d" and "D" are synonyms. Therefore, for consistency, it makes sense for us to make c do the same as C, and the same goes for the s command ;) > > > wouldn't it make more sense? > > That would certainly be cooler, that's for sure :) However, in this case it would be cooler that this is done in visual-block mode. Currently, for your example you can do something like "2l2jCX". This would lead to: > > aaX > bb > cc > > Certainly this is not exactly what you wanted though :P Anyways, inserting contents in the same column at the same time in a range of selected lines sounds more like Kate's Block selection mode, which is something that we lack in vi-mode :) For example, (I'm just wondering around, don't take me very seriously here ;) ), we could make the in visual-block mode when we press "i" or "c" we enter in Kate's block selection mode, and so your problem would be resolved in a *much* powerful way. > > Therefore, in my opinion, in visual-line block we have the following options for the C and S commands: > > 1. We can say that since they are not useful, and they are not implemented, and therefore the c and s commands should be used. > 2. We can say that c, C, s and S are synonyms in visual-line mode. This is what my patch goes after. > 3. Another option, (and I think that this is what you expect from your first question :) ), is that C and S are the same as doing "DI". That is, delete the current line and go to the first non-blank character of the next line. > > What do you think ? > > Michal Humpula wrote: > we need a third person here:) Definitely :) Let's see if Simon can take a look at this review request and give his opinion :) - Miquel ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://git.reviewboard.kde.org/r/117660/#review56089 ----------------------------------------------------------- On April 20, 2014, 5:31 p.m., Miquel Sabaté Solà wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://git.reviewboard.kde.org/r/117660/ > ----------------------------------------------------------- > > (Updated April 20, 2014, 5:31 p.m.) > > > Review request for Kate, Michal Humpula and Simon St James. > > > Repository: ktexteditor > > > Description > ------- > > When in visual-line mode, the C command should behave exactly as the c command in this case: change the whole line. This is because the purpose of visual-line mode is to perform commands on lines, not in some parts of a line. The current behavior doesn't make a lot of sense imho: it deletes the current line and goes to the second column of the next line in insert mode. Plus, the behavior of the C command in this patch matches the behavior in vim for this case. I know that we don't *have* to mimic all the vim behavior, but in this case it makes much more sense than the actual behavior in kate. > > So, why have I included also the S command in this patch? Well, before this patch the S command behaved like the C command in this case in Kate. So, I think we should apply the same logic as in the C's case. Vim does something that I don't fully understand, so I guess we won't be mimicking vim here :P > > > Diffs > ----- > > autotests/src/vimode/modes.cpp cf4705d > src/vimode/katevivisualmode.cpp 25d4bd9 > > Diff: https://git.reviewboard.kde.org/r/117660/diff/ > > > Testing > ------- > > All tests are passing. I've also added a couple of tests. > > > Thanks, > > Miquel Sabaté Solà > > --===============5764233582407636539== Content-Type: text/html; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit
This is an automatically generated e-mail. To reply, visit: https://git.reviewboard.kde.org/r/117660/

On April 20th, 2014, 7:24 p.m. UTC, Michal Humpula wrote:

There is a precedence with normal mode "Y" command, i.e. it does the "correct" thing in kate but not in vim = yanking to the end of line, no the whole line. From my point of view, this applies here to. Having capitalized commands work on "from here to the end of line". I agree that visual line mode is a bordeline case, but I don't see the point of changing behaviour of this command in this one case, when the user can still use "c" to the the job.

On April 20th, 2014, 7:38 p.m. UTC, Miquel Sabaté Solà wrote:

Yes, I agree with you. However, in my opinion, the current behavior in Kate of the C and S commands in visual-line mode doesn't make any sense right now. For example, if you type "lVCX" in the following text:

Hello
World

You end up with:

WXorld

This doesn't make sense. Yes, the user should've used the c command to do the right thing. But I got to this patch because by accident I typed C instead of c and I ended up in an unexpected situation ;)

So this patch basically says that in visual-line mode, C and S are the same as c and s, because that's in my opinion the expected thing to happen in visual-line mode :)

On April 20th, 2014, 8:08 p.m. UTC, Michal Humpula wrote:

What about doing something like this

HX
World

?

On April 20th, 2014, 8:19 p.m. UTC, Miquel Sabaté Solà wrote:

This would certainly make more sense than the current behavior, and it's the same behavior as in normal mode. However, this is not normal mode, this is visual mode, and therefore we have a certain text selected. Since this is visual-line mode, the whole line is selected. Therefore, if you perform a "change" command, the change should affect the selection, that is, the whole line. Therefore, the text should imo end up like this (which is how it looks with my patch applied ;) ):

X
World

On April 20th, 2014, 8:30 p.m. UTC, Michal Humpula wrote:

ok, then only way to delete to the end of line and jump to insert would be "Di", right? And what about this example:

start:
aaaa
bbbbbbb
ccc

input: 2lV2jCX

expected:
aaX
bbX
ccX

wouldn't it make more sense? Please notice that you cann't use visual block mode to "delete after second column" (it will not select the to the end of second line).

On April 20th, 2014, 8:57 p.m. UTC, Michal Humpula wrote:

To put it differently: I was at the impression that vim selection is a way to give a commands hint on area to operate on and it's up to the command to choose from that hint what it needs. For example substition command, no matter how you do selection, is interested only on first and last line selected so it knows where to start substituting and where it should end. Column information is ignored in this case. The "C" should in my opinion behave similarly.

On April 20th, 2014, 8:59 p.m. UTC, Miquel Sabaté Solà wrote:

> ok, then only way to delete to the end of line and jump to insert would be "Di", right?

Well, the current behavior is more like: "Da". Also note that in visual-line mode, "d" and "D" are synonyms. Therefore, for consistency, it makes sense for us to make c do the same as C, and the same goes for the s command ;)

> wouldn't it make more sense?

That would certainly be cooler, that's for sure :) However, in this case it would be cooler that this is done in visual-block mode. Currently, for your example you can do something like "2l<c-v>2jCX". This would lead to:

aaX
bb
cc

Certainly this is not exactly what you wanted though :P Anyways, inserting contents in the same column at the same time in a range of selected lines sounds more like Kate's Block selection mode, which is something that we lack in vi-mode :) For example, (I'm just wondering around, don't take me very seriously here ;) ), we could make the in visual-block mode when we press "i" or "c" we enter in Kate's block selection mode, and so your problem would be resolved in a *much* powerful way.

Therefore, in my opinion, in visual-line block we have the following options for the C and S commands:

1. We can say that since they are not useful, and they are not implemented, and therefore the c and s commands should be used.
2. We can say that c, C, s and S are synonyms in visual-line mode. This is what my patch goes after.
3. Another option, (and I think that this is what you expect from your first question :) ), is that C and S are the same as doing "DI". That is, delete the current line and go to the first non-blank character of the next line.

What do you think ?

On April 21st, 2014, 11:01 a.m. UTC, Michal Humpula wrote:

we need a third person here:)
Definitely :) Let's see if Simon can take a look at this review request and give his opinion :)

- Miquel


On April 20th, 2014, 5:31 p.m. UTC, Miquel Sabaté Solà wrote:

Review request for Kate, Michal Humpula and Simon St James.
By Miquel Sabaté Solà.

Updated April 20, 2014, 5:31 p.m.

Repository: ktexteditor

Description

When in visual-line mode, the C command should behave exactly as the c command in this case: change the whole line. This is because the purpose of visual-line mode is to perform commands on lines, not in some parts of a line. The current behavior doesn't make a lot of sense imho: it deletes the current line and goes to the second column of the next line in insert mode. Plus, the behavior of the C command in this patch matches the behavior in vim for this case. I know that we don't *have* to mimic all the vim behavior, but in this case it makes much more sense than the actual behavior in kate.

So, why have I included also the S command in this patch? Well, before this patch the S command behaved like the C command in this case in Kate. So, I think we should apply the same logic as in the C's case. Vim does something that I don't fully understand, so I guess we won't be mimicking vim here :P

Testing

All tests are passing. I've also added a couple of tests.

Diffs

  • autotests/src/vimode/modes.cpp (cf4705d)
  • src/vimode/katevivisualmode.cpp (25d4bd9)

View Diff

--===============5764233582407636539==-- --===============7427055603091431839== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ KWrite-Devel mailing list KWrite-Devel@kde.org https://mail.kde.org/mailman/listinfo/kwrite-devel --===============7427055603091431839==--