Skip to content

Commit

Permalink
add new C-w window management bidnings in vi-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
vindarel committed Dec 27, 2024
1 parent 77264d3 commit 6fa26b1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
40 changes: 34 additions & 6 deletions content/en/usage/keybindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,22 @@ The up to date list it to be found on Github: https://github.com/lem-project/lem
## Buffer
| Command | Key bindings | Documentation |
|-----------------------------------------------------------------------------------------------|--------------|-----------------------------------------------|
| [select-buffer](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L62) | C-x b | Switches to the selected buffer. |
| [kill-buffer](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L101) | C-x k | Delete buffer. |
| [previous-buffer](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L110) | C-x Left | Switches to the previous buffer. |
| [next-buffer](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L120) | C-x Right | Switches to the next buffer. |
| [recenter](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L126) | C-l | Scroll so that the cursor is in the middle. |
| [toggle-read-only](https://github.com/lem-project/lem/blob/main/src/commands/buffer.lisp#L14) | C-x C-q | Toggle the buffer read-only. |
| [rename-buffer](https://github.com/lem-project/lem/blob/main/src/commands/buffer.lisp#L22) | | Rename the buffer. |
| [unmark-buffer](https://github.com/lem-project/lem/blob/main/src/commands/buffer.lisp#L26) | M-~ | Remove the mark where the buffer was changed. |

## Window
## Window management

### emacs-mode (default)


| Command | Key bindings | Documentation |
|----------------------------------------------------------------------------------------------------------------|----------------|-----------------------------------------------------------------------|
| [select-buffer](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L62) | C-x b | Switches to the selected buffer. |
| [kill-buffer](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L101) | C-x k | Delete buffer. |
| [previous-buffer](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L110) | C-x Left | Switches to the previous buffer. |
| [next-buffer](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L120) | C-x Right | Switches to the next buffer. |
| [recenter](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L126) | C-l | Scroll so that the cursor is in the middle. |
| [split-active-window-vertically](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L133) | C-x 2 | Split the current window vertically. |
| [split-active-window-horizontally](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L139) | C-x 3 | Split the current window horizontally. |
| [other-window](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L150) | C-x o, M-o | Go to the next window. |
Expand All @@ -164,6 +168,30 @@ The up to date list it to be found on Github: https://github.com/lem-project/lem
| [select-buffer-other-window](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L278) | C-x 4 b | Select a buffer in another window. |
| [compare-windows](https://github.com/lem-project/lem/blob/main/src/commands/window.lisp#L282) | | |

### vi-mode

And now the vi-mode keybindings


| Keybinding | Function | Command(s) |
|:----------:|:-----------------------:|:------------:|
| `C-w hjkl` | Navigating split windows| `(vi-window-move-[left, right, down, up])` |
| `C-w s/v` | Splits the window and moves to the split | `(vi-window-split-[horizontally, vertically)` |
| `C-w n` | Split the window and creates a new window | `(vi-window-split-vertically-new)` |
| `C-w c` | Closes the current split, except the last one | `(vi-close)` |
| `C-w p` | Go to the previous window | calls `previous-window` |
| `C-w o` | Delete other windows | calls `delete-other-windows` |

Ex commands are:

| Ex-command | Function |
|:----------:|:--------------------------:|
| `:new` | Creates a new buffer in a split below. Uses the `C-w n` command. |
| `:vne(w)` | Creates a new buffer in a split to the right. |
| `:enew(w)` | Opens the specified file name or creates a blank buffer. |
| `:clo(se)` | Closes the buffer, unless it's the last one. Uses the C-w c command: (vi-close) |
| `:on(ly)` | delete other windows. |

## Multiple-Cursors
| Command | Key bindings | Documentation |
|----------------------------------------------------------------------------------------------------------------|--------------|-------------------------------------------------------------|
Expand Down
12 changes: 9 additions & 3 deletions content/en/usage/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ These other commands are not bound to a key:
| `window-move-down/up` | | Go to the window at the bottom / at the top |
| `window-move-left/right` | | Go to the window at the left / at the right |

Many window-management commands are available in vi-mode. They start
with the `C-w` prefix, and you'll find ex commands too. Some commands
accept a number prefix, as in `3 C-w v`.

For the full list of keybindings please see the [keybindings page](/usage/keybindings/#window-management).


### Frames (maximize, minimize)

Expand Down Expand Up @@ -349,12 +355,12 @@ to re-play the macro only in the selected region.
M-x grep

this presents the results in a two-panes window. You can edit lines in the results buffer, changes are reflected immediately on the files, and updated on the right side. You can use search and replace `M-x query-replace` in the results buffer.

> To set the default args for grep command, put this in your `~/.lem/init.lisp` file.
> ```
> ```
> (setf lem/grep:*grep-args* "-niHI")
> (setf lem/grep::*last-query* "git grep -niHI ")
> ```
> ```
>
See also: `M-x project-grep`, bound to `C-x p g`.
Expand Down

0 comments on commit 6fa26b1

Please sign in to comment.