forked from mirrors/qmk_firmware
Vim Layout for Ergodox-EZ (mac only) (#2112)
* ignore libs * Clang complete file * Add VIM_A, VIM_S, VIM_COMMAND_SHIFT_D, and VIM_COMMAND_SHIFT_A Add VIM_A, VIM_S, VIM_COMMAND_SHIFT_D, and VIM_COMMAND_SHIFT_A a s O * Comment blocks for minimap generated at http://patorjk.com/software/taag/#p=display&h=0&v=0&c=c&f=Banner&t=COMMENT * Be explicit * More Comment blocks * Add J * add A, C, D, J, S, O * Make h j k l explicitly vim commands (useful for JOIN) * add cb ce cw ch cj ck cl db de dw dh dj dk dl vb ve vh vj vk vl x ciw diw viw * debug messages for ci di vi * Var capitalized * Save bytes by disabling mouse keys * Add Y P * Be more explicit about which key was pressed * Be more explicit about which key was sent * Move project to new directory structure * Remove non-vim layout folder * Replace KC_TRNS with KC_NO on normal layer * Insert Mode as default * Try to prevent crashes * Put normal mode back * Revert "ignore libs" This reverts commit 4c5d7592d6c1b70e689c0b9400afca19c71970a7. * add rules.mk * Add mouse bindings * Checkout most recent keymap following rebase * Realign mouse button keys * Make a macro for TO(NORMAL_MODE)
This commit is contained in:
parent
eeb6443767
commit
98ac32b417
6 changed files with 1180 additions and 0 deletions
24
.clang_complete
Normal file
24
.clang_complete
Normal file
|
@ -0,0 +1,24 @@
|
|||
|
||||
-I.
|
||||
-I./drivers
|
||||
-I./drivers/avr
|
||||
-I./keyboards/ergodox_ez
|
||||
-I./keyboards/ergodox_ez/keymaps/vim
|
||||
-I./lib
|
||||
-I./lib/lufa
|
||||
-I./quantum
|
||||
-I./quantum/api
|
||||
-I./quantum/audio
|
||||
-I./quantum/keymap_extras
|
||||
-I./quantum/process_keycode
|
||||
-I./quantum/serial_link
|
||||
-I./quantum/template
|
||||
-I./quantum/tools
|
||||
-I./quantum/visualizer
|
||||
-I./tmk_core
|
||||
-I./tmk_core/common
|
||||
-I./tmk_core/common/debug.h
|
||||
-I./tmk_core/protocol
|
||||
-I./tmk_core/protocol/lufa
|
||||
-I./util
|
||||
-DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYMAP=\"$(KEYMAP)\"
|
10
keyboards/ergodox_ez/keymaps/vim/config.h
Normal file
10
keyboards/ergodox_ez/keymaps/vim/config.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef CONFIG_USER_H
|
||||
#define CONFIG_USER_H
|
||||
#endif
|
||||
|
||||
#define NORMAL_MODE 0
|
||||
#define INSERT_MODE 1
|
||||
#define SYMB 2
|
||||
#define MOUSE 3
|
||||
|
||||
#include "../../config.h"
|
384
keyboards/ergodox_ez/keymaps/vim/keymap.c
Normal file
384
keyboards/ergodox_ez/keymaps/vim/keymap.c
Normal file
|
@ -0,0 +1,384 @@
|
|||
#include QMK_KEYBOARD_H
|
||||
#include "quantum_keycodes.h"
|
||||
#include "action_layer.h"
|
||||
#include "version.h"
|
||||
#include "vim.h"
|
||||
|
||||
#define VERSION_STRING QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION
|
||||
#define _______ KC_TRNS
|
||||
#define X_____X KC_TRNS
|
||||
#define KC_ATM LGUI(LSFT(KC_P))
|
||||
#define KC_ATP LGUI(LCTL(KC_P))
|
||||
#define TO_NORM TO(NORMAL_MODE)
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
/* Normal mode
|
||||
*
|
||||
* ,--------------------------------------------------. ,--------------------------------------------------.
|
||||
* | | | | | | | | | | | | | | | |
|
||||
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
|
||||
* | TAB | | WORD | END | | | | | | YANK | UNDO | | OPEN | PUT | |
|
||||
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
|
||||
* | ⎋ | | | DEL | | |------| |------| ← | ↓ | ↑ | → | | ⎋ |
|
||||
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
|
||||
* | SHIFT | | | |VISUAL| BACK | | | | | | | | | SHIFT |
|
||||
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
|
||||
* | | | | | | | | | | | |
|
||||
* `----------------------------------' `----------------------------------'
|
||||
* ,-------------. ,-------------.
|
||||
* | | | | | |
|
||||
* ,------|------|------| |------+------+------.
|
||||
* | | | | | | | |
|
||||
* |SPACE |DELETE|------| |------|ENTER |BACKSP|
|
||||
* | | | | | | | |
|
||||
* `--------------------' `--------------------'
|
||||
*/
|
||||
[NORMAL_MODE] = KEYMAP(
|
||||
// Layer 2 Left Hand
|
||||
X_____X,X_____X,X_____X,X_____X,X_____X,X_____X,X_____X,
|
||||
KC_TAB ,X_____X,VIM_W, VIM_E ,X_____X,X_____X,X_____X,
|
||||
X_____X,VIM_A ,VIM_S ,VIM_D ,X_____X,X_____X,
|
||||
KC_LSFT,X_____X,VIM_X ,VIM_C ,VIM_V ,VIM_B ,X_____X,
|
||||
KC_LCTL,KC_LALT,X_____X,X_____X,X_____X,
|
||||
|
||||
KC_HOME,KC_END ,
|
||||
TO(SYMB),
|
||||
GUI_T(KC_SPC), KC_ESC ,_______,
|
||||
|
||||
|
||||
// Layer 2 Right Hand
|
||||
X_____X,X_____X,X_____X,X_____X,X_____X,X_____X,X_____X,
|
||||
X_____X,VIM_Y ,VIM_U ,VIM_I ,VIM_O ,VIM_P ,X_____X,
|
||||
VIM_H ,VIM_J ,VIM_K ,VIM_L ,X_____X,X_____X,
|
||||
X_____X,X_____X,X_____X,X_____X,X_____X,X_____X,KC_LSFT,
|
||||
X_____X,X_____X,X_____X,KC_RALT,KC_RCTL,
|
||||
|
||||
KC_PGUP, KC_PGDN,
|
||||
TO(SYMB),
|
||||
KC_DEL , KC_ENT, GUI_T(KC_BSPC)
|
||||
),
|
||||
|
||||
/* Insert mode
|
||||
*
|
||||
* ,--------------------------------------------------. ,--------------------------------------------------.
|
||||
* | NORMAL | 1 | 2 | 3 | 4 | 5 | ⇧⌘P | | PROJ | 6 | 7 | 8 | 9 | 0 | - |
|
||||
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
|
||||
* | ⇥ | Q | W | E | R | T | ` | | - | Y | U | I | O | P | \ |
|
||||
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
|
||||
* | ⎋ | A | S | D | F | G |------| |------| H | J | K | L | ; | ' |
|
||||
* |--------+------+------+------+------+------| = | | + |------+------+------+------+------+--------|
|
||||
* | L⇧ | Z | X | C | V | B | | | | N | M | , | . | / | R⇧ |
|
||||
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
|
||||
* | ⌃ | ⌥ | ( | [ | { | | } | ] | ) | ⌥ | ⌃ |
|
||||
* `----------------------------------' `----------------------------------'
|
||||
* ,-------------. ,-------------.
|
||||
* | HOME | END | | PGDN | PGUP |
|
||||
* ,------|------|------| |------+------+------.
|
||||
* |SPACE | | | | | | BSPC |
|
||||
* | |NORMAL|------| |------| ENTER| |
|
||||
* | ⌘ | | | | | | ⌘ |
|
||||
* `--------------------' `--------------------'
|
||||
*/
|
||||
[INSERT_MODE] = KEYMAP(
|
||||
// Left Hand
|
||||
NOR_MOD,KC_1, KC_2, KC_3, KC_4, KC_5, KC_ATM,
|
||||
KC_TAB ,KC_Q, KC_W, KC_E, KC_R, KC_T, KC_GRV,
|
||||
KC_ESC ,KC_A, KC_S, KC_D, KC_F, KC_G,
|
||||
KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_EQL,
|
||||
KC_LCTL,KC_LALT,KC_LPRN,KC_LBRC, KC_LCBR,
|
||||
|
||||
KC_HOME,KC_END ,
|
||||
TO(SYMB),
|
||||
GUI_T(KC_SPC),KC_ESC ,TO_NORM,
|
||||
|
||||
|
||||
// Right Hand
|
||||
KC_ATP , KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
|
||||
KC_MINS, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
|
||||
KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT,
|
||||
KC_PLUS, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH,KC_RSFT,
|
||||
KC_RCBR,KC_RBRC, KC_RPRN,KC_RALT,KC_RCTL,
|
||||
|
||||
KC_PGUP, KC_PGDN,
|
||||
TO(SYMB),
|
||||
MO(MOUSE) , KC_ENT, GUI_T(KC_BSPC)
|
||||
),
|
||||
|
||||
[SYMB] = KEYMAP(
|
||||
// Left Hand
|
||||
NOR_MOD,KC_1, KC_2, KC_3, KC_4, KC_5, KC_ATM,
|
||||
KC_TAB ,KC_Q, KC_W, KC_E, KC_R, KC_T, KC_GRV,
|
||||
_______,KC_A, KC_S, KC_D, KC_F, KC_G,
|
||||
KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_EQL,
|
||||
KC_LCTL,KC_LALT,KC_LPRN,KC_LBRC, KC_LCBR,
|
||||
|
||||
_______,_______,
|
||||
_______,
|
||||
_______,_______,TO_NORM,
|
||||
|
||||
// Right Hand
|
||||
KC_ATP , KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
|
||||
KC_MINS, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
|
||||
KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT,
|
||||
KC_PLUS, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH,KC_RSFT,
|
||||
KC_RCBR,KC_RBRC, KC_RPRN,KC_RALT,KC_RCTL,
|
||||
|
||||
_______,_______,
|
||||
_______,
|
||||
_______,_______,_______
|
||||
),
|
||||
|
||||
[MOUSE] = KEYMAP(
|
||||
// Left Hand
|
||||
_______,_______,_______,_______,_______,_______,_______,
|
||||
_______,_______,_______,_______,_______,_______,_______,
|
||||
_______,_______,_______,_______,_______,_______,
|
||||
_______,_______,_______,_______,_______,_______,_______,
|
||||
_______,_______,_______,_______,_______,
|
||||
|
||||
_______,_______,
|
||||
_______,
|
||||
_______,_______,_______,
|
||||
|
||||
// Right Hand
|
||||
_______,_______,_______,_______,_______,_______,_______,
|
||||
_______,_______,KC_BTN1,KC_BTN3,KC_BTN2,_______,_______,
|
||||
KC_MS_L,KC_MS_D,KC_MS_U,KC_MS_R,_______,_______,
|
||||
_______,_______,_______,_______,_______,_______,_______,
|
||||
_______,_______,_______,_______,_______,
|
||||
|
||||
_______,_______,
|
||||
_______,
|
||||
_______,_______,_______
|
||||
),
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_TAP_TOGGLE(1)
|
||||
};
|
||||
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
|
||||
switch(id) {
|
||||
case 0:
|
||||
if (record->event.pressed) { SEND_STRING (VERSION_STRING); }
|
||||
break;
|
||||
}
|
||||
return MACRO_NONE;
|
||||
};
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
bool SHIFTED = (keyboard_report->mods & MOD_BIT(KC_LSFT)) |
|
||||
(keyboard_report->mods & MOD_BIT(KC_RSFT));
|
||||
|
||||
switch (keycode) {
|
||||
|
||||
case VIM_A:
|
||||
if (record->event.pressed) { SHIFTED ? VIM_APPEND_LINE() : VIM_APPEND(); }
|
||||
return false;
|
||||
|
||||
case VIM_B:
|
||||
if (record->event.pressed) {
|
||||
switch(VIM_QUEUE) {
|
||||
case KC_NO: VIM_BACK(); break;
|
||||
case VIM_C: VIM_CHANGE_BACK(); break;
|
||||
case VIM_D: VIM_DELETE_BACK(); break;
|
||||
case VIM_V: VIM_VISUAL_BACK(); break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
case VIM_C:
|
||||
if (record->event.pressed) {
|
||||
switch(VIM_QUEUE) {
|
||||
case KC_NO: SHIFTED ? VIM_CHANGE_LINE() : VIM_LEADER(VIM_C); break;
|
||||
case VIM_C: VIM_CHANGE_WHOLE_LINE(); break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
case VIM_D:
|
||||
if (record->event.pressed) {
|
||||
switch(VIM_QUEUE) {
|
||||
case KC_NO: SHIFTED ? VIM_DELETE_LINE() : VIM_LEADER(VIM_D); break;
|
||||
case VIM_D: VIM_DELETE_WHOLE_LINE(); break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
case VIM_E:
|
||||
if (record->event.pressed) {
|
||||
switch (VIM_QUEUE) {
|
||||
case KC_NO: VIM_END(); break;
|
||||
case VIM_C: VIM_CHANGE_END(); break;
|
||||
case VIM_D: VIM_DELETE_END(); break;
|
||||
case VIM_V: VIM_VISUAL_END(); break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
case VIM_H:
|
||||
if (record->event.pressed) {
|
||||
switch (VIM_QUEUE) {
|
||||
case KC_NO: VIM_LEFT(); break;
|
||||
case VIM_C: VIM_CHANGE_LEFT(); break;
|
||||
case VIM_D: VIM_DELETE_LEFT(); break;
|
||||
case VIM_V: VIM_VISUAL_LEFT(); break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
case VIM_I:
|
||||
if (record->event.pressed) {
|
||||
switch (VIM_QUEUE) {
|
||||
case KC_NO: layer_on(INSERT_MODE); break;
|
||||
case VIM_C: VIM_LEADER(VIM_CI); break;
|
||||
case VIM_D: VIM_LEADER(VIM_DI); break;
|
||||
case VIM_V: VIM_LEADER(VIM_VI); break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
case VIM_J:
|
||||
if (record->event.pressed) {
|
||||
switch (VIM_QUEUE) {
|
||||
case KC_NO: SHIFTED ? VIM_JOIN() : VIM_DOWN(); break;
|
||||
case VIM_C: VIM_CHANGE_DOWN(); break;
|
||||
case VIM_D: VIM_DELETE_DOWN(); break;
|
||||
case VIM_V: VIM_VISUAL_DOWN(); break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
case VIM_K:
|
||||
if (record->event.pressed) {
|
||||
switch (VIM_QUEUE) {
|
||||
case KC_NO: VIM_UP(); break;
|
||||
case VIM_C: VIM_CHANGE_UP(); break;
|
||||
case VIM_D: VIM_DELETE_UP(); break;
|
||||
case VIM_V: VIM_VISUAL_UP(); break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
case VIM_L:
|
||||
if (record->event.pressed) {
|
||||
switch (VIM_QUEUE) {
|
||||
case KC_NO: VIM_RIGHT(); break;
|
||||
case VIM_C: VIM_CHANGE_RIGHT(); break;
|
||||
case VIM_D: VIM_DELETE_RIGHT(); break;
|
||||
case VIM_V: VIM_VISUAL_RIGHT(); break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
case VIM_O:
|
||||
if (record->event.pressed) { SHIFTED ? VIM_OPEN_ABOVE() : VIM_OPEN(); }
|
||||
return false;
|
||||
|
||||
case VIM_P:
|
||||
if (record->event.pressed) { SHIFTED ? VIM_PUT_BEFORE() : VIM_PUT(); }
|
||||
return false;
|
||||
|
||||
case VIM_S:
|
||||
if (record->event.pressed) { SHIFTED ? VIM_CHANGE_WHOLE_LINE() : VIM_SUBSTITUTE(); }
|
||||
return false;
|
||||
|
||||
case VIM_U:
|
||||
if (record->event.pressed) { VIM_UNDO(); }
|
||||
return false;
|
||||
|
||||
case VIM_V:
|
||||
if (record->event.pressed) { VIM_LEADER(VIM_V); }
|
||||
return false;
|
||||
|
||||
case VIM_W:
|
||||
if (record->event.pressed) {
|
||||
switch (VIM_QUEUE) {
|
||||
case KC_NO: VIM_WORD(); break;
|
||||
case VIM_C: VIM_CHANGE_WORD(); break;
|
||||
case VIM_CI: VIM_CHANGE_INNER_WORD(); break;
|
||||
case VIM_D: VIM_DELETE_WORD(); break;
|
||||
case VIM_DI: VIM_DELETE_INNER_WORD(); break;
|
||||
case VIM_V: VIM_VISUAL_WORD(); break;
|
||||
case VIM_VI: VIM_VISUAL_INNER_WORD(); break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
case VIM_X:
|
||||
if (record->event.pressed) { VIM_CUT(); }
|
||||
return false;
|
||||
|
||||
case VIM_Y:
|
||||
if (record->event.pressed) { SHIFTED ? VIM_YANK_LINE() : VIM_YANK(); }
|
||||
return false;
|
||||
|
||||
// dynamically generate these.
|
||||
case EPRM:
|
||||
if (record->event.pressed) { eeconfig_init(); }
|
||||
return false;
|
||||
case VRSN:
|
||||
if (record->event.pressed) { SEND_STRING(VERSION_STRING); }
|
||||
return false;
|
||||
case RGB_SLD:
|
||||
if (record->event.pressed) { rgblight_mode(1); }
|
||||
return false;
|
||||
}
|
||||
|
||||
// End by clearing the queue unless keycode is a
|
||||
// if ((record->event.pressed) &&
|
||||
// (keycode != VIM_I ||
|
||||
// keycode != VIM_C ||
|
||||
// keycode != VIM_D ||
|
||||
// keycode != VIM_V)) {
|
||||
// VIM_LEADER(KC_NO);
|
||||
// }
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
void matrix_init_user(void) {
|
||||
debug_enable = true;
|
||||
VIM_LEADER(KC_NO);
|
||||
};
|
||||
|
||||
void matrix_scan_user(void) {
|
||||
uint8_t layer = biton32(layer_state);
|
||||
|
||||
ergodox_board_led_off();
|
||||
ergodox_right_led_1_off();
|
||||
ergodox_right_led_2_off();
|
||||
ergodox_right_led_3_off();
|
||||
switch (layer) {
|
||||
case 1:
|
||||
ergodox_right_led_1_on();
|
||||
break;
|
||||
case 2:
|
||||
ergodox_right_led_2_on();
|
||||
break;
|
||||
case 3:
|
||||
ergodox_right_led_3_on();
|
||||
break;
|
||||
case 4:
|
||||
ergodox_right_led_1_on();
|
||||
ergodox_right_led_2_on();
|
||||
break;
|
||||
case 5:
|
||||
ergodox_right_led_1_on();
|
||||
ergodox_right_led_3_on();
|
||||
break;
|
||||
case 6:
|
||||
ergodox_right_led_2_on();
|
||||
ergodox_right_led_3_on();
|
||||
break;
|
||||
case 7:
|
||||
ergodox_right_led_1_on();
|
||||
ergodox_right_led_2_on();
|
||||
ergodox_right_led_3_on();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
};
|
5
keyboards/ergodox_ez/keymaps/vim/readme.md
Normal file
5
keyboards/ergodox_ez/keymaps/vim/readme.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Vim-like keymap for macOS
|
||||
|
||||
This keymap adds vim emulation to the keyboard firmware. Layer 0 is 'normal mode', providing a number of commands like `w`, `e`, `a`, `dw`, etc.
|
||||
|
||||
The keymap works by using macOS text-editing shortcuts, so currently it only chooches on macOS.
|
1
keyboards/ergodox_ez/keymaps/vim/rules.mk
Normal file
1
keyboards/ergodox_ez/keymaps/vim/rules.mk
Normal file
|
@ -0,0 +1 @@
|
|||
MOUSEKEY_ENABLE = yes
|
756
keyboards/ergodox_ez/keymaps/vim/vim.h
Normal file
756
keyboards/ergodox_ez/keymaps/vim/vim.h
Normal file
|
@ -0,0 +1,756 @@
|
|||
#include "config.h"
|
||||
#include "print.h"
|
||||
#include "keycode.h"
|
||||
#include "quantum.h"
|
||||
#include "quantum_keycodes.h"
|
||||
|
||||
#define NOR_MOD TO(NORMAL_MODE)
|
||||
#define INS_MOD TO(INSERT_MODE)
|
||||
|
||||
#define PRESS(keycode) register_code16(keycode)
|
||||
#define RELEASE(keycode) unregister_code16(keycode)
|
||||
#define PREVENT_STUCK_MODIFIERS
|
||||
|
||||
uint16_t VIM_QUEUE = KC_NO;
|
||||
|
||||
enum custom_keycodes {
|
||||
PLACEHOLDER = SAFE_RANGE, // can always be here
|
||||
VIM_A,
|
||||
VIM_B,
|
||||
VIM_C,
|
||||
VIM_CI,
|
||||
VIM_D,
|
||||
VIM_DI,
|
||||
VIM_E,
|
||||
VIM_H,
|
||||
VIM_I,
|
||||
VIM_J,
|
||||
VIM_K,
|
||||
VIM_L,
|
||||
VIM_O,
|
||||
VIM_P,
|
||||
VIM_S,
|
||||
VIM_U,
|
||||
VIM_V,
|
||||
VIM_VI,
|
||||
VIM_W,
|
||||
VIM_X,
|
||||
VIM_Y,
|
||||
EPRM,
|
||||
VRSN,
|
||||
RGB_SLD,
|
||||
};
|
||||
|
||||
void VIM_APPEND(void);
|
||||
void VIM_APPEND_LINE(void);
|
||||
void VIM_BACK(void);
|
||||
void VIM_CHANGE_BACK(void);
|
||||
void VIM_CHANGE_DOWN(void);
|
||||
void VIM_CHANGE_END(void);
|
||||
void VIM_CHANGE_INNER_WORD(void);
|
||||
void VIM_CHANGE_LEFT(void);
|
||||
void VIM_CHANGE_LINE(void);
|
||||
void VIM_CHANGE_RIGHT(void);
|
||||
void VIM_CHANGE_UP(void);
|
||||
void VIM_CHANGE_WHOLE_LINE(void);
|
||||
void VIM_CHANGE_WORD(void);
|
||||
void VIM_CUT(void);
|
||||
void VIM_DELETE_BACK(void);
|
||||
void VIM_DELETE_DOWN(void);
|
||||
void VIM_DELETE_END(void);
|
||||
void VIM_DELETE_INNER_WORD(void);
|
||||
void VIM_DELETE_LEFT(void);
|
||||
void VIM_DELETE_LINE(void);
|
||||
void VIM_DELETE_RIGHT(void);
|
||||
void VIM_DELETE_UP(void);
|
||||
void VIM_DELETE_WHOLE_LINE(void);
|
||||
void VIM_DELETE_WORD(void);
|
||||
void VIM_END(void);
|
||||
void VIM_JOIN(void);
|
||||
void VIM_OPEN(void);
|
||||
void VIM_OPEN_ABOVE(void);
|
||||
void VIM_PUT(void);
|
||||
void VIM_SUBSTITUTE(void);
|
||||
void VIM_UNDO(void);
|
||||
void VIM_VISUAL_BACK(void);
|
||||
void VIM_VISUAL_DOWN(void);
|
||||
void VIM_VISUAL_END(void);
|
||||
void VIM_VISUAL_INNER_WORD(void);
|
||||
void VIM_VISUAL_LEFT(void);
|
||||
void VIM_VISUAL_RIGHT(void);
|
||||
void VIM_VISUAL_UP(void);
|
||||
void VIM_VISUAL_WORD(void);
|
||||
void VIM_WORD(void);
|
||||
void VIM_YANK(void);
|
||||
|
||||
void TAP(uint16_t keycode) {
|
||||
PRESS(keycode);
|
||||
RELEASE(keycode);
|
||||
}
|
||||
|
||||
void CMD(uint16_t keycode) {
|
||||
PRESS(KC_LGUI);
|
||||
TAP(keycode);
|
||||
RELEASE(KC_LGUI);
|
||||
}
|
||||
|
||||
void CTRL(uint16_t keycode) {
|
||||
PRESS(KC_LCTRL);
|
||||
TAP(keycode);
|
||||
RELEASE(KC_LCTRL);
|
||||
}
|
||||
|
||||
void SHIFT(uint16_t keycode) {
|
||||
PRESS(KC_LSHIFT);
|
||||
TAP(keycode);
|
||||
RELEASE(KC_LSHIFT);
|
||||
}
|
||||
|
||||
void ALT(uint16_t keycode) {
|
||||
PRESS(KC_LALT);
|
||||
TAP(keycode);
|
||||
RELEASE(KC_LALT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the `VIM_QUEUE` variable to the incoming keycode.
|
||||
* Pass `KC_NO` to cancel the operation.
|
||||
* @param keycode
|
||||
*/
|
||||
void VIM_LEADER(uint16_t keycode) {
|
||||
VIM_QUEUE = keycode;
|
||||
switch(keycode) {
|
||||
case VIM_C: print("\e[32mc\e[0m"); break;
|
||||
case VIM_CI: print("\e[32mi\e[0m"); break;
|
||||
case VIM_D: print("\e[32md\e[0m"); break;
|
||||
case VIM_DI: print("\e[32mi\e[0m"); break;
|
||||
case VIM_V: print("\e[32mv\e[0m"); break;
|
||||
case VIM_VI: print("\e[32mi\e[0m"); break;
|
||||
case KC_NO: print("❎"); break;
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* ####### # # ####### ##### # # ####### #######
|
||||
* # # ## # # # # # # # # #
|
||||
* # # # # # # # # # # # #
|
||||
* # # # # # ##### ##### ####### # # #
|
||||
* # # # # # # # # # # # #
|
||||
* # # # ## # # # # # # # #
|
||||
* ####### # # ####### ##### # # ####### #
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Vim-like `append` command.
|
||||
* Works by sending →.
|
||||
*/
|
||||
void VIM_APPEND(void) {
|
||||
print("\e[31ma\e[0m");
|
||||
TAP(KC_RIGHT);
|
||||
layer_on(INSERT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `back` command
|
||||
* Simulates vim's `b` command by sending ⌥←
|
||||
*/
|
||||
void VIM_BACK(void) {
|
||||
print("\e[31mb\e[0m");
|
||||
ALT(KC_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `cut` command
|
||||
* Simulates vim's `x` command by sending ⇧→ then ⌘X.
|
||||
*/
|
||||
void VIM_CUT(void) {
|
||||
print("\e[31mx\e[0m");
|
||||
SHIFT(KC_RIGHT);
|
||||
CMD(KC_X);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `down` command
|
||||
* Sends ↓
|
||||
*/
|
||||
void VIM_DOWN(void) {
|
||||
print("\e[31mj\e[0m");
|
||||
TAP(KC_DOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `end` command
|
||||
* Simulates vim's `e` command by sending ⌥→
|
||||
*/
|
||||
void VIM_END(void) {
|
||||
print("\e[31me\e[0m");
|
||||
ALT(KC_RIGHT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `left` command
|
||||
* Sends ←
|
||||
*/
|
||||
void VIM_LEFT(void) {
|
||||
print("\e[31mh\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
TAP(KC_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `open` command.
|
||||
* Works by sending ⌘→ to move to the end of the line, `enter` to open a new line,
|
||||
* then switching to insert mode.
|
||||
*/
|
||||
void VIM_OPEN(void) {
|
||||
print("\e[31mo\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
CMD(KC_RIGHT);
|
||||
TAP(KC_ENTER);
|
||||
layer_on(INSERT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `put` command
|
||||
* Simulates vim's `p` command by sending ⌘V
|
||||
*/
|
||||
void VIM_PUT(void) {
|
||||
print("\e[31mp\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
CMD(KC_V);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `put before` command
|
||||
* Simulates vim's `P` command by sending ↑, ⌘←, then ⌘V
|
||||
*/
|
||||
void VIM_PUT_BEFORE(void) {
|
||||
print("\e[31mP\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
TAP(KC_UP);
|
||||
CMD(KC_LEFT);
|
||||
CMD(KC_V);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `right` command
|
||||
* Sends →
|
||||
*/
|
||||
void VIM_RIGHT(void) {
|
||||
print("\e[31ml\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
TAP(KC_RIGHT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `substitute` command
|
||||
* Simulates vim's `s` command by sending ⇧→ to select the next character, then
|
||||
* ⌘X to cut it, then entering insert mode.
|
||||
*/
|
||||
void VIM_SUBSTITUTE(void) {
|
||||
print("\e[31ms\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
SHIFT(KC_RIGHT);
|
||||
CMD(KC_X);
|
||||
layer_on(INSERT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `undo` command
|
||||
* Simulates vim's `u` command by sending ⌘Z
|
||||
*/
|
||||
void VIM_UNDO(void) {
|
||||
print("\e[31mu\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
CMD(KC_Z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `up` command
|
||||
* Sends ↑
|
||||
*/
|
||||
void VIM_UP(void) {
|
||||
print("\e[31mk\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
TAP(KC_UP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `word` command
|
||||
* Simulates vim's `w` command by moving the cursor first to the
|
||||
* end of the current word, then to the end of the next word,
|
||||
* then to the beginning of that word.
|
||||
*/
|
||||
void VIM_WORD(void) {
|
||||
print("\e[31mw\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
PRESS(KC_LALT);
|
||||
TAP(KC_RIGHT);
|
||||
TAP(KC_RIGHT);
|
||||
TAP(KC_LEFT);
|
||||
RELEASE(KC_LALT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `yank` command
|
||||
* Simulates vim's `y` command by sending ⌘C
|
||||
*/
|
||||
void VIM_YANK(void) {
|
||||
print("\e[31my\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
CMD(KC_C);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `yank line` command
|
||||
* Simulates vim's `y` command by sending ⌘← then ⇧⌘→ then ⌘C
|
||||
*/
|
||||
void VIM_YANK_LINE(void) {
|
||||
print("\e[31mY\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
CMD(KC_LEFT);
|
||||
PRESS(KC_LSHIFT);
|
||||
CMD(KC_RIGHT);
|
||||
RELEASE(KC_LSHIFT);
|
||||
CMD(KC_C);
|
||||
}
|
||||
|
||||
/***
|
||||
* ##### # # ### ####### ####### ####### ######
|
||||
* # # # # # # # # # #
|
||||
* # # # # # # # # #
|
||||
* ##### ####### # ##### # ##### # #
|
||||
* # # # # # # # # #
|
||||
* # # # # # # # # # #
|
||||
* ##### # # ### # # ####### ######
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Vim-like `append to line` command
|
||||
* Simulates vim's `A` command by sending ⌘→ then switching to insert mode.
|
||||
*/
|
||||
void VIM_APPEND_LINE(void) {
|
||||
print("\e[31mA\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
CMD(KC_RIGHT);
|
||||
layer_on(INSERT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `change line` command
|
||||
* Simulates vim's `C` command by sending ⌃K then switching to insert mode.
|
||||
*/
|
||||
void VIM_CHANGE_LINE(void) {
|
||||
print("\e[31mC\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
VIM_DELETE_LINE();
|
||||
layer_on(INSERT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like 'delete line' command
|
||||
* Simulates vim's `D` command by sending ⌃K to kill the line
|
||||
*/
|
||||
void VIM_DELETE_LINE(void) {
|
||||
print("\e[31mD\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
CTRL(KC_K);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like 'join lines' command
|
||||
* Simulates vim's `J` command by sending ⌘→ to go to the end of the line, then
|
||||
* DELETE to join the lines
|
||||
*/
|
||||
void VIM_JOIN(void) {
|
||||
print("\e[31mJ\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
CMD(KC_RIGHT);
|
||||
TAP(KC_DELETE);
|
||||
VIM_LEADER(KC_NO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like 'open above' command
|
||||
* Simulates vim's `O` command by sending ⌘→ to go to the start of the line,
|
||||
* enter to move the line down, ↑ to move up to the new line, then switching to
|
||||
* insert mode.
|
||||
*/
|
||||
void VIM_OPEN_ABOVE(void) {
|
||||
print("\e[31mO\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
CMD(KC_LEFT);
|
||||
TAP(KC_ENTER);
|
||||
TAP(KC_UP);
|
||||
layer_on(INSERT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like 'change whole line' command
|
||||
* Simulates vim's `S` `cc` or `c$` commands by sending ⌘← to go to the start of the line,
|
||||
* ⌃K to kill the line, then switching to insert mode.
|
||||
*/
|
||||
void VIM_CHANGE_WHOLE_LINE(void) {
|
||||
print("\e[31mS\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
CMD(KC_LEFT);
|
||||
VIM_CHANGE_LINE();
|
||||
}
|
||||
|
||||
/***
|
||||
* ###### ###### ###### ####### ####### ### # # ####### ######
|
||||
* # # # # # # # # # # # # # #
|
||||
* # # # # # # # # # # # # # #
|
||||
* # # ###### ###### ##### ##### # # ##### # #
|
||||
* # # # # # # # # # # # # #
|
||||
* # # # # # # # # # # # # #
|
||||
* ###### # # # ####### # ### # # ####### ######
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Vim-like `delete to end` command
|
||||
* Simulates vim's `de` command by sending ⌥⇧→ then ⌘X.
|
||||
*/
|
||||
void VIM_DELETE_END(void) {
|
||||
print("\e[31me\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
PRESS(KC_LALT);
|
||||
SHIFT(KC_RIGHT); // select to end of this word
|
||||
RELEASE(KC_LALT);
|
||||
CMD(KC_X);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `delete whole line` command
|
||||
* Simulates vim's `dd` command by sending ⌘← to move to start of line,
|
||||
* selecting the whole line, then sending ⌘X to cut the line.
|
||||
* alternate method: ⌘⌫, ⌃K
|
||||
*/
|
||||
void VIM_DELETE_WHOLE_LINE(void) {
|
||||
print("\e[31md\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
CMD(KC_LEFT);
|
||||
PRESS(KC_LSHIFT);
|
||||
CMD(KC_RIGHT);
|
||||
RELEASE(KC_LSHIFT);
|
||||
CMD(KC_X);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `delete word` command
|
||||
* Simulates vim's `dw` command by sending ⌥⇧→→← then ⌘X to select to the start
|
||||
* of the next word then cut.
|
||||
*/
|
||||
void VIM_DELETE_WORD(void) {
|
||||
print("\e[31mw\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
PRESS(KC_LALT);
|
||||
SHIFT(KC_RIGHT); // select to end of this word
|
||||
SHIFT(KC_RIGHT); // select to end of next word
|
||||
SHIFT(KC_LEFT); // select to start of next word
|
||||
RELEASE(KC_LALT);
|
||||
CMD(KC_X); // delete selection
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `delete back` command
|
||||
* Simulates vim's `db` command by selecting to the end of the word then deleting.
|
||||
*/
|
||||
void VIM_DELETE_BACK(void) {
|
||||
print("\e[31mb\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
PRESS(KC_LALT);
|
||||
SHIFT(KC_LEFT); // select to start of word
|
||||
SHIFT(KC_DEL); // delete selection
|
||||
RELEASE(KC_LSHIFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `delete left` command
|
||||
* Simulates vim's `dh` command by sending ⇧← then ⌘X.
|
||||
*/
|
||||
void VIM_DELETE_LEFT(void) {
|
||||
print("\e[31mh\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
SHIFT(KC_LEFT);
|
||||
CMD(KC_X);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `delete right` command
|
||||
* Simulates vim's `dl` command by sending ⇧→ then ⌘X.
|
||||
*/
|
||||
void VIM_DELETE_RIGHT(void) {
|
||||
print("\e[31ml\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
SHIFT(KC_RIGHT);
|
||||
CMD(KC_X);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `delete up` command
|
||||
* Simulates vim's `dk` command by sending ↑ then deleting the line.
|
||||
*/
|
||||
void VIM_DELETE_UP(void) {
|
||||
print("\e[31mk\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
TAP(KC_UP);
|
||||
VIM_DELETE_LINE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `delete down` command
|
||||
* Simulates vim's `dj` command by sending ↓ then deleting the line.
|
||||
*/
|
||||
void VIM_DELETE_DOWN(void) {
|
||||
print("\e[31mj\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
TAP(KC_DOWN);
|
||||
VIM_DELETE_LINE();
|
||||
}
|
||||
|
||||
/***
|
||||
* ###### ### ###### ###### ####### ####### ### # # ####### ######
|
||||
* # # # # # # # # # # # # # # #
|
||||
* # # # # # # # # # # # # # # #
|
||||
* # # # ###### ###### ##### ##### # # ##### # #
|
||||
* # # # # # # # # # # # # # #
|
||||
* # # # # # # # # # # # # # #
|
||||
* ###### ### # # # ####### # ### # # ####### ######
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Vim-like `delete inner word` command
|
||||
* Simulates vim's `diw` command by moving back then cutting to the end of the word.
|
||||
*/
|
||||
void VIM_DELETE_INNER_WORD(void) {
|
||||
print("\e[31mw\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
VIM_BACK();
|
||||
VIM_DELETE_END();
|
||||
}
|
||||
|
||||
/***
|
||||
* ##### ###### ###### ####### ####### ### # # ####### ######
|
||||
* # # # # # # # # # # # # # #
|
||||
* # # # # # # # # # # # # #
|
||||
* # ###### ###### ##### ##### # # ##### # #
|
||||
* # # # # # # # # # # # #
|
||||
* # # # # # # # # # # # # #
|
||||
* ##### # # # ####### # ### # # ####### ######
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Vim-like `change back` command
|
||||
* Simulates vim's `cb` command by first deleting to the start of the word,
|
||||
* then switching to insert mode.
|
||||
*/
|
||||
void VIM_CHANGE_BACK(void) {
|
||||
print("\e[31mb\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
VIM_DELETE_BACK();
|
||||
layer_on(INSERT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `change down` command
|
||||
* Simulates vim's `cj` command by sending ↓ then changing the line.
|
||||
*/
|
||||
void VIM_CHANGE_DOWN(void) {
|
||||
print("\e[31mj\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
VIM_DELETE_DOWN();
|
||||
layer_on(INSERT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `change to end` command
|
||||
* Simulates vim's `ce` command by first deleting to the end of the word,
|
||||
* then switching to insert mode.
|
||||
*/
|
||||
void VIM_CHANGE_END(void) {
|
||||
print("\e[31mce\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
VIM_DELETE_END();
|
||||
layer_on(INSERT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `change left` command
|
||||
* Simulates vim's `ch` command by deleting left then switching to insert mode.
|
||||
*/
|
||||
void VIM_CHANGE_LEFT(void) {
|
||||
print("\e[31mch\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
VIM_DELETE_LEFT();
|
||||
layer_on(INSERT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `change right` command
|
||||
* Simulates vim's `cl` command by deleting right then switching to insert mode.
|
||||
*/
|
||||
void VIM_CHANGE_RIGHT(void) {
|
||||
print("\e[31mcl\e[0m");
|
||||
VIM_DELETE_RIGHT();
|
||||
layer_on(INSERT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `change up` command
|
||||
* Simulates vim's `ck` command by deleting up then switching to insert mode.
|
||||
*/
|
||||
void VIM_CHANGE_UP(void) {
|
||||
print("\e[31mck\e[0m");
|
||||
VIM_DELETE_UP();
|
||||
layer_on(INSERT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `change word` command
|
||||
* Simulates vim's `cw` command by first deleting to the end of the word,
|
||||
* then switching to insert mode.
|
||||
*/
|
||||
void VIM_CHANGE_WORD(void) {
|
||||
print("\e[31mcw\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
VIM_DELETE_WORD();
|
||||
layer_on(INSERT_MODE);
|
||||
}
|
||||
|
||||
/***
|
||||
* ##### ### ###### ###### ####### ####### ### # # ####### ######
|
||||
* # # # # # # # # # # # # # # #
|
||||
* # # # # # # # # # # # # # #
|
||||
* # # ###### ###### ##### ##### # # ##### # #
|
||||
* # # # # # # # # # # # # #
|
||||
* # # # # # # # # # # # # # #
|
||||
* ##### ### # # # ####### # ### # # ####### ######
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Vim-like `change inner word` command
|
||||
* Simulates vim's `ciw` command by deleting the inner word then switching to insert mode.
|
||||
*/
|
||||
void VIM_CHANGE_INNER_WORD(void) {
|
||||
print("\e[31mciw\e[0m");
|
||||
VIM_DELETE_INNER_WORD();
|
||||
layer_on(INSERT_MODE);
|
||||
}
|
||||
|
||||
/***
|
||||
* # # ###### ###### ####### ####### ### # # ####### ######
|
||||
* # # # # # # # # # # # # # #
|
||||
* # # # # # # # # # # # # # #
|
||||
* # # ###### ###### ##### ##### # # ##### # #
|
||||
* # # # # # # # # # # # # #
|
||||
* # # # # # # # # # # # # #
|
||||
* # # # # ####### # ### # # ####### ######
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Vim-like `visual select back` command
|
||||
* Simulates vim's `vb` command by selecting to the enc of the word.
|
||||
*/
|
||||
void VIM_VISUAL_BACK(void) {
|
||||
print("\e[31mvb\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
PRESS(KC_LALT);
|
||||
SHIFT(KC_LEFT); // select to start of word
|
||||
RELEASE(KC_LALT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `visual select to end` command
|
||||
* Simulates vim's `ve` command by selecting to the end of the word.
|
||||
*/
|
||||
void VIM_VISUAL_END(void) {
|
||||
print("\e[31mve\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
PRESS(KC_LALT);
|
||||
SHIFT(KC_RIGHT); // select to end of this word
|
||||
RELEASE(KC_LALT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `visual select word` command
|
||||
* Simulates vim's `vw` command by selecting to the end of the word.
|
||||
*/
|
||||
void VIM_VISUAL_WORD(void) {
|
||||
print("\e[31mvw\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
PRESS(KC_LALT);
|
||||
SHIFT(KC_RIGHT); // select to end of this word
|
||||
SHIFT(KC_RIGHT); // select to end of next word
|
||||
SHIFT(KC_LEFT); // select to start of next word
|
||||
RELEASE(KC_LALT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `visual left` command
|
||||
* Simulates vim's `vh` command by sending ⇧←.
|
||||
*/
|
||||
void VIM_VISUAL_LEFT(void) {
|
||||
print("\e[31mvh\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
SHIFT(KC_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `visual right` command
|
||||
* Simulates vim's `vl` command by sending ⇧→.
|
||||
*/
|
||||
void VIM_VISUAL_RIGHT(void) {
|
||||
print("\e[31mvl\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
SHIFT(KC_RIGHT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `visual up` command
|
||||
* Simulates vim's `vk` command by sending ⇧↑.
|
||||
*/
|
||||
void VIM_VISUAL_UP(void) {
|
||||
print("\e[31mvk\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
SHIFT(KC_UP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vim-like `visual down` command
|
||||
* Simulates vim's `vj` command by sending ⇧↓.
|
||||
*/
|
||||
void VIM_VISUAL_DOWN(void) {
|
||||
print("\e[31mdj\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
SHIFT(KC_DOWN);
|
||||
}
|
||||
|
||||
/***
|
||||
* # # ### ###### ###### ####### ####### ### # # ####### ######
|
||||
* # # # # # # # # # # # # # # #
|
||||
* # # # # # # # # # # # # # # #
|
||||
* # # # ###### ###### ##### ##### # # ##### # #
|
||||
* # # # # # # # # # # # # # #
|
||||
* # # # # # # # # # # # # # #
|
||||
* # ### # # # ####### # ### # # ####### ######
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Vim-like `visual inner word` command
|
||||
* Simulates vim's `viw` command by moving back then selecting to the end of the word.
|
||||
*/
|
||||
void VIM_VISUAL_INNER_WORD(void) {
|
||||
print("\e[31mviw\e[0m");
|
||||
VIM_LEADER(KC_NO);
|
||||
VIM_BACK();
|
||||
VIM_VISUAL_END();
|
||||
}
|
Loading…
Reference in a new issue