Y vagy yy?

Nyilván nem magamtól találtam ki, hogy a Y+p a "copy+paste", hanem olvastam valahol. Na mindegy.

Másnál ez hogy megy? Rosszul tanultam meg, vagy valamikor a Y volt a yy? Vagy sose volt?

Lásd: https://www.reddit.com/r/neovim/comments/petq61/neovim_060_y_not_yankin…

(Bár lehet hogy csak azért új, mert nemrég cseréltem neovimre a vi-t - ami vim volt tulajdonképp.)

 

Szerk: anno ebből tanultam a vi-t: https://www.regikonyvek.hu/kiadas/unix-felhasznaloi-ismeretek-openinfo-…

Kb. most is annyi az ismeretem, ami a két oldalon fel volt sorolva :) Na, megnézni nem tudom mi van benne, bár ha nagyon akarnám, tudhatnám is.

Hozzászólások

6.5.6.1 Copying Lines

To copy a line requires two commands: yy or Y ("yank") and either p ("put below") or P ("put above"). Note that Y does the same thing as yy.

To yank one line, position the cursor anywhere on the line and type yy. Now move the cursor to the line above where you want the yanked line to be put (copied), and type p. A copy of the yanked line will appear in a new line below the cursor.

To place the yanked line in a new line above the cursor, type P.

The yy command works well with a count: to yank 11 lines, for example, just type 11yy. Eleven lines, counting down from the cursor, will be yanked, and vi indicates this with a message at the bottom of the screen: 11 lines yanked.

You can also use the P or p commands immediately after any of the deletion commands discussed earlier. This puts the text you deleted above or below the cursor, respectively.

Eredeti vi doksiból vágtam ki.

Viszont nézzük a vim oktatóanyagát:

$ sudo apt install vim      # ha netán nem lenne fent a teljes
$ LANG=en_US vimtutor

                        Lesson 6.4: COPY AND PASTE TEXT


          ** Use the  y  operator to copy text and  p  to paste it **

  1. Move to the line below marked ---> and place the cursor after "a)".

  2. Start Visual mode with  v  and move the cursor to just before "first".

  3. Type  y  to yank (copy) the highlighted text.

  4. Move the cursor to the end of the next line:  j$

  5. Type  p  to put (paste) the text.  Then type:  a second <ESC> .

  6. Use Visual mode to select " item.", yank it with  y , move to the end of
     the next line with  j$  and put the text there with  p . 

--->  a) this is the first item.
      b)

  NOTE: You can also use  y  as an operator:  yw  yanks one word,
        yy  yanks the whole line, then  p  puts that line.

Aha. Alakul ez.

Szóval ez úgy volt, hogy a ~20 gépből kettőn nem ment. Az a kettő pont Ubuntu, frissebb csomaggal. Oké, néztem én hogy milyen cséncsek vannak amik eltörnet ezt-azt, de túl hosszú volt a lista, illetve biztos voltam benne, hogy az általam frissen összeügyeskedett konfiggal van a baj.

Persze miután már teljesen mindenféle plugin, konfig, minden nélkül indítva se volt jó, kezdett gyanús lenni. Aztán kiderült, hogy már eleve a regiszterbe "rosszul" yankol, és akkor már "könnyű" volt, hogy tudtam, pontosan mire is is keressek.

Aztán ja, hát ilyen, az egyik vi* ilyen, a másik vi* olyan.

Szerkesztve: 2023. 04. 07., p – 18:11

20+ éve használok vi(m)-(e)t, alap szinten. Én mindig is "yy"-jal copy-ztam 1 sort, 4yy paranccsal 4 sort, stb.

Az aktuális sortól a fájl végéig yank-et meg mindig y+Shift+G-vel csinálom.

A gyors gondolat többet ér, mint a gyors mozdulat.