Skip to content

create intuitive bindings for copy and paste #3008

@midichef

Description

@midichef

After all this time with Visidata, I still can't keep straight in my head all the variations of y/gy/gzy/zp etc. In the past, we've talked about trimming these commands to a manageable subset.

Instead, maybe we could keep the commands, but make them more intuitive and memorable. I'd like to suggest some ideas, to open up the possibilities.

Here's one idea, make y and p a vim-style "operator-pending" command, that takes a second letter to decide what shape to apply the yank/paste to. This is a prototype to test out in .visidatarc: y or p is applied to a shape that suggests the shape of the sheet elements it is applied to: . for cell, - for row, | for column:

Sheet.bindkey('y',  None)
Sheet.bindkey('p',  None)
vd.allPrefixes += ['y', 'p']
                                          #Existing binding
Sheet.bindkey('y.',  'copy-cell')         # zy
Sheet.bindkey('y-',  'copy-row')          #  y
Sheet.bindkey('ys-', 'copy-selected')     # gy        # selected rows
Sheet.bindkey('ys|', 'copy-cells')        #gzy        # selected cells in current column
Sheet.bindkey('p.',  'paste-cell')        # zp
Sheet.bindkey('p,',  'paste-after')       #  p        #maybe p- or p_ instead?
Sheet.bindkey('p',  'paste-before')      #  P
## the paste equivalent of 'ys-' does not exist; b/c there is no gp command, perhaps it would be:
## Sheet.bindkey('ps-', 'paste-selected') #none  
Sheet.bindkey('ps|', 'setcol-clipboard')  #gzp        # selected cells in current column

The syscopy- and syspaste- equivalents could use the prefixes Y or P, perhaps. Or gy and gp.

Some other ideas:

## letter based mnemonics
yc     copy-cell
yr     copy-row
ys     copy-selected
yC     copy-cells

## motion based mnemonics
yh/yl  copy-cell
yy     copy-row     (maybe also yj/yk)
ys     copy-selected
y|     copy-cells   (maybe also y, )

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions