Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vi mode #2174

Merged
merged 39 commits into from May 6, 2023
Merged

Vi mode #2174

merged 39 commits into from May 6, 2023

Conversation

koltenpearson
Copy link
Contributor

You just knew this was inevitable after letting there be an emacs mode ; )

The keybindings are not all one to one with vi, and I did not try to replicate vi's ability to parse sequences of keys to customize the effects of commands. Rather than being a perfect of version of vi/vim, its purpose is to help someone with vi muscle memory from stumbling over themselves constantly

I think I got most of the keybindings that were easy to add with the available functionality, in the next few weeks I hope to add some functionality so I can add more motion commands. I might also try and add to the other non code editors and at least let hjkl work for what the arrow keys would normally do where it makes sense.

@sthilaid
Copy link
Contributor

sthilaid commented Apr 24, 2023 via email

@koltenpearson
Copy link
Contributor Author

just a quick note, that last commit fixes #1997, don't want it to get lost in the shuffle if the vi mode ends up not being desired

@koltenpearson
Copy link
Contributor Author

this last commit added a replace all feature. I am not sure the best way to add it to UI, as that icon bar is looking a little crowded. Any suggestions on the best way to incorporate it?

@koltenpearson koltenpearson marked this pull request as draft April 27, 2023 04:38
@koltenpearson
Copy link
Contributor Author

I just noticed that there is a draft mode for WIP pull requests, and that other PRs in the repo were using it, sorry if that was spamming anyone

@koltenpearson
Copy link
Contributor Author

koltenpearson commented May 4, 2023

okay I think I have added all the functionality I am going to add, here are the keybindings at the moment :

Motion Keys (work in both normal and select mode) :

    h - left one column
    k - up one row
    j - down one row
    l - right one column
    (arrow keys also work)

    g - start of file
    G - end of file

    0,Home - start of line
    $,End - end of line

    ctrl+u,pageup - up one screen
    ctrl+d,pagedown - down one screen
    K - up half screen
    J - down half screen

    b - back one word
    w - forward one word

    ^ - first non-whitespace character on line

    { - next empty line above current position
    } - next empty line below current position

    % - jump to matching delimiter

    f - seek forward in line to next character typed
    F - seek backward in line to next character typed

    ; - seek forward in line to next character under cursor
    : - seek backwards in line to next character under cursor


Insert Mode :
    escape - switch to normal mode
    typing letters inserts text

Normal Mode :
    
    escape - exit editor to console

    i - enter insert mode
    a - move right one column and enter insert mode 
    o - insert a new line below current line and enter insert mode on that line
    O - insert a new line above current line and enter insert mode on that line
    space - create a new line under the current line
    shift+space - create a new line above the current line
    v - enter select mode (visual mode from vi)
    / - find
    n - go to next occurance of found word
    N - go to previous occurance of found word
    # - go to next occurance of word under cursor
    r - find and replace
    u - undo
    U - redo
    p - paste, will place multi line blocks of code on line below
    P - paste, will place multi line blocks of code above current line

    1-9 - goto line, just type the line number and it will take you there

    [ - go to function definition if it can be found
    ? - open code outline

    m - mark current line
    M - open bookmark list
    , - goto previous bookmark
    . - goto next bookmark

    z - recenter screen

    -(minus) - comment line
    x - delete character under cursor
    ~ - toggle case of character under cursor

    d - cut current line
    y - copy current line

    W - save project
    R - run game

    c - delete word under cursor and enter insert mode
        if over a delimiter or quotation, delete contents contained and enter insert mode
    C - delete until the end of the line and enter insert mode

    > - indent line
    < - dedent line

    alt + f - toggle font size
    alt + s - toggle font shadow

Select Mode :

    escape - switch to normal mode
    -(minus) - comment block
    y - copy block
    d - cut block
    p - paste over block
    c - delete block and enter insert mode
    > - indent block
    < - dedent block
    / - find populating current selection
    r - find and replace within block
    ~ - toggle case in block

If anyone has any feedback on the choices let me know. My plan now is to use this personally for a few weeks to double check for any bugs and see if there are any adjustments that seem like it would be good to apply and then declare it done and request to be merged.

I will go ahead and mark it ready for review now, so I can be fixing any issue with the code found in review as I use it as well.

@koltenpearson koltenpearson marked this pull request as ready for review May 4, 2023 06:08
@nesbox nesbox added this to To do in dev version 1.1 via automation May 6, 2023
@nesbox nesbox merged commit b8e722b into nesbox:main May 6, 2023
30 checks passed
dev version 1.1 automation moved this from To do to Done May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants