vi-mode: Adding additional C-w functionality (Window management) #1713
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Preface
Hi! I just want to start off by saying how much I am enjoying Lem. It has been great to work with the project.
I am a vim user, and wanted to add some of the functionality around window management to the Lem vi-mode.
This is my first public pull request, so please let me know if anything is not protocol. I am also new to common lisp and lisp in general, so I am very happy to take on feedback about the code. Same with the Lem specific stuff. I am not an expert yet.
I would also be happy to break this up into smaller pull requests if that would help, let me know. Although there are sections like Keybinds and Ex-Commands, they use the same vi-* functions in a lot of cases.
Thank you for your time.
Lee
Feature Breakdown
I tested what I could with a clean vim build to verify this functionality matched.
To each key where the docs specified(https://vimhelp.org/windows.txt.html), I added the alternative C-w h & C-w C-h. Some are not in vim like C-w C-c.
Keybinds
C-w hjkl
Navigating splits.
To allow number prefix, eg.
2 C-w l
New Commands
C-w s/v
Splits the window and moves to the split.
This now allows a number prefix, eg.
3 C-w v
New Commands
C-w n
Split the window and creates a new window as per the vim docs here: https://vimhelp.org/windows.txt.html#opening-window
New Commands
C-w c
Closes the current split. If there is one window, don't close it as in vi/vim.
New Commands
C-w p
Uses Lem function to go to previous window.
C-w o
Uses Lem function to delete other windows.
Ex-Commands
These link up with the above keybinds for the most part.
:new
Creates a new buffer in a split below. Uses the
C-w n
command: (vi-window-split-vertically-new):vne(w)
Creates a new buffer in a split to the right. Uses something similar to the above: (vi-window-split-horizontally-new)
There isn't a vanilla vim keybinding to match this functionality.
:enew(w)
Opens the specified file name or creates a blank buffer.
There isn't a vanilla vim keybinding to match this functionality.
:clo(se)
Closes the buffer, unless it's the last one. Uses the
C-w c
command: (vi-close):on(ly)
Uses Lem function to delete other windows. Same as
C-w o
: (lem:delete-other-windows)Bug with :wa
There was a small bug in the matching for :wa(ll) and :wa(ll)!
They did not treat the (ll) as optional.