diff --git a/.gitmodules b/.gitmodules
index 7cd8281fa1a3..c58c43a9b927 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -25,3 +25,6 @@
path = lib/lvgl
url = https://github.com/qmk/lvgl.git
branch = release/v8.2
+[submodule "users/rootiest/qmk-vim"]
+ path = users/rootiest/qmk-vim
+ url = https://github.com/andrewjrae/qmk-vim.git
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/autocorrect_data.h b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/autocorrect_data.h
index d69fe241a8d3..bbc61dc22d04 100644
--- a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/autocorrect_data.h
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/autocorrect_data.h
@@ -25,7 +25,7 @@
#pragma once
-// Autocorrection dictionary (91 entries):
+// Autocorrection dictionary (97 entries):
// :guage -> gauge
// :the:the: -> the
// :thier -> their
@@ -117,15 +117,21 @@
// doesnt -> doesn't
// oposite -> opposite
// oportunity -> opportunity
+// retreive -> retrieve
+// vegitarien -> vegetarian
+// vegatarian -> vegetarian
+// vegeterian -> vegetarian
+// vegatarien -> vegetarian
+// vegeterien -> vegetarian
#define AUTOCORRECT_MIN_LENGTH 4 // "youd"
#define AUTOCORRECT_MAX_LENGTH 10 // "accomodate"
-#define DICTIONARY_SIZE 1405
+#define DICTIONARY_SIZE 1527
static const uint8_t autocorrect_data[DICTIONARY_SIZE] PROGMEM = {
- 0x6C, 0x2E, 0x00, 0x06, 0x4A, 0x00, 0x07, 0x54, 0x00, 0x08, 0xF3, 0x00, 0x09, 0x62, 0x02, 0x0A,
- 0x6C, 0x02, 0x0B, 0x8C, 0x02, 0x0F, 0xA7, 0x02, 0x11, 0xF5, 0x02, 0x12, 0x7E, 0x03, 0x13, 0x8A,
- 0x03, 0x15, 0x94, 0x03, 0x16, 0xE2, 0x03, 0x17, 0x11, 0x04, 0x1C, 0x26, 0x05, 0x00, 0x48, 0x35,
+ 0x6C, 0x2E, 0x00, 0x06, 0x4A, 0x00, 0x07, 0x54, 0x00, 0x08, 0xF3, 0x00, 0x09, 0x74, 0x02, 0x0A,
+ 0x7E, 0x02, 0x0B, 0x9E, 0x02, 0x0F, 0xB9, 0x02, 0x11, 0x07, 0x03, 0x12, 0xF8, 0x03, 0x13, 0x04,
+ 0x04, 0x15, 0x0E, 0x04, 0x16, 0x5C, 0x04, 0x17, 0x8B, 0x04, 0x1C, 0xA0, 0x05, 0x00, 0x48, 0x35,
0x00, 0x16, 0x3F, 0x00, 0x00, 0x0B, 0x17, 0x2C, 0x08, 0x0B, 0x17, 0x2C, 0x00, 0x84, 0x00, 0x08,
0x16, 0x12, 0x12, 0x0F, 0x00, 0x84, 0x73, 0x65, 0x73, 0x00, 0x0B, 0x17, 0x0C, 0x1A, 0x16, 0x00,
0x81, 0x63, 0x68, 0x00, 0x44, 0x64, 0x00, 0x08, 0x70, 0x00, 0x0F, 0xC3, 0x00, 0x15, 0xE0, 0x00,
@@ -160,55 +166,63 @@ static const uint8_t autocorrect_data[DICTIONARY_SIZE] PROGMEM = {
0x6F, 0x64, 0x61, 0x74, 0x65, 0x00, 0x07, 0x18, 0x00, 0x84, 0x70, 0x64, 0x61, 0x74, 0x65, 0x00,
0x08, 0x13, 0x08, 0x16, 0x00, 0x84, 0x61, 0x72, 0x61, 0x74, 0x65, 0x00, 0x16, 0x12, 0x13, 0x12,
0x00, 0x84, 0x70, 0x6F, 0x73, 0x69, 0x74, 0x65, 0x00, 0x0A, 0x08, 0x0F, 0x0F, 0x12, 0x06, 0x00,
- 0x82, 0x61, 0x67, 0x75, 0x65, 0x00, 0x08, 0x0C, 0x06, 0x08, 0x15, 0x00, 0x83, 0x65, 0x69, 0x76,
- 0x65, 0x00, 0x0C, 0x08, 0x0B, 0x06, 0x00, 0x82, 0x69, 0x65, 0x66, 0x00, 0x11, 0x00, 0x4C, 0x75,
- 0x02, 0x15, 0x82, 0x02, 0x00, 0x0F, 0x08, 0x0C, 0x06, 0x00, 0x85, 0x65, 0x69, 0x6C, 0x69, 0x6E,
- 0x67, 0x00, 0x0C, 0x17, 0x16, 0x00, 0x83, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x46, 0x93, 0x02, 0x17,
- 0x9E, 0x02, 0x00, 0x0C, 0x17, 0x1A, 0x16, 0x00, 0x83, 0x69, 0x74, 0x63, 0x68, 0x00, 0x0A, 0x0C,
- 0x08, 0x0B, 0x00, 0x81, 0x68, 0x74, 0x00, 0x48, 0xB4, 0x02, 0x0C, 0xBD, 0x02, 0x0F, 0xCD, 0x02,
- 0x18, 0xE5, 0x02, 0x00, 0x1D, 0x1D, 0x12, 0x11, 0x00, 0x81, 0x6C, 0x65, 0x00, 0x09, 0x18, 0x17,
- 0x0C, 0x08, 0x05, 0x00, 0x85, 0x61, 0x75, 0x74, 0x69, 0x66, 0x75, 0x6C, 0x00, 0x58, 0xD4, 0x02,
- 0x1C, 0xDC, 0x02, 0x00, 0x12, 0x1C, 0x00, 0x81, 0x27, 0x6C, 0x6C, 0x00, 0x08, 0x0B, 0x17, 0x00,
- 0x81, 0x27, 0x6C, 0x6C, 0x00, 0x09, 0x0C, 0x17, 0x18, 0x08, 0x05, 0x00, 0x85, 0x61, 0x75, 0x74,
- 0x69, 0x66, 0x75, 0x6C, 0x00, 0x48, 0x05, 0x03, 0x0A, 0x10, 0x03, 0x12, 0x19, 0x03, 0x15, 0x5C,
- 0x03, 0x18, 0x67, 0x03, 0x00, 0x16, 0x12, 0x12, 0x0B, 0x06, 0x00, 0x83, 0x73, 0x65, 0x6E, 0x00,
- 0x0C, 0x15, 0x17, 0x16, 0x00, 0x81, 0x6E, 0x67, 0x00, 0x0C, 0x00, 0x56, 0x22, 0x03, 0x17, 0x3C,
- 0x03, 0x00, 0x44, 0x29, 0x03, 0x16, 0x32, 0x03, 0x00, 0x0C, 0x0F, 0x00, 0x83, 0x69, 0x73, 0x6F,
- 0x6E, 0x00, 0x04, 0x06, 0x06, 0x12, 0x00, 0x83, 0x69, 0x6F, 0x6E, 0x00, 0x4C, 0x43, 0x03, 0x16,
- 0x52, 0x03, 0x00, 0x17, 0x0C, 0x13, 0x08, 0x15, 0x00, 0x86, 0x65, 0x74, 0x69, 0x74, 0x69, 0x6F,
- 0x6E, 0x00, 0x12, 0x13, 0x00, 0x83, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x17, 0x18, 0x08, 0x15,
- 0x00, 0x83, 0x74, 0x75, 0x72, 0x6E, 0x00, 0x55, 0x6E, 0x03, 0x17, 0x77, 0x03, 0x00, 0x17, 0x08,
- 0x15, 0x00, 0x82, 0x75, 0x72, 0x6E, 0x00, 0x08, 0x15, 0x00, 0x80, 0x72, 0x6E, 0x00, 0x07, 0x08,
- 0x18, 0x16, 0x13, 0x00, 0x83, 0x65, 0x75, 0x64, 0x6F, 0x00, 0x18, 0x12, 0x12, 0x0F, 0x00, 0x81,
- 0x6B, 0x75, 0x70, 0x00, 0x48, 0x9B, 0x03, 0x12, 0xD1, 0x03, 0x00, 0x47, 0xA8, 0x03, 0x0C, 0xB3,
- 0x03, 0x0F, 0xBC, 0x03, 0x11, 0xC6, 0x03, 0x00, 0x12, 0x0F, 0x16, 0x00, 0x84, 0x6F, 0x6C, 0x64,
- 0x65, 0x72, 0x00, 0x0B, 0x17, 0x2C, 0x00, 0x82, 0x65, 0x69, 0x72, 0x00, 0x17, 0x0C, 0x09, 0x00,
- 0x83, 0x6C, 0x74, 0x65, 0x72, 0x00, 0x17, 0x16, 0x0C, 0x0F, 0x00, 0x82, 0x65, 0x6E, 0x65, 0x72,
- 0x00, 0x17, 0x04, 0x15, 0x08, 0x17, 0x11, 0x0C, 0x00, 0x87, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6F,
- 0x72, 0x00, 0x48, 0xEC, 0x03, 0x11, 0xF4, 0x03, 0x18, 0x01, 0x04, 0x00, 0x0F, 0x04, 0x09, 0x00,
- 0x81, 0x73, 0x65, 0x00, 0x04, 0x0C, 0x17, 0x11, 0x12, 0x06, 0x00, 0x83, 0x61, 0x69, 0x6E, 0x73,
- 0x00, 0x16, 0x11, 0x08, 0x06, 0x11, 0x12, 0x06, 0x00, 0x85, 0x73, 0x65, 0x6E, 0x73, 0x75, 0x73,
- 0x00, 0x74, 0x27, 0x04, 0x0A, 0x34, 0x04, 0x0B, 0x3E, 0x04, 0x0F, 0x54, 0x04, 0x11, 0x5F, 0x04,
- 0x16, 0xF0, 0x04, 0x18, 0xFE, 0x04, 0x00, 0x11, 0x08, 0x16, 0x12, 0x07, 0x00, 0x84, 0x65, 0x73,
- 0x6E, 0x27, 0x74, 0x00, 0x0B, 0x18, 0x04, 0x06, 0x00, 0x82, 0x67, 0x68, 0x74, 0x00, 0x47, 0x45,
- 0x04, 0x0A, 0x4C, 0x04, 0x00, 0x0C, 0x1A, 0x00, 0x81, 0x74, 0x68, 0x00, 0x11, 0x08, 0x0F, 0x00,
- 0x81, 0x74, 0x68, 0x00, 0x16, 0x18, 0x08, 0x15, 0x00, 0x83, 0x73, 0x75, 0x6C, 0x74, 0x00, 0x44,
- 0x6C, 0x04, 0x07, 0x77, 0x04, 0x08, 0x9F, 0x04, 0x16, 0xDB, 0x04, 0x00, 0x15, 0x04, 0x13, 0x13,
- 0x04, 0x00, 0x82, 0x65, 0x6E, 0x74, 0x00, 0x4C, 0x7E, 0x04, 0x0F, 0x84, 0x04, 0x00, 0x07, 0x00,
- 0x80, 0x27, 0x74, 0x00, 0x18, 0x12, 0x00, 0x46, 0x91, 0x04, 0x0B, 0x95, 0x04, 0x1A, 0x9B, 0x04,
- 0x00, 0x80, 0x27, 0x74, 0x00, 0x16, 0x00, 0x80, 0x27, 0x74, 0x00, 0x80, 0x27, 0x74, 0x00, 0x55,
- 0xA6, 0x04, 0x19, 0xD1, 0x04, 0x00, 0x44, 0xAD, 0x04, 0x15, 0xB8, 0x04, 0x00, 0x13, 0x04, 0x00,
- 0x84, 0x70, 0x61, 0x72, 0x65, 0x6E, 0x74, 0x00, 0x04, 0x13, 0x00, 0x44, 0xC2, 0x04, 0x13, 0xCA,
- 0x04, 0x00, 0x85, 0x70, 0x61, 0x72, 0x65, 0x6E, 0x74, 0x00, 0x04, 0x00, 0x83, 0x65, 0x6E, 0x74,
- 0x00, 0x08, 0x0F, 0x08, 0x15, 0x00, 0x82, 0x61, 0x6E, 0x74, 0x00, 0x48, 0xE2, 0x04, 0x12, 0xE9,
- 0x04, 0x00, 0x12, 0x07, 0x00, 0x80, 0x27, 0x74, 0x00, 0x06, 0x00, 0x82, 0x6E, 0x73, 0x74, 0x00,
- 0x0C, 0x09, 0x08, 0x11, 0x04, 0x10, 0x00, 0x84, 0x69, 0x66, 0x65, 0x73, 0x74, 0x00, 0x53, 0x05,
- 0x05, 0x17, 0x1C, 0x05, 0x00, 0x57, 0x0C, 0x05, 0x18, 0x14, 0x05, 0x00, 0x11, 0x0C, 0x00, 0x83,
- 0x70, 0x75, 0x74, 0x00, 0x12, 0x00, 0x82, 0x74, 0x70, 0x75, 0x74, 0x00, 0x13, 0x18, 0x12, 0x00,
- 0x83, 0x74, 0x70, 0x75, 0x74, 0x00, 0x46, 0x36, 0x05, 0x08, 0x42, 0x05, 0x0B, 0x4C, 0x05, 0x15,
- 0x5E, 0x05, 0x17, 0x69, 0x05, 0x00, 0x08, 0x18, 0x14, 0x08, 0x15, 0x09, 0x00, 0x81, 0x6E, 0x63,
- 0x79, 0x00, 0x17, 0x09, 0x04, 0x16, 0x00, 0x82, 0x65, 0x74, 0x79, 0x00, 0x06, 0x15, 0x04, 0x15,
- 0x0C, 0x08, 0x0B, 0x00, 0x87, 0x69, 0x65, 0x72, 0x61, 0x72, 0x63, 0x68, 0x79, 0x00, 0x04, 0x05,
- 0x0C, 0x0F, 0x00, 0x82, 0x72, 0x61, 0x72, 0x79, 0x00, 0x0C, 0x11, 0x18, 0x17, 0x15, 0x12, 0x13,
- 0x12, 0x00, 0x87, 0x70, 0x6F, 0x72, 0x74, 0x75, 0x6E, 0x69, 0x74, 0x79, 0x00
+ 0x82, 0x61, 0x67, 0x75, 0x65, 0x00, 0x48, 0x5D, 0x02, 0x0C, 0x68, 0x02, 0x00, 0x0C, 0x06, 0x08,
+ 0x15, 0x00, 0x83, 0x65, 0x69, 0x76, 0x65, 0x00, 0x08, 0x15, 0x17, 0x08, 0x15, 0x00, 0x83, 0x69,
+ 0x65, 0x76, 0x65, 0x00, 0x0C, 0x08, 0x0B, 0x06, 0x00, 0x82, 0x69, 0x65, 0x66, 0x00, 0x11, 0x00,
+ 0x4C, 0x87, 0x02, 0x15, 0x94, 0x02, 0x00, 0x0F, 0x08, 0x0C, 0x06, 0x00, 0x85, 0x65, 0x69, 0x6C,
+ 0x69, 0x6E, 0x67, 0x00, 0x0C, 0x17, 0x16, 0x00, 0x83, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x46, 0xA5,
+ 0x02, 0x17, 0xB0, 0x02, 0x00, 0x0C, 0x17, 0x1A, 0x16, 0x00, 0x83, 0x69, 0x74, 0x63, 0x68, 0x00,
+ 0x0A, 0x0C, 0x08, 0x0B, 0x00, 0x81, 0x68, 0x74, 0x00, 0x48, 0xC6, 0x02, 0x0C, 0xCF, 0x02, 0x0F,
+ 0xDF, 0x02, 0x18, 0xF7, 0x02, 0x00, 0x1D, 0x1D, 0x12, 0x11, 0x00, 0x81, 0x6C, 0x65, 0x00, 0x09,
+ 0x18, 0x17, 0x0C, 0x08, 0x05, 0x00, 0x85, 0x61, 0x75, 0x74, 0x69, 0x66, 0x75, 0x6C, 0x00, 0x58,
+ 0xE6, 0x02, 0x1C, 0xEE, 0x02, 0x00, 0x12, 0x1C, 0x00, 0x81, 0x27, 0x6C, 0x6C, 0x00, 0x08, 0x0B,
+ 0x17, 0x00, 0x81, 0x27, 0x6C, 0x6C, 0x00, 0x09, 0x0C, 0x17, 0x18, 0x08, 0x05, 0x00, 0x85, 0x61,
+ 0x75, 0x74, 0x69, 0x66, 0x75, 0x6C, 0x00, 0x44, 0x1A, 0x03, 0x08, 0x40, 0x03, 0x0A, 0x8A, 0x03,
+ 0x12, 0x93, 0x03, 0x15, 0xD6, 0x03, 0x18, 0xE1, 0x03, 0x00, 0x0C, 0x15, 0x00, 0x44, 0x24, 0x03,
+ 0x08, 0x33, 0x03, 0x00, 0x17, 0x04, 0x0A, 0x08, 0x19, 0x00, 0x86, 0x65, 0x74, 0x61, 0x72, 0x69,
+ 0x61, 0x6E, 0x00, 0x17, 0x08, 0x0A, 0x08, 0x19, 0x00, 0x84, 0x61, 0x72, 0x69, 0x61, 0x6E, 0x00,
+ 0x4C, 0x47, 0x03, 0x16, 0x80, 0x03, 0x00, 0x15, 0x00, 0x44, 0x50, 0x03, 0x08, 0x73, 0x03, 0x00,
+ 0x17, 0x00, 0x44, 0x59, 0x03, 0x0C, 0x66, 0x03, 0x00, 0x0A, 0x08, 0x19, 0x00, 0x86, 0x65, 0x74,
+ 0x61, 0x72, 0x69, 0x61, 0x6E, 0x00, 0x0A, 0x08, 0x19, 0x00, 0x86, 0x65, 0x74, 0x61, 0x72, 0x69,
+ 0x61, 0x6E, 0x00, 0x17, 0x08, 0x0A, 0x08, 0x19, 0x00, 0x84, 0x61, 0x72, 0x69, 0x61, 0x6E, 0x00,
+ 0x12, 0x12, 0x0B, 0x06, 0x00, 0x83, 0x73, 0x65, 0x6E, 0x00, 0x0C, 0x15, 0x17, 0x16, 0x00, 0x81,
+ 0x6E, 0x67, 0x00, 0x0C, 0x00, 0x56, 0x9C, 0x03, 0x17, 0xB6, 0x03, 0x00, 0x44, 0xA3, 0x03, 0x16,
+ 0xAC, 0x03, 0x00, 0x0C, 0x0F, 0x00, 0x83, 0x69, 0x73, 0x6F, 0x6E, 0x00, 0x04, 0x06, 0x06, 0x12,
+ 0x00, 0x83, 0x69, 0x6F, 0x6E, 0x00, 0x4C, 0xBD, 0x03, 0x16, 0xCC, 0x03, 0x00, 0x17, 0x0C, 0x13,
+ 0x08, 0x15, 0x00, 0x86, 0x65, 0x74, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x12, 0x13, 0x00, 0x83,
+ 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x17, 0x18, 0x08, 0x15, 0x00, 0x83, 0x74, 0x75, 0x72, 0x6E,
+ 0x00, 0x55, 0xE8, 0x03, 0x17, 0xF1, 0x03, 0x00, 0x17, 0x08, 0x15, 0x00, 0x82, 0x75, 0x72, 0x6E,
+ 0x00, 0x08, 0x15, 0x00, 0x80, 0x72, 0x6E, 0x00, 0x07, 0x08, 0x18, 0x16, 0x13, 0x00, 0x83, 0x65,
+ 0x75, 0x64, 0x6F, 0x00, 0x18, 0x12, 0x12, 0x0F, 0x00, 0x81, 0x6B, 0x75, 0x70, 0x00, 0x48, 0x15,
+ 0x04, 0x12, 0x4B, 0x04, 0x00, 0x47, 0x22, 0x04, 0x0C, 0x2D, 0x04, 0x0F, 0x36, 0x04, 0x11, 0x40,
+ 0x04, 0x00, 0x12, 0x0F, 0x16, 0x00, 0x84, 0x6F, 0x6C, 0x64, 0x65, 0x72, 0x00, 0x0B, 0x17, 0x2C,
+ 0x00, 0x82, 0x65, 0x69, 0x72, 0x00, 0x17, 0x0C, 0x09, 0x00, 0x83, 0x6C, 0x74, 0x65, 0x72, 0x00,
+ 0x17, 0x16, 0x0C, 0x0F, 0x00, 0x82, 0x65, 0x6E, 0x65, 0x72, 0x00, 0x17, 0x04, 0x15, 0x08, 0x17,
+ 0x11, 0x0C, 0x00, 0x87, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6F, 0x72, 0x00, 0x48, 0x66, 0x04, 0x11,
+ 0x6E, 0x04, 0x18, 0x7B, 0x04, 0x00, 0x0F, 0x04, 0x09, 0x00, 0x81, 0x73, 0x65, 0x00, 0x04, 0x0C,
+ 0x17, 0x11, 0x12, 0x06, 0x00, 0x83, 0x61, 0x69, 0x6E, 0x73, 0x00, 0x16, 0x11, 0x08, 0x06, 0x11,
+ 0x12, 0x06, 0x00, 0x85, 0x73, 0x65, 0x6E, 0x73, 0x75, 0x73, 0x00, 0x74, 0xA1, 0x04, 0x0A, 0xAE,
+ 0x04, 0x0B, 0xB8, 0x04, 0x0F, 0xCE, 0x04, 0x11, 0xD9, 0x04, 0x16, 0x6A, 0x05, 0x18, 0x78, 0x05,
+ 0x00, 0x11, 0x08, 0x16, 0x12, 0x07, 0x00, 0x84, 0x65, 0x73, 0x6E, 0x27, 0x74, 0x00, 0x0B, 0x18,
+ 0x04, 0x06, 0x00, 0x82, 0x67, 0x68, 0x74, 0x00, 0x47, 0xBF, 0x04, 0x0A, 0xC6, 0x04, 0x00, 0x0C,
+ 0x1A, 0x00, 0x81, 0x74, 0x68, 0x00, 0x11, 0x08, 0x0F, 0x00, 0x81, 0x74, 0x68, 0x00, 0x16, 0x18,
+ 0x08, 0x15, 0x00, 0x83, 0x73, 0x75, 0x6C, 0x74, 0x00, 0x44, 0xE6, 0x04, 0x07, 0xF1, 0x04, 0x08,
+ 0x19, 0x05, 0x16, 0x55, 0x05, 0x00, 0x15, 0x04, 0x13, 0x13, 0x04, 0x00, 0x82, 0x65, 0x6E, 0x74,
+ 0x00, 0x4C, 0xF8, 0x04, 0x0F, 0xFE, 0x04, 0x00, 0x07, 0x00, 0x80, 0x27, 0x74, 0x00, 0x18, 0x12,
+ 0x00, 0x46, 0x0B, 0x05, 0x0B, 0x0F, 0x05, 0x1A, 0x15, 0x05, 0x00, 0x80, 0x27, 0x74, 0x00, 0x16,
+ 0x00, 0x80, 0x27, 0x74, 0x00, 0x80, 0x27, 0x74, 0x00, 0x55, 0x20, 0x05, 0x19, 0x4B, 0x05, 0x00,
+ 0x44, 0x27, 0x05, 0x15, 0x32, 0x05, 0x00, 0x13, 0x04, 0x00, 0x84, 0x70, 0x61, 0x72, 0x65, 0x6E,
+ 0x74, 0x00, 0x04, 0x13, 0x00, 0x44, 0x3C, 0x05, 0x13, 0x44, 0x05, 0x00, 0x85, 0x70, 0x61, 0x72,
+ 0x65, 0x6E, 0x74, 0x00, 0x04, 0x00, 0x83, 0x65, 0x6E, 0x74, 0x00, 0x08, 0x0F, 0x08, 0x15, 0x00,
+ 0x82, 0x61, 0x6E, 0x74, 0x00, 0x48, 0x5C, 0x05, 0x12, 0x63, 0x05, 0x00, 0x12, 0x07, 0x00, 0x80,
+ 0x27, 0x74, 0x00, 0x06, 0x00, 0x82, 0x6E, 0x73, 0x74, 0x00, 0x0C, 0x09, 0x08, 0x11, 0x04, 0x10,
+ 0x00, 0x84, 0x69, 0x66, 0x65, 0x73, 0x74, 0x00, 0x53, 0x7F, 0x05, 0x17, 0x96, 0x05, 0x00, 0x57,
+ 0x86, 0x05, 0x18, 0x8E, 0x05, 0x00, 0x11, 0x0C, 0x00, 0x83, 0x70, 0x75, 0x74, 0x00, 0x12, 0x00,
+ 0x82, 0x74, 0x70, 0x75, 0x74, 0x00, 0x13, 0x18, 0x12, 0x00, 0x83, 0x74, 0x70, 0x75, 0x74, 0x00,
+ 0x46, 0xB0, 0x05, 0x08, 0xBC, 0x05, 0x0B, 0xC6, 0x05, 0x15, 0xD8, 0x05, 0x17, 0xE3, 0x05, 0x00,
+ 0x08, 0x18, 0x14, 0x08, 0x15, 0x09, 0x00, 0x81, 0x6E, 0x63, 0x79, 0x00, 0x17, 0x09, 0x04, 0x16,
+ 0x00, 0x82, 0x65, 0x74, 0x79, 0x00, 0x06, 0x15, 0x04, 0x15, 0x0C, 0x08, 0x0B, 0x00, 0x87, 0x69,
+ 0x65, 0x72, 0x61, 0x72, 0x63, 0x68, 0x79, 0x00, 0x04, 0x05, 0x0C, 0x0F, 0x00, 0x82, 0x72, 0x61,
+ 0x72, 0x79, 0x00, 0x0C, 0x11, 0x18, 0x17, 0x15, 0x12, 0x13, 0x12, 0x00, 0x87, 0x70, 0x6F, 0x72,
+ 0x74, 0x75, 0x6E, 0x69, 0x74, 0x79, 0x00
};
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/autocorrect_dictionary.txt b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/autocorrect_dictionary.txt
index 72101b5ddbf5..348c947fe2b1 100644
--- a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/autocorrect_dictionary.txt
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/autocorrect_dictionary.txt
@@ -89,4 +89,10 @@ didnt -> didn't
doesnt -> doesn't
oposite -> opposite
oportunity -> opportunity
+retreive -> retrieve
+vegitarien -> vegetarian
+vegatarian -> vegetarian
+vegeterian -> vegetarian
+vegatarien -> vegetarian
+vegeterien -> vegetarian
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/config.h b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/config.h
index 8bd40ebbd3b4..e7a55f9529e3 100644
--- a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/config.h
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/config.h
@@ -206,3 +206,16 @@
// NKRO on by default
//#define FORCE_NKRO // Force NKRO
+
+// VIM Mode Features
+#define BETTER_VISUAL_MODE
+#define VIM_I_TEXT_OBJECTS
+#define VIM_A_TEXT_OBJECTS
+#define VIM_G_MOTIONS
+#define VIM_COLON_CMDS
+#define VIM_PASTE_BEFORE
+#define VIM_REPLACE
+#define VIM_DOT_REPEAT
+#define VIM_W_BEGINNING_OF_WORD
+#define VIM_NUMBERED_JUMPS
+#define VIM_FOR_ALL
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/keymap.c b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/keymap.c
index bbab06c80367..ea8bf23369c9 100644
--- a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/keymap.c
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/keymap.c
@@ -17,6 +17,7 @@
* along with rootiest. If not, see .
*/
+#include "rgb_matrix.h"
#include QMK_KEYBOARD_H // QMK Keyboard library
#include "keychron_common.h" // Keychron common definitions
#include "features/select_word.h" // Select word feature
@@ -24,7 +25,8 @@
#include "features/layer_lock.h" // Layer lock feature
#include "features/achordion.h" // Achordion feature
#include "features/sentence_case.h" // Sentence case feature
-#include "rootiest.h" // Rootiest customizations
+#include "rootiest.h" // Rootiest customizations
+#include "qmk-vim/src/vim.h" // Vim mode
/* ============================================================================================================ */
/* ============================================================================================================ */
@@ -42,16 +44,16 @@
// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[MAIN_BASE] = LAYOUT_ansi_101(
- KC_ESC, KC_BRID, KC_BRIU, KC_MCTRL, KC_MYCM, KC_F5, KC_F6, KC_MPRV, KC_MPLY, KC_MNXT, KC_F10, KC_F11, KC_F12, KC_DEL, KC_PSCR, KC_WWW_SEARCH , QK_LEAD, KC_MUTE,
- KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, TD(TD_PG_HOME), TD(TD_NUM_CLEAR), KC_PSLS, KC_PAST, KC_PMNS,
- KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, TD(TD_PG_END), KC_P7, KC_P8, KC_P9,
+ KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MPRV, KC_MPLY, KC_MNXT, KC_F10, KC_F11, KC_F12, KC_DEL, KC_PSCR, KC_WWW_SEARCH , QK_LEAD, KC_MUTE,
+ KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_PGUP, TD(TD_NUM_CLEAR), KC_PSLS, KC_PAST, KC_PMNS,
+ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGDN, KC_P7, KC_P8, KC_P9,
TD(TD_ESC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, TD(TD_HOME_END), KC_P4, KC_P5, KC_P6, KC_PPLS,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3,
SC_LCPO, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(MAIN_FN), SC_RCPC, KC_LEFT, KC_DOWN, KC_RGHT, LT(SPECIAL_FN, KC_P0), LT(PREFIX_C_K, KC_PDOT), KC_PENT),
[MAIN_FN] = LAYOUT_ansi_101(
- _______, KC_F1, KC_F2, KC_F3, KC_F4, RGB_VAD, RGB_VAI, KC_F7, KC_F8, KC_F9, KC_MUTE, KC_VOLD, KC_VOLU, A(KC_F4), _______, _______, ALT4KEY, A(KC_F4),
+ ESC_CLOSE, KC_BRID, KC_BRIU, KC_MCTRL, KC_MYCM, RGB_VAD, RGB_VAI, KC_F7, KC_F8, KC_F9, KC_MUTE, KC_VOLD, KC_VOLU, A(KC_F4), _______, _______, ALT4KEY, A(KC_F4),
HEATMAP, BT_HST1, BT_HST2, BT_HST3, P2P4G, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_CALC, _______, _______, _______,
- RGB_MOD, RGB_TOG, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, SS_PERSONAL, SS_ADDRESS,
+ RGB_MOD, RGB_TOG, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, TOG_VIM, _______, _______, _______, _______, _______, _______, _______, SS_PERSONAL, SS_ADDRESS,
_______, C(KC_A), C(KC_S), RGB_HUD, RGB_SAD, RGB_SPD, _______, _______, _______, _______, _______, _______, _______, _______, SS_NICK, SS_WEB, SS_GITHUB, _______,
_______, C(KC_Z), C(KC_X), C(KC_C), C(KC_V), BAT_LVL, NK_TOGG, TO(MUSIK), _______, AC_TOGG, _______, _______, _______, SS_NAME, SS_EMAIL, SS_PHONE,
_______, _______, _______, _______, _______, _______, _______, TD(TD_OPEN), _______, TD(TD_CLOSE), _______, _______, _______),
@@ -114,7 +116,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
bool mouse_jiggler_enabled = false;
static uint16_t mouse_jiggler_timer;
-bool has_mouse_report_changed(report_mouse_t* new_report, report_mouse_t* old_report) {
+bool has_mouse_report_changed(
+ report_mouse_t* new_report,
+ report_mouse_t* old_report
+) {
// Only report every 5 seconds.
if (mouse_jiggler_enabled && timer_elapsed(mouse_jiggler_timer) > 5000) {
mouse_jiggler_timer = timer_read();
@@ -314,7 +319,7 @@ static uint32_t idle_callback(uint32_t trigger_time, void* cb_arg) {
}
/* ##################################################################### */
-/* ########################## Encoder mappping ######################### */
+/* ########################## Encoder mapping ########################## */
/* ##################################################################### */
// The encoder map defines the behavior of the encoders. It maps the
// encoders to the keycodes that are sent when the encoder is turned.
@@ -355,6 +360,11 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
if (!process_achordion(keycode, record)) { return false; } // Achordion
if (!process_sentence_case(keycode, record)) { return false; } // Sentence case
+ // process vim mode
+ if (!process_vim_mode(keycode, record)) {
+ return false;
+ }
+
// Alt4Key overrides
if (!record->event.pressed) { // On key up event.
static uint8_t count = 0;
@@ -703,6 +713,14 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
send_unicode_string("€");
}
return false;
+ case ESC_CLOSE: // Close the current window/tab
+ if (record->event.pressed) {
+ SEND_STRING(
+ SS_LCTL(
+ SS_LSFT(
+ SS_TAP(X_Q))));
+ }
+ return false;
/* Backspace or delete based on shift key state override. */
#ifdef USE_BSPC_DEL_OVERRIDE
case KC_BSPC: { // Backspace or Delete based on shift key state.
@@ -736,6 +754,13 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
}
return false;
#endif
+ case TOG_VIM:
+ if (record->event.pressed) {
+ toggle_vim_mode();
+ }
+ return false;
+ default:
+ return true;
}
// Call the common keychron process record function
@@ -744,6 +769,40 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
}
return true;
}
+/* ##################################################################### */
+/* ####################### RGB MATRIX INDICATORS ####################### */
+/* ##################################################################### */
+// This function is called to set the RGB matrix indicators.
+static uint current_vim = 0;
+bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
+ // Set Vim mode indicator LEDs
+ if (vim_mode_enabled()) {
+ if ( current_vim <= 0 ) {
+ RGB_MATRIX_INDICATOR_SET_COLOR(ESC_KEY_INDEX, 255, 255, 255);
+ } else if ( current_vim == 1 ) {
+ RGB_MATRIX_INDICATOR_SET_COLOR(ESC_KEY_INDEX, 75, 255, 75);
+ } else if ( current_vim == 2 ) {
+ RGB_MATRIX_INDICATOR_SET_COLOR(ESC_KEY_INDEX, 255, 75, 255);
+ } else if ( current_vim >= 3 ) {
+ RGB_MATRIX_INDICATOR_SET_COLOR(ESC_KEY_INDEX, 255, 75, 255);
+ }
+ }
+ return true;
+}
+
+// Set the Vim mode flag
+void insert_mode_user(void) {
+ current_vim = 1;
+}
+void normal_mode_user(void) {
+ current_vim = 0;
+}
+void visual_mode_user(void) {
+ current_vim = 2;
+}
+void visual_line_mode_user(void) {
+ current_vim = 3;
+}
/* ##################################################################### */
/* ########################### Layer Locking ########################### */
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/LICENSE b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/LICENSE
new file mode 100644
index 000000000000..d159169d1050
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/LICENSE
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/README.org b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/README.org
new file mode 100644
index 000000000000..769adcb04030
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/README.org
@@ -0,0 +1,416 @@
+#+TITLE: QMK Vim
+#+OPTIONS: ^:nil
+
+[[images/demo.gif]]
+
+* Table of Contents :TOC_3:noexport:
+- [[#about][About]]
+- [[#features][Features]]
+ - [[#core-features][Core Features]]
+ - [[#motions][Motions]]
+ - [[#actions][Actions]]
+ - [[#normal-mode][Normal Mode]]
+ - [[#insert-mode][Insert Mode]]
+ - [[#visual-mode][Visual Mode]]
+ - [[#visual-line-mode][Visual Line Mode]]
+ - [[#extra-features][Extra Features]]
+ - [[#text-objects][Text Objects]]
+ - [[#dot-repeat][Dot Repeat]]
+ - [[#w-motions][W Motions]]
+ - [[#numbered-jumps][Numbered Jumps]]
+ - [[#oneshot-vim][Oneshot Vim]]
+- [[#configuration][Configuration]]
+ - [[#setup][Setup]]
+ - [[#adding-keybinds][Adding Keybinds]]
+ - [[#setting-custom-state][Setting Custom State]]
+ - [[#mac-support][Mac Support]]
+ - [[#displaying-modes][Displaying Modes]]
+- [[#contributing][Contributing]]
+ - [[#updating-readme-firmware-sizes][Updating Readme Firmware Sizes]]
+
+* About
+This project aims to emulate as much of vim as possible in QMK userspace. The
+idea is to use clever combinations of shift, home, end, and control + arrow keys
+to emulate vim's modal editing and motions.
+
+The other goal is to make it relatively plug and play in user keymaps, while
+still providing customization options.
+
+* Features
+** Core Features
+The core features are in in the tables below and takes up roughly 5% of at
+Atmega32u4.
+*** Motions
+Motions are available in [[#normal-mode][normal]] and [[#visual-mode][visual mode]], and can be composed with
+[[#actions][actions]]. Note that in the table below the mods shown are for Linux/Windows,
+however if =VIM_FOR_MAC= is defined then these should change to =LOPT=.
+| Vim Binding | Action | Notes |
+|-------------+--------------+-----------------------------------------------------------------------------------------------------------------------------------|
+| h | LEFT | |
+| j | DOWN | |
+| k | UP | |
+| l | RIGHT | |
+| e / E | LCTL + RIGHT | This may act more like a =w= command depending on the text environment |
+| w / W | LCTL + RIGHT | By default, this may act more like an =e= command depending on the text environment. Alternatively, see [[#w-motions][W motions]] |
+| b / B | LCTL + LEFT | |
+| 0 / ^ | HOME | In some text environments this goes to the true start, or the first piece of text |
+| $ | END | |
+
+*** Actions
+Change, delete, and yank actions are all supported and can be combined with
+[[#motions][motions]] and text objects in normal mode as you would expect. For example =cw= will
+change until the next word (or end of word depending on your text environment).
+Note that by default the =d= action will copy the deleted text to the clipboard.
+
+In visual mode each action can be accessed with =c=, =d=, and =y= respectively and
+they will act on the currently selected visual area.
+
+Normal mode also supports these commands:
+| Vim Binding | Action | Notes |
+|-------------+-------------------------------------+----------------------------------------------------|
+| cc / S | Change line | This doesn't copy the old line to clipboard |
+| C | Change to end of line | This doesn't copy the changed content to clipboard |
+| s | Change character to right of cursor | This doesn't copy the changed content to clipboard |
+| dd | Delete line | This copies the deleted line to clipboard |
+| D | Delete to end of line | This copies the deleted text to clipboard |
+| yy | Yank line | |
+| Y | Yank to end of line | |
+
+**** Paste Action
+The =paste_action()= handles pasting, which is simple for non lines, but most of
+the time, I'm pasting lines so this function attempts to consistently handle
+pasting lines. Yanks and deletes of lines are tracked through the =yanked_line=
+global, the paste action then pastes accordingly. For copying and pasting lines
+the line(s) the selection is made from the very start of the line below, up to
+start of the first line. See the [[#visual-line-mode][visual line mode]] section for more info on how
+lines are selected. There is also an optional =paste_before_action()=, enabled
+with the =VIM_PASTE_BEFORE= macro.
+
+*** Normal Mode
+This below tables lists all of the commands not covered by the [[#motions][motions]] and
+[[#actions][actions]] sections . Note that in the table below the mods shown are for
+Linux/Windows, however if =VIM_FOR_MAC= is defined then these should change to
+=LCMD=.
+| Vim Binding | Action | Notes |
+|-------------+-------------------------------------------------+-------------------------------------|
+| i | [[#insert-mode][insert_mode()]] | |
+| I | HOME, [[#insert-mode][insert_mode()]] | |
+| a | RIGHT, [[#insert-mode][insert_mode()]] | |
+| A | END, [[#insert-mode][insert_mode()]] | |
+| o | END, ENTER, [[#insert-mode][insert_mode()]] | |
+| O | HOME, ENTER, UP [[#insert-mode][insert_mode()]] | |
+| v | [[#visual-mode][visual_mode()]] | |
+| V | [[#visual-line-mode][visual_line_mode()]] | |
+| p | [[#paste-action][paste_action()]] | |
+| u | LCTL + z | This works /most/ places |
+| CTRL + r | LCTL + y | This may or may not work everywhere |
+| x | DELETE | |
+| X | BACKSPACE | |
+
+Note that all keycodes chorded with CTRL, GUI, or ALT, that aren't bound to
+anything are let through. In other words, you can still alt tab and use
+shortcuts for whatever editor you're in.
+
+*** Insert Mode
+Insert mode is rather straight forward, all keystrokes are passed through as
+normal with the exception of escape, which brings you back to [[#normal-mode][normal mode]].
+
+*** Visual Mode
+Visual mode behaves largely as one would expect, all [[#motions][motions]] and [[#actions][actions]] are
+supported. Escape of course returns you to [[#normal-mode][normal mode]]. Note that hitting
+escape may move your cursor unexpectedly, especially if you don't have
+=BETTER_VISUAL_MODE= enabled. This is because there isn't a good way to just
+deselect text in "standard" editing, the best way is to move the text cursor
+with the arrow keys. The trouble for us is choosing which way to move, by
+default we always move right. However, with =BETTER_VISUAL_MODE= enabled the
+first direction moved in visual mode is recorded so that we can move the cursor
+to either the left or right or the selection as required. Of course this
+approach breaks down if you double back on the cursor, but I find I don't do
+that all that often.
+
+*** Visual Line Mode
+Visual line mode is very similar to [[#visual-mode][visual mode]] as you would expect however only
+the ~j~ and ~k~ motions are supported and of course the entire line is selected.
+However, there is no perfect way (that I know of) to select lines the way vim
+does easily. The way I used do it before I used vim, was to get myself to the
+start of the line then hit shift and up or down. Going down works almost as
+you'd expect in vim, but you'll always be a line behind since it doesn't
+highlight the line the cursor is currently on. Going up on the other hand will
+select the line the cursor is on, but it will always be missing the first line.
+So neither solution quite works on it's own, =BETTER_VISUAL_MODE= does mostly fix
+these issues, but at the price of a larger compile size, hence why it's not on
+by default.
+
+A note on the default implementation, since most programming environments make
+the home key go to the start of the indent or the actual start of the line
+dynamically, consistently getting to the start of a line isn't as easy as
+hitting home. The most consistent way I've found is to hit end on the line
+above, and then right arrow your way to the start of the next line. This works
+as long as there is no line wrapping, so in the default implementation, entering
+visual line mode sends ~KC_END~, ~KC_RIGHT~, ~LSFT(KC_UP)~. Not only is this quite
+consistent, it also immediately highlights the current line just as you would
+expect. The only downside with the default implementation is that if you then
+try to go down that first line will be deselected, so you have to start your
+visual selection a line above when moving downwards. Of course
+=BETTER_VISUAL_MODE= fixes this as long as you don't double back on the cursor.
+
+** Extra Features
+In an effort to reduce the size overhead of the project, any extra features can be enabled and disabled using macros in your config.h.
+| Macro | Features Enabled/Disabled | Bytes (gcc 8.3.0) |
+|---------------------------+-----------------------------------------------------------------------------------------------------------------------------------+-------------------|
+| =NO_VISUAL_MODE= | Disables the normal visual mode. | +256 B |
+| =NO_VISUAL_LINE_MODE= | Disables the normal visual line mode. | +336 B |
+| =BETTER_VISUAL_MODE= | Makes the visual modes much more vim like, see [[#visual-line-mode][visual_line_mode()]] for details. | -172 B |
+| =VIM_I_TEXT_OBJECTS= | Adds the ~i~ text objects, which adds the ~iw~ and ~ig~ text objects, see [[#text-objects][text objects]] for details. | -122 B |
+| =VIM_A_TEXT_OBJECTS= | Adds the ~a~ text objects, which adds the ~aw~ and ~ag~ text objects. | -138 B |
+| =VIM_G_MOTIONS= | Adds ~gg~ and ~G~ motions, which only work in some programs. | -116 B |
+| =VIM_COLON_CMDS= | Adds the colon command state, but only the ~w~ and ~q~ commands are supported (can be in combination). | -72 B |
+| =VIM_PASTE_BEFORE= | Adds the ~P~ command. | -60 B |
+| =VIM_REPLACE= | Adds the ~r~ command. | -76 B |
+| =VIM_DOT_REPEAT= | Adds the ~.~ command, allowing you to repeat actions, see [[#dot-repeat][dot repeat]] for details. | -232 B |
+| =VIM_W_BEGINNING_OF_WORD= | Makes the ~w~ and ~W~ motions skip to the beginning of the next word, see [[#w-motions][W motions]] for details. | -104 B |
+| =VIM_NUMBERED_JUMPS= | Adds the ability to do numbered motions, ie ~10j~ or ~5w~, be wary of large numbers however, as they can freeze up your keyboard. | -544 B |
+| =ONESHOT_VIM= | Enables running vim in "oneshot" mode, see [[#oneshot-vim][oneshot vim]] for details. | -76 B |
+| =VIM_FOR_ALL= | Adds the ability to toggle Mac support on and off at runtime, rather than only at compile time. | -456 B |
+
+*** Text Objects
+Unfortunately there is really no way to implement text objects properly,
+especially things like brackets. However, word objects in some form are quite
+possible. The tricky part is distinguishing between an inner and outer word,
+some editors will have a forward word jump go to the end of a word like vim''s
+~w~.
+
+It's easy to get an inner word if word jump acts like ~e~, since you can go to the
+end of the word, then hold shift and jump to the start. And similarly it's easy
+to get an outer word if word jump acts like ~w~, since you can go to the start of
+the next word then hold shift and jump back to the start of your word. However,
+getting an inner word with just ~w~ and ~b~ at your disposal isn't possible without
+using arrow keys which won't be consistent in scenarios where the word
+punctuated in some way. But, it is possible to get an outer word with ~b~ and ~e~.
+In vim terms, the sequence looks like ~eebvb~, now in vim that doesn't do exactly
+what we want, but with word jumps it does result in an outer word selection.
+
+It should be noted that this always selects extra space to the right of the
+word, and if the cursor is at the end of a word it will get the wrong word. So
+it isn't ideal, but it works okay in general.
+
+There is also a the ~g~ object, which isn't even a default vim object, but ~CTRL+A~
+provides such a nice way to select the entire document that I couldn't help it.
+I find it especially nice if I'm sending a message and I want to delete what I
+wrote or change the whole thing, with ~dig~ or ~cig~.
+
+*** Dot Repeat
+The dot repeat feature can be enabled with the =VIM_DOT_REPEAT= macro. This lets
+the user hit the ~.~ key in normal mode to repeat the last normal mode command.
+For example, typing ~ciw~, ~hello!~, will replace the underlying word with ~hello!~,
+now going over another word hitting ~.~ will repeat the action, just like vim
+does. The way this works is that once an action starts, like ~c~ or ~D~, or even ~A~
+all keycodes are recorded until we return to the normal mode state. Once you
+hit ~.~ it goes through the recorded keys until it hits normal mode again. The
+default size of the recorded keys buffer is =64=, but can be modified with the
+=VIM_REPEAT_BUF_SIZE= macro.
+
+*** W Motions
+If the =VIM_W_BEGINNING_OF_WORD= macro is defined, the ~w~ and ~W~ motions (which are
+synonymous) will skip to the beginning of the next word by sending LCTL + RIGHT
+and then tapping LCTL + RIGHT, LCTL + LEFT on release. Otherwise, their default
+behavior is to imitate the ~e~ and ~E~ motions by sending LCTL + RIGHT. Note that
+enabling this feature currently causes unexpected side effects with actions such
+as ~cw~ and ~dw~, where the ~w~ motion acts like an ~e~ motion
+([[https://github.com/andrewjrae/qmk-vim/pull/1#discussion_r650416367][context]]).
+
+*** Numbered Jumps
+The numbered jumps feature allows users to do repeat motions a specified number
+of times just like in vim. By enabling =VIM_NUMBERED_JUMPS=, you can now type ~10j~
+to jump down 10 lines, or you can type ~c3w~ to change the next three words.
+
+*** Oneshot Vim
+"Oneshot" vim is not a normal vim feature, rather it's a way to use this enable
+this vim mode for a brief moment. Inspired by oneshot keys and other features
+like [[https://github.com/andrewjrae/kyria-keymap#caps-word][caps word]], this
+mode tries to intelligently leave vim mode automatically. This was added
+because sometimes I only want to make a small edit, or quickly navigate and yank
+some text, and I don't like having to toggle the mode on and off. Especially as
+sometimes I forget to turn it off and get briefly confused why the /real/ vim
+isn't working quite right.
+
+In essence, this mode works as normal except that any time you press ~Esc~ you
+exit the mode, same goes if you call any complex action like ~daw~, ~ciw~ and the like.
+Note that currently simple things like ~x~ and ~Y~ do not cause oneshot vim to exit.
+
+To enable this mode simply add the =ONESHOT_VIM= macro to your =config.h=.
+Then add some way to call the =start_oneshot_vim()= function.
+
+* Configuration
+** Setup
++ First add the repo as a submodule to your keymap or userspace.
+ #+begin_src bash
+git submodule add https://github.com/andrewjrae/qmk-vim.git
+ #+end_src
+
++ Next, you need to source the files in the make file, the easy way to do this is to just add this line to your keymap's ~rules.mk~ file:
+ #+begin_src make
+include $(KEYBOARD_PATH_2)/keymaps/$(KEYMAP)/qmk-vim/rules.mk
+ #+end_src
+ ...or to your userspace's ~rules.mk~ file:
+ #+begin_src make
+include $(USER_PATH)/qmk-vim/rules.mk
+ #+end_src
+ If this doesn't work, you can either try changing the number in the =KEYBOARD_PATH_2= variable (values 1-5), or simply copy the contents from [[file:rules.mk][qmk-vim/rules.mk]].
+
++ Now add the header file so you can add =process_vim_mode()= to your =process_record_user()=, it can either go at the top or the bottom, it depends on how you want it to interact with your keycodes.
+
+ If you process at the beginning it will look something like this, make sure that you return false when =process_vim_mode()= returns false.
+ #+begin_src C
+#include "qmk-vim/src/vim.h"
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ // Process case modes
+ if (!process_vim_mode(keycode, record)) {
+ return false;
+ }
+ ...
+ #+end_src
+
++ The last step is to add a way to enter into vim mode. There are many ways
+ to do this, personally I use leader sequences, but using combos or just a
+ macro on a layer are all viable ways to do this. The important part here is
+ ensure that you also have a way to get out of vim mode, since by default there
+ is no way out. Enabling =VIM_COLON_CMDS= will allow you to also use ~:q~ or ~:wq~
+ in order to get out of vim, but in general I would recommend using the
+ =toggle_vim_mode()= function.
+
+ As a simple example, here is the setup for a simple custom keycode macro:
+ #+begin_src C
+enum custom_keycodes {
+ TOG_VIM = SAFE_RANGE,
+};
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ // Process case modes
+ if (!process_vim_mode(keycode, record)) {
+ return false;
+ }
+
+ // Regular user keycode case statement
+ switch (keycode) {
+ case CAPSWORD:
+ if (record->event.pressed) {
+ toggle_vim_mode();
+ }
+ return false;
+ default:
+ return true;
+ }
+}
+ #+end_src
+** Adding Keybinds
+Since most vim users remap a key here or there, I've added hooks for the normal,
+visual, visual line, and insert modes. These hooks act in the exact same way
+that =process_record_user()= does, except that keycodes come in with any active
+modifiers applied to them. And not all keycodes will be passed down to vim, vim
+mode only intercepts keycodes alphanumeric, and symbolic keycodes (and escape).
+
+For example pressing =KC_LSHIFT= and then =KC_A= will have =LSFT(KC_A)= sent down to
+vim mode. It should also be noted that all modifiers will be added to the
+keycode as the left mod, ie you can always use =LSFT(KC_A)= for catching ~A~.
+
+The hooks that you can use are:
+#+begin_src C
+bool process_insert_mode_user(uint16_t keycode, const keyrecord_t *record);
+bool process_normal_mode_user(uint16_t keycode, const keyrecord_t *record);
+bool process_visual_mode_user(uint16_t keycode, const keyrecord_t *record);
+bool process_visual_line_mode_user(uint16_t keycode, const keyrecord_t *record);
+#+end_src
+
+As an example, I have the bad habit of hitting ~CTRL+S~ all the time. And for a
+long time I've had it so that in insert mode, ~CTRL+S~ saves and enters
+[[#normal-mode][normal_mode()]]. So in my [[https://github.com/andrewjrae/kyria-keymap/blob/master/keymap.c][keymap.c]] file I have this binding added:
+#+begin_src C
+bool process_insert_mode_user(uint16_t keycode, const keyrecord_t *record) {
+ if (record->event.pressed && keycode == LCTL(KC_S)) {
+ normal_mode();
+ tap_code16(keycode);
+ return false;
+ }
+ return true;
+}
+#+end_src
+** Setting Custom State
+The following user hooks are also called whenever the active mode is changed:
+#+begin_src C
+void insert_mode_user(void);
+void normal_mode_user(void);
+void visual_mode_user(void);
+void visual_line_mode_user(void);
+#+end_src
+
+These can optionally be used to set custom state in your keymap.c file; for
+example, changing the [[https://beta.docs.qmk.fm/using-qmk/hardware-features/lighting/feature_rgblight#enabling-and-disabling-lighting-layers-id-enabling-lighting-layers][RGB lighting layer]] to indicate the current mode:
+#+begin_src C
+void insert_mode_user(void) {
+ rgblight_set_layer_state(VIM_LIGHTING_LAYER, false);
+}
+void normal_mode_user(void) {
+ rgblight_set_layer_state(VIM_LIGHTING_LAYER, true);
+}
+#+end_src
+** Mac Support
+Since Macs have different shortcuts, you need to set the =VIM_FOR_MAC= macro in
+your config.h. That being said I'm not a Mac user so it's all untested and I'd
+guess there are some issues.
+
+If you are a Mac user and do encounter issues, feel free to put up a PR or an
+issue.
+
+If you intend to use your keyboard with both Mac and Windows or Linux computers, you can set the =VIM_FOR_ALL= macro in
+your config.h. This will allow you to use the following functions in your keymap.c to switch between Mac support mode
+and non-Mac support mode:
+#+begin_src C
+void enable_vim_for_mac(void);
+void disable_vim_for_mac(void);
+void toggle_vim_for_mac(void);
+bool vim_for_mac_enabled(void);
+#+end_src
+=VIM_FOR_ALL= overrides the behavior of =VIM_FOR_MAC=.
+
+By default the keyboard will start in non-Mac support mode, but if =VIM_FOR_ALL= and =VIM_FOR_MAC= are both defined the
+keyboard will start in Mac support mode.
+
+** Displaying Modes
+To help remind you that you have vim mode enabled, there are two functions
+available. The =vim_mode_enabled()= function which returns =true= is vim mode is
+active, and the =get_vim_mode()= function which returns the current vim mode.
+
+In my keymap I use these to display the current mode on my OLED.
+#+begin_src C
+if (vim_mode_enabled()) {
+ switch (get_vim_mode()) {
+ case NORMAL_MODE:
+ oled_write_P(PSTR("-- NORMAL --\n"), false);
+ break;
+ case INSERT_MODE:
+ oled_write_P(PSTR("-- INSERT --\n"), false);
+ break;
+ case VISUAL_MODE:
+ oled_write_P(PSTR("-- VISUAL --\n"), false);
+ break;
+ case VISUAL_LINE_MODE:
+ oled_write_P(PSTR("-- VISUAL LINE --\n"), false);
+ break;
+ default:
+ oled_write_P(PSTR("?????\n"), false);
+ break;
+ }
+#+end_src
+
+* Contributing
+** Updating Readme Firmware Sizes
+If you'd like to submit a pull request, please update the [[#extra-features][table with the
+firmware sizes for each feature]]. This can be done automatically by running the
+following commands in the root directory of this repository (it may take a few
+minutes, since it recompiles for each feature in the table):
+#+begin_src bash
+docker build -t qmk-vim-update-readme update-readme
+docker run -v $PWD:/qmk_firmware/keyboards/uno/keymaps/qmk-vim-update-readme/qmk-vim qmk-vim-update-readme
+#+end_src
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/rules.mk b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/rules.mk
new file mode 100644
index 000000000000..11e497992fc7
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/rules.mk
@@ -0,0 +1,8 @@
+# note that the order is important here
+SRC += qmk-vim/src/mac_mode.c
+SRC += qmk-vim/src/process_func.c
+SRC += qmk-vim/src/numbered_actions.c
+SRC += qmk-vim/src/motions.c
+SRC += qmk-vim/src/actions.c
+SRC += qmk-vim/src/modes.c
+SRC += qmk-vim/src/vim.c
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/actions.c b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/actions.c
new file mode 100644
index 000000000000..feba915dfd8d
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/actions.c
@@ -0,0 +1,309 @@
+#include "actions.h"
+#include "numbered_actions.h"
+#include "motions.h"
+#include "process_func.h"
+
+
+// Function pointer type for executing actions
+typedef void (*action_func_t)(void);
+
+// the current process func, from in process_func.c
+extern process_func_t process_func;
+
+// forward declare insert_mode
+void normal_mode(void);
+void insert_mode(void);
+bool process_normal_mode(uint16_t keycode, const keyrecord_t *record);
+
+// which key is the current action key
+static uint16_t action_key;
+// the current action_function
+static action_func_t action_func;
+// whether the current yank is a line or not
+static bool yanked_line;
+
+// Function to process key codes when in an action sequence
+static bool process_vim_action(uint16_t keycode, const keyrecord_t *record) {
+ // process numbers for numbered actions
+#ifdef VIM_NUMBERED_JUMPS
+ if (!process_numbers(keycode, record)) {
+ return false;
+ }
+#endif
+ // process motion and exit call action func if there was one
+ if (!process_motions(keycode, record, QK_LSFT)) {
+ clear_keyboard();
+ action_func();
+ return false;
+ }
+
+#ifdef _VIM_TEXT_OBJECTS
+ if (!process_text_objects(keycode, record)) {
+ return false;
+ }
+#endif
+
+ // handle double taps, ie cc, yy, dd
+ if (record->event.pressed) {
+ if (keycode == action_key) {
+ // for the change action
+ if (action_func == change_action) {
+ VIM_HOME();
+ VIM_SHIFT_END();
+#ifdef VIM_NUMBERED_JUMPS
+ extern int16_t motion_counter;
+ if (motion_counter > 0) {
+ tap_code16(LSFT(KC_RIGHT));
+ decrement_motion_counter();
+ DO_NUMBERED_ACTION(
+ tap_code16(LSFT(KC_DOWN));
+ );
+ }
+#endif
+ action_func();
+ }
+ else {
+ VIM_END();
+ tap_code(KC_RIGHT);
+ tap_code(KC_UP);
+ DO_NUMBERED_ACTION(
+ tap_code16(LSFT(KC_DOWN));
+ );
+ action_func();
+ yanked_line = true;
+ }
+ return false;
+ }
+ // if nothing happened, return to normal mode
+ normal_mode();
+ }
+
+ return false;
+}
+
+#ifdef VIM_I_TEXT_OBJECTS
+static bool process_in_object(uint16_t keycode, const keyrecord_t *record) {
+ if (record->event.pressed) {
+ switch (keycode) {
+ case KC_W:
+ tap_code16(VIM_W);
+ tap_code16(LSFT(VIM_B));
+ action_func();
+ return false;
+ case KC_G:
+ tap_code16(VCMD(KC_A));
+ action_func();
+ return false;
+ default:
+ normal_mode();
+ return false;
+ }
+ }
+ return false;
+}
+#endif
+
+#ifdef VIM_A_TEXT_OBJECTS
+static bool process_around_object(uint16_t keycode, const keyrecord_t *record) {
+ if (record->event.pressed) {
+ switch (keycode) {
+ case KC_W:
+ tap_code16(VIM_W);
+ tap_code16(VIM_W);
+ tap_code16(VIM_B);
+ tap_code16(LSFT(VIM_B));
+ action_func();
+ return false;
+ case KC_G:
+ tap_code16(VCMD(KC_A));
+ action_func();
+ return false;
+ default:
+ normal_mode();
+ return false;
+ }
+ }
+ return false;
+}
+#endif
+
+#ifdef _VIM_TEXT_OBJECTS
+bool process_text_objects(uint16_t keycode, const keyrecord_t *record) {
+ if (record->event.pressed) {
+#ifdef VIM_I_TEXT_OBJECTS
+ if (keycode == KC_I) {
+ process_func = process_in_object;
+ return false;
+ }
+#endif
+#ifdef VIM_A_TEXT_OBJECTS
+ if (keycode == KC_A) {
+ process_func = process_around_object;
+ return false;
+ }
+#endif
+ }
+ return true;
+}
+#endif // end ifdef VIM_TEXT_OBJECTS
+
+// The actual change action
+void change_action(void) {
+ tap_code16(VIM_CHANGE);
+ insert_mode();
+}
+// The actual delete action
+void delete_action(void) {
+ yanked_line = false;
+ tap_code16(VIM_DELETE);
+ normal_mode();
+}
+// The delete action for a line
+void delete_line_action(void) {
+ yanked_line = true;
+ tap_code16(VIM_DELETE);
+ normal_mode();
+}
+// The actual yank action
+void yank_action(void) {
+ yanked_line = false;
+ tap_code16(VIM_YANK);
+ tap_code(KC_LEFT);
+ normal_mode();
+}
+// The yank action for a line
+void yank_line_action(void) {
+ yanked_line = true;
+ tap_code16(VIM_YANK);
+ tap_code(KC_LEFT);
+ normal_mode();
+}
+// The paste action
+void paste_action(void) {
+ if (yanked_line) {
+ VIM_END();
+ tap_code(KC_RIGHT);
+ }
+ tap_code16(VIM_PASTE);
+ normal_mode();
+}
+#ifdef VIM_PASTE_BEFORE
+// Paste before, ie P
+void paste_before_action(void) {
+ if (yanked_line) {
+ VIM_END();
+ tap_code(KC_RIGHT);
+ tap_code(KC_UP);
+ }
+ else {
+ tap_code(KC_LEFT);
+ }
+ tap_code16(VIM_PASTE);
+ normal_mode();
+}
+#endif
+
+// Function to start a change action
+void start_change_action(void) {
+ action_key = KC_C;
+ action_func = change_action;
+ process_func = process_vim_action;
+}
+// Function to start a delete action
+void start_delete_action(void) {
+ action_key = KC_D;
+ action_func = delete_action;
+ process_func = process_vim_action;
+}
+// Function to start a yank action
+void start_yank_action(void) {
+ action_key = KC_Y;
+ action_func = yank_action;
+ process_func = process_vim_action;
+}
+
+// a little nasty but okay...
+extern bool process_visual_mode(uint16_t keycode, const keyrecord_t *record);
+static void visual_no_action(void) {
+ process_func = process_visual_mode;
+}
+// Function to start a visual action
+void start_visual_action(void) {
+ action_key = KC_NO;
+ action_func = visual_no_action;
+ // Don't update the process_func, that should already be set to the
+ // visual mode process func
+}
+
+#ifdef VIM_REPLACE
+static bool process_replace_action(uint16_t keycode, const keyrecord_t *record) {
+ if (record->event.pressed) {
+ if (keycode != KC_ESC) {
+ tap_code(KC_DELETE);
+ tap_code16(keycode);
+ tap_code(KC_LEFT);
+ }
+ normal_mode();
+ }
+ return false;
+}
+
+void replace_action(void) {
+ process_func = process_replace_action;
+}
+#endif
+
+#ifdef VIM_DOT_REPEAT
+
+#ifndef VIM_REPEAT_BUF_SIZE
+#define VIM_REPEAT_BUF_SIZE 64
+#endif
+
+typedef enum {
+ INVALID_REPEAT = 0,
+ VALID_REPEAT,
+ RECORDING_REPEAT,
+ EXECUTING_REPEAT,
+} repeat_state_t;
+
+static repeat_state_t repeat_state = INVALID_REPEAT;
+static uint8_t repeat_buf_idx = 0;
+// if this gets much bigger you would probably want it in progmem
+static uint16_t repeat_buf[VIM_REPEAT_BUF_SIZE];
+
+void start_recording_repeat(void) {
+ // if the state isn't recording or executing
+ if (repeat_state <= VALID_REPEAT) {
+ repeat_state = RECORDING_REPEAT;
+ repeat_buf_idx = 0;
+ }
+}
+
+void add_repeat_keycode(uint16_t keycode) {
+ if (repeat_state == RECORDING_REPEAT) {
+ if (repeat_buf_idx < VIM_REPEAT_BUF_SIZE) {
+ repeat_buf[repeat_buf_idx] = keycode;
+ ++repeat_buf_idx;
+ if (process_func == process_normal_mode) {
+ repeat_state = VALID_REPEAT;
+ }
+ }
+ else {
+ repeat_state = INVALID_REPEAT;
+ }
+ }
+}
+
+void repeat_action(const keyrecord_t *record) {
+ if (repeat_state == VALID_REPEAT) {
+ repeat_state = EXECUTING_REPEAT;
+ for (uint8_t i = 0; i < repeat_buf_idx; ++i) {
+ if (process_func(repeat_buf[i], record)) {
+ tap_code16(repeat_buf[i]);
+ }
+ }
+ repeat_state = VALID_REPEAT;
+ }
+}
+
+#endif
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/actions.h b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/actions.h
new file mode 100644
index 000000000000..9d847f63f502
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/actions.h
@@ -0,0 +1,75 @@
+#pragma once
+
+#include "mac_mode.h"
+#include "motions.h"
+
+// If either of the text objects are defined, define this macro for both
+#if defined (VIM_I_TEXT_OBJECTS) || defined (VIM_A_TEXT_OBJECTS)
+#define _VIM_TEXT_OBJECTS
+#endif
+
+// Define a custom variable for the common shortcut modifier
+// ie on MAC, CMD + C is copy, but on Windows/Linux it's CTRL + C
+// This should be used whenever using one of these shortcuts
+
+#define VCMD(kc) VIM_MAC_NOMAC(LCMD(kc), LCTL(kc))
+#define VIM_REDO VIM_MAC_NOMAC(VCMD(LSFT(KC_Z)), VCMD(KC_Y))
+
+// These + VIM_REDO (defined above) are the main keys for each vim core vim action
+#define VIM_CHANGE KC_DEL
+#define VIM_DELETE VCMD(KC_X) // note that you may prefer a simple delete here since we only are using one clipboard
+#define VIM_YANK VCMD(KC_C)
+// Other commands
+#define VIM_PASTE VCMD(KC_V)
+#define VIM_UNDO VCMD(KC_Z)
+#define VIM_FIND VCMD(KC_F)
+#define VIM_SAVE VCMD(KC_S)
+#define VIM_X KC_DEL
+#define VIM_SHIFT_X KC_BSPC
+
+// Process function to handle text objects ie in or around word
+bool process_text_objects(uint16_t keycode, const keyrecord_t *record);
+
+// The actual change action
+void change_action(void);
+// The actual delete action
+void delete_action(void);
+// The yank action for a line
+void delete_line_action(void);
+// The actual yank action
+void yank_action(void);
+// The yank action for a line
+void yank_line_action(void);
+// The paste action
+void paste_action(void);
+#ifdef VIM_PASTE_BEFORE
+// Paste before, ie P
+void paste_before_action(void);
+#endif
+
+// Visual mode isn't an action, but it does share the same action type sequences,
+// so we need a way to make the action not call an old action
+void action_prepare_visual(void);
+
+// Function to start a change action
+void start_change_action(void);
+// Function to start a delete action
+void start_delete_action(void);
+// Function to start a yank action
+void start_yank_action(void);
+
+// Function to start a visual action
+// Note that this functions a little differently as there is no action at the end,
+// and it doesn't use the process_vim_action function, it basically sets up the global
+// variables such that process_text_objects can be used without calling a random action
+void start_visual_action(void);
+
+#ifdef VIM_REPLACE
+void replace_action(void);
+#endif
+
+#ifdef VIM_DOT_REPEAT
+void start_recording_repeat(void);
+void add_repeat_keycode(uint16_t keycode);
+void repeat_action(const keyrecord_t *record);
+#endif
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/mac_mode.c b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/mac_mode.c
new file mode 100644
index 000000000000..202cacc76e23
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/mac_mode.c
@@ -0,0 +1,12 @@
+#include "mac_mode.h"
+
+#ifdef VIM_FOR_ALL
+
+// When VIM_FOR_ALL is enabled, we allow the user to choose if mac support is enabled at startup or not
+#ifdef VIM_FOR_MAC
+bool vim_for_mac = true;
+#else
+bool vim_for_mac = false;
+#endif
+
+#endif
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/mac_mode.h b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/mac_mode.h
new file mode 100644
index 000000000000..b823773b789e
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/mac_mode.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#include QMK_KEYBOARD_H
+
+#ifdef VIM_FOR_ALL
+
+extern bool vim_for_mac;
+
+#define VIM_MAC_NOMAC(a, b) (vim_for_mac ? (a) : (b))
+// The results of this implimentation of VIM_MAC_NOMAC are not constant
+// expressions, which means they cannot be used in a case statement
+// In order to get around this restriction we can duplicate the switch statement
+// and force our keycode to evaluate as a constant expression in each
+#define VIM_REDUCE_MAC_NOMAC_TO_CONST(body) do { \
+ if(vim_for_mac) { \
+ const bool vim_for_mac = true; \
+ body \
+ } \
+ else { \
+ const bool vim_for_mac = false; \
+ body \
+ } \
+} while (0)
+
+#else
+
+#ifdef VIM_FOR_MAC
+#define VIM_MAC_NOMAC(a, b) (a)
+
+#else
+#define VIM_MAC_NOMAC(a, b) (b)
+#endif
+
+#define VIM_REDUCE_MAC_NOMAC_TO_CONST(body) do { \
+ body \
+} while(0)
+
+#endif
+
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/modes.c b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/modes.c
new file mode 100644
index 000000000000..7a6e17b7a5c8
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/modes.c
@@ -0,0 +1,469 @@
+#include "modes.h"
+#include "numbered_actions.h"
+#include "motions.h"
+#include "actions.h"
+#include "process_func.h"
+
+extern process_func_t process_func;
+
+// forward declare from vim.h
+void disable_vim_mode(void);
+
+vim_mode_t vim_current_mode;
+vim_mode_t get_vim_mode(void) {
+ return vim_current_mode;
+}
+
+#ifdef BETTER_VISUAL_MODE
+extern visual_direction_t visual_direction;
+#endif
+
+#ifdef VIM_G_MOTIONS
+static bool process_g_cmd(uint16_t keycode, const keyrecord_t *record) {
+ if (record->event.pressed) {
+ switch (keycode) {
+ case KC_G:
+ // this doesn't quite work for all programs
+ tap_code16(VCMD(KC_A));
+ wait_ms(200);
+ tap_code(KC_UP);
+ break;
+ default:
+ break;
+ }
+ normal_mode();
+ }
+ return false;
+}
+#endif
+
+#ifdef VIM_COLON_CMDS
+static bool process_colon_cmd(uint16_t keycode, const keyrecord_t *record) {
+ if (record->event.pressed) {
+ switch (keycode) {
+ case KC_Q:
+ disable_vim_mode();
+ break;
+ case KC_W:
+ tap_code16(VIM_SAVE);
+ break;
+ case KC_ENTER:
+ normal_mode();
+ break;
+ default:
+ break;
+ }
+ }
+ return false;
+}
+#endif
+
+// Allow the user to add their own bindings to both normal modes
+// Note, this should be optimized away unless there is a user definition
+__attribute__ ((weak))
+bool process_normal_mode_user(uint16_t keycode, const keyrecord_t *record) {
+ return true;
+}
+
+// The function that handles normal mode keycode inputs
+bool process_normal_mode(uint16_t keycode, const keyrecord_t *record) {
+ if (!process_normal_mode_user(keycode, record)) {
+ return false;
+ }
+#ifdef VIM_DOT_REPEAT
+ bool should_record_action = true;
+ #define NO_RECORD_ACTION() should_record_action = false;
+#else
+ #define NO_RECORD_ACTION()
+#endif
+
+ // process numbers for numbered actions
+#ifdef VIM_NUMBERED_JUMPS
+ if (!process_numbers(keycode, record)) {
+ return false;
+ }
+#endif
+ // handle motions on their own so they can be pressed and held
+ if (!process_motions(keycode, record, 0)) {
+ return false;
+ }
+ if (record->event.pressed) {
+ switch (keycode) {
+ // insert keys
+ case LSFT(KC_I):
+ VIM_HOME();
+ // fallthrough to lowercase i
+ case KC_I:
+ insert_mode();
+ break;
+ case LSFT(KC_A):
+ VIM_END();
+ insert_mode();
+ break;
+ case KC_A:
+ tap_code(KC_RIGHT);
+ insert_mode();
+ break;
+ case LSFT(KC_O):
+ VIM_HOME();
+ tap_code(KC_ENTER);
+ tap_code(KC_UP);
+ insert_mode();
+ break;
+ case KC_O:
+ VIM_END();
+ tap_code(KC_ENTER);
+ insert_mode();
+ break;
+ // actions
+ case LSFT(KC_C):
+ VIM_SHIFT_END();
+ change_action();
+ break;
+ case KC_C:
+ start_change_action();
+ break;
+ case LSFT(KC_D):
+ VIM_SHIFT_END();
+ delete_action();
+ break;
+ case KC_D:
+ start_delete_action();
+ break;
+ case LSFT(KC_S):
+ VIM_HOME();
+ VIM_SHIFT_END();
+ change_action();
+ break;
+ case KC_S:
+ tap_code16(LSFT(KC_RIGHT));
+ change_action();
+ break;
+ case LSFT(KC_Y):
+ VIM_SHIFT_END();
+ yank_action();
+ NO_RECORD_ACTION();
+ break;
+ case KC_Y:
+ start_yank_action();
+ NO_RECORD_ACTION();
+ break;
+#ifdef VIM_PASTE_BEFORE
+ case LSFT(KC_P):
+ paste_before_action();
+ break;
+#endif
+ case KC_P:
+ paste_action();
+ break;
+ // visual modes
+#ifndef NO_VISUAL_LINE_MODE
+ case LSFT(KC_V):
+ visual_line_mode();
+ NO_RECORD_ACTION();
+ break;
+#endif
+#ifndef NO_VISUAL_MODE
+ case KC_V:
+ visual_mode();
+ NO_RECORD_ACTION();
+ break;
+#endif
+ // undo redo
+ case KC_U:
+ tap_code16(VIM_UNDO);
+ wait_ms(10);
+ tap_code(KC_LEFT);
+ NO_RECORD_ACTION();
+ break;
+ case LCTL(KC_R):
+ tap_code16(VIM_REDO);
+ NO_RECORD_ACTION();
+ break;
+#ifdef VIM_REPLACE
+ case KC_R:
+ replace_action();
+ break;
+#endif
+ case KC_X:
+ tap_code16(VIM_X);
+ break;
+ case LSFT(KC_X):
+ tap_code16(VIM_SHIFT_X);
+ break;
+#ifdef VIM_COLON_CMDS
+ case KC_COLON:
+ process_func = process_colon_cmd;
+ NO_RECORD_ACTION();
+ break;
+#endif
+#ifdef VIM_G_MOTIONS
+ // g motions
+ case LSFT(KC_G):
+ // this doesn't quite work for all programs
+ tap_code16(VCMD(KC_A));
+ wait_ms(200);
+ tap_code(KC_DOWN);
+ NO_RECORD_ACTION();
+ break;
+ case KC_G:
+ process_func = process_g_cmd;
+ NO_RECORD_ACTION();
+ break;
+#endif
+#ifdef VIM_DOT_REPEAT
+ case KC_DOT:
+ repeat_action(record);
+ NO_RECORD_ACTION();
+ break;
+#endif
+ default:
+ NO_RECORD_ACTION();
+ if (keycode >= QK_MODS && (keycode & 0xFF00) != QK_LSFT) {
+ tap_code16(keycode);
+ }
+ break;
+ }
+#ifdef VIM_DOT_REPEAT
+ if (should_record_action) {
+ start_recording_repeat();
+ }
+#endif
+ }
+ return false;
+}
+
+// Allow the user to add their own bindings to visual mode
+// Note, this should be optimized away unless there is a user definition
+__attribute__ ((weak))
+bool process_visual_mode_user(uint16_t keycode, const keyrecord_t *record) {
+ return true;
+}
+
+// The function that handles visual mode keycode inputs
+bool process_visual_mode(uint16_t keycode, const keyrecord_t *record) {
+ if (!process_visual_mode_user(keycode, record)) {
+ return false;
+ }
+ // process numbers for numbered actions
+#ifdef VIM_NUMBERED_JUMPS
+ if (!process_numbers(keycode, record)) {
+ return false;
+ }
+#endif
+ // handle motions on their own so they can be pressed and held
+ if (!process_motions(keycode, record, QK_LSFT)) {
+ return false;
+ }
+#ifdef _VIM_TEXT_OBJECTS
+ if (!process_text_objects(keycode, record)) {
+ return false;
+ }
+#endif
+ if (record->event.pressed) {
+ switch (keycode) {
+ case KC_C:
+ case KC_S:
+ change_action();
+ return false;
+ case KC_D:
+ case KC_X:
+ delete_action();
+ return false;
+ case KC_Y:
+ yank_action();
+ return false;
+ case KC_P:
+ tap_code16(VIM_PASTE);
+ normal_mode();
+ return false;
+ case KC_ESC:
+#ifdef BETTER_VISUAL_MODE
+ if (visual_direction == V_FORWARD)
+ tap_code(KC_RIGHT);
+ else
+ tap_code(KC_LEFT);
+#else
+ tap_code(KC_RIGHT);
+#endif
+ normal_mode();
+ return false;
+ default:
+ if (keycode >= QK_MODS && (keycode & 0xFF00) != QK_LSFT) {
+ tap_code16(keycode);
+ }
+ break;
+ }
+ }
+ return false;
+}
+
+// Allow the user to add their own bindings to visual line mode
+// Note, this should be optimized away unless there is a user definition
+__attribute__ ((weak))
+bool process_visual_line_mode_user(uint16_t keycode, const keyrecord_t *record) {
+ return true;
+}
+
+// The function that handles visual line mode keycode inputs
+bool process_visual_line_mode(uint16_t keycode, const keyrecord_t *record) {
+ if (!process_visual_line_mode_user(keycode, record)) {
+ return false;
+ }
+ // process numbers for numbered actions
+#ifdef VIM_NUMBERED_JUMPS
+ if (!process_numbers(keycode, record)) {
+ return false;
+ }
+#endif
+ // handle motions on their own so they can be pressed and held
+ switch (keycode) {
+ case KC_J:
+ case VIM_J:
+#ifdef BETTER_VISUAL_MODE
+ if (visual_direction == V_NONE) {
+ tap_code(KC_LEFT);
+ tap_code16(LSFT(VIM_J));
+ }
+#endif
+ set_visual_direction(V_FORWARD);
+ register_motion(LSFT(VIM_J), record);
+ return false;
+ case KC_K:
+ case VIM_K:
+ set_visual_direction(V_BACKWARD);
+ register_motion(LSFT(VIM_K), record);
+ return false;
+ }
+ if (record->event.pressed) {
+ switch (keycode) {
+ case KC_C:
+ case KC_S:
+ tap_code16(LSFT(KC_LEFT));
+ change_action();
+ return false;
+ case KC_D:
+ case KC_X:
+ delete_line_action();
+ return false;
+ case KC_Y:
+ yank_line_action();
+ return false;
+ case KC_P:
+ tap_code16(VIM_PASTE);
+ normal_mode();
+ return false;
+ case KC_ESC:
+#ifdef BETTER_VISUAL_MODE
+ if (visual_direction == V_FORWARD)
+ tap_code(KC_RIGHT);
+ else
+ tap_code(KC_LEFT);
+#else
+ tap_code(KC_RIGHT);
+#endif
+ normal_mode();
+ return false;
+ default:
+ if (keycode >= QK_MODS && (keycode & 0xFF00) != QK_LSFT) {
+ tap_code16(keycode);
+ }
+ break;
+ }
+ }
+ return false;
+}
+
+
+// Allow the user to add their own bindings to insert mode
+// Note, this should be optimized away unless there is a user definition
+__attribute__ ((weak))
+bool process_insert_mode_user(uint16_t keycode, const keyrecord_t *record) {
+ return true;
+}
+
+// The function that handles insert mode keycode inputs
+bool process_insert_mode(uint16_t keycode, const keyrecord_t *record) {
+ if (!process_insert_mode_user(keycode, record)) {
+ return false;
+ }
+ // handle motions on their own so they can be pressed and held
+ if (record->event.pressed) {
+ switch (keycode) {
+ case KC_ESC:
+ normal_mode();
+ return false;
+ default:
+ break;
+ }
+ }
+ return true;
+}
+
+
+// Allow the user to set custom state when normal mode is entered
+__attribute__ ((weak))
+void normal_mode_user(void) {
+}
+
+// Function to enter into normal mode
+void normal_mode(void) {
+ normal_mode_user();
+ vim_current_mode = NORMAL_MODE;
+ process_func = process_normal_mode;
+}
+
+// Allow the user to set custom state when insert mode is entered
+__attribute__ ((weak))
+void insert_mode_user(void) {
+}
+
+// Function to enter into insert mode
+void insert_mode(void) {
+ insert_mode_user();
+ vim_current_mode = INSERT_MODE;
+ // need to clear motion keys if they are currently pressed
+ clear_keyboard();
+ process_func = process_insert_mode;
+}
+
+// Allow the user to set custom state when visual mode is entered
+__attribute__ ((weak))
+void visual_mode_user(void) {
+}
+
+// Function to enter into visual mode
+void visual_mode(void) {
+ visual_mode_user();
+ vim_current_mode = VISUAL_MODE;
+#ifndef NO_VISUAL_MODE
+#ifdef BETTER_VISUAL_MODE
+ visual_direction = V_NONE;
+#endif
+ // this sets up the actions states so we can use text objects
+ start_visual_action();
+ process_func = process_visual_mode;
+#endif
+}
+
+
+// Allow the user to set custom state when visual line mode is entered
+__attribute__ ((weak))
+void visual_line_mode_user(void) {
+}
+
+// Function to enter into visual line mode
+void visual_line_mode(void) {
+ visual_line_mode_user();
+ vim_current_mode = VISUAL_LINE_MODE;
+#ifndef NO_VISUAL_LINE_MODE
+#ifdef BETTER_VISUAL_MODE
+ visual_direction = V_NONE;
+#endif
+ VIM_END();
+ tap_code(KC_RIGHT);
+ tap_code16(LSFT(KC_UP));
+
+ process_func = process_visual_line_mode;
+#endif
+}
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/modes.h b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/modes.h
new file mode 100644
index 000000000000..e43a5507217a
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/modes.h
@@ -0,0 +1,21 @@
+#pragma once
+
+typedef enum {
+ NORMAL_MODE = 0,
+ VISUAL_MODE,
+ VISUAL_LINE_MODE,
+ INSERT_MODE,
+ UNKNOWN_MODE,
+} vim_mode_t;
+
+// Function to enter into normal mode
+void normal_mode(void);
+// Function to enter into insert mode
+void insert_mode(void);
+// Function to enter into visual mode
+void visual_mode(void);
+// Function to enter into visual line mode
+void visual_line_mode(void);
+
+// Get the mode that vim is currently in
+vim_mode_t get_vim_mode(void);
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/motions.c b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/motions.c
new file mode 100644
index 000000000000..eac282547bf3
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/motions.c
@@ -0,0 +1,109 @@
+#include "mac_mode.h"
+#include "motions.h"
+#include "numbered_actions.h"
+
+#ifdef BETTER_VISUAL_MODE
+visual_direction_t visual_direction = V_NONE;
+#endif
+
+void set_visual_direction(visual_direction_t dir) {
+#ifdef BETTER_VISUAL_MODE
+ if (visual_direction == V_NONE)
+ visual_direction = dir;
+#endif
+}
+
+void register_motion(uint16_t keycode, const keyrecord_t *record) {
+ if (record->event.pressed) {
+#ifdef VIM_NUMBERED_JUMPS
+ extern int16_t motion_counter;
+ if (motion_counter > 1) {
+ tap_code16(keycode);
+ return;
+ }
+#endif
+ register_code16(keycode);
+ } else {
+ unregister_code16(keycode);
+ }
+}
+
+bool process_motions(uint16_t keycode, const keyrecord_t *record, uint16_t qk_mods) {
+ // This macro duplicates the code inside if VIM_FOR_ALL is enabled
+ // Calling it on only a subset of the larger switch statement saves some space
+ VIM_REDUCE_MAC_NOMAC_TO_CONST(
+ switch (keycode) {
+ case VIM_B:
+ keycode = KC_B;
+ break;
+ case VIM_W:
+ keycode = KC_W;
+ break;
+ case VIM_0:
+ keycode = KC_0;
+ break;
+ case VIM_DLR:
+ keycode = KC_DLR;
+ break;
+ }
+ );
+ DO_NUMBERED_ACTION(
+ switch (keycode) {
+ case KC_H:
+ case VIM_H:
+ set_visual_direction(V_BACKWARD);
+ register_motion(qk_mods | VIM_H, record);
+ break;
+ case KC_J:
+ case VIM_J:
+ set_visual_direction(V_FORWARD);
+ register_motion(qk_mods | VIM_J, record);
+ break;
+ case KC_K:
+ case VIM_K:
+ set_visual_direction(V_BACKWARD);
+ register_motion(qk_mods | VIM_K, record);
+ break;
+ case KC_L:
+ case VIM_L:
+ set_visual_direction(V_FORWARD);
+ register_motion(qk_mods | VIM_L, record);
+ break;
+ case KC_B:
+ case LSFT(KC_B):
+ set_visual_direction(V_BACKWARD);
+ register_motion(qk_mods | VIM_B, record);
+ break;
+ case KC_W:
+ case LSFT(KC_W):
+#ifdef VIM_W_BEGINNING_OF_WORD
+ set_visual_direction(V_FORWARD);
+ register_motion(qk_mods | VIM_W, record);
+ if (!record->event.pressed) {
+ /* unregister_code16(qk_mods | VIM_W); */
+ tap_code16(qk_mods | VIM_W);
+ tap_code16(qk_mods | VIM_B);
+ }
+ break;
+#endif
+ case KC_E:
+ case LSFT(KC_E):
+ set_visual_direction(V_FORWARD);
+ register_motion(qk_mods | VIM_E, record);
+ break;
+ case KC_0:
+ case KC_CIRC: // ^
+ set_visual_direction(V_BACKWARD);
+ register_motion(qk_mods | VIM_0, record);
+ break;
+ case KC_DLR: // $
+ set_visual_direction(V_FORWARD);
+ register_motion(qk_mods | VIM_DLR, record);
+ break;
+ default:
+ /* motion_counter = 0; */
+ return true;
+ }
+ );
+ return false;
+}
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/motions.h b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/motions.h
new file mode 100644
index 000000000000..a596df816d9b
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/motions.h
@@ -0,0 +1,45 @@
+#pragma once
+
+#include QMK_KEYBOARD_H
+#include "mac_mode.h"
+
+// Define a custom variable for the common motion shortcut modifier
+// ie on MAC, OPT + RIGHT is forward word, but on Windows/Linux it's CTRL + RIGHT
+// This should be used whenever using one of these shortcuts
+#define VMOTION(kc) VIM_MAC_NOMAC(LOPT(kc), LCTL(kc))
+
+#define VIM_0 VIM_MAC_NOMAC(LCMD(KC_LEFT), KC_HOME)
+#define VIM_HOME() VIM_MAC_NOMAC(tap_code16(VIM_0), tap_code(VIM_0));
+#define VIM_SHIFT_HOME() tap_code16(LSFT(VIM_0));
+
+#define VIM_DLR VIM_MAC_NOMAC(LCMD(KC_RIGHT), KC_END)
+#define VIM_END() VIM_MAC_NOMAC(tap_code16(VIM_DLR), tap_code(VIM_DLR));
+#define VIM_SHIFT_END() tap_code16(LSFT(VIM_DLR));
+
+// The vim motions keys supported by single keystrokes/chords
+#define VIM_H KC_LEFT
+#define VIM_J KC_DOWN
+#define VIM_K KC_UP
+#define VIM_L KC_RIGHT
+
+#define VIM_B VMOTION(KC_LEFT)
+#define VIM_W VMOTION(KC_RIGHT)
+#define VIM_E VMOTION(KC_RIGHT)
+
+// An enum for the direction of the visual mode
+// This is used to figure out which way to exit out of a selection
+// Note that it's only ever used when BETTER_VISUAL_MODE is defined
+// Also note that this will only garner expected behaviour if the
+// the user doesn't double back on their original cursor position
+typedef enum {
+ V_NONE = 0,
+ V_FORWARD,
+ V_BACKWARD,
+} visual_direction_t;
+
+// Function to set the global visual direction if it is currently unset
+void set_visual_direction(visual_direction_t dir);
+
+// Register one of the basic vim motions in a fashion where they can be held down.
+void register_motion(uint16_t keycode, const keyrecord_t *record);
+bool process_motions(uint16_t keycode, const keyrecord_t *record, uint16_t qk_mods);
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/numbered_actions.c b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/numbered_actions.c
new file mode 100644
index 000000000000..ea5f3e249f63
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/numbered_actions.c
@@ -0,0 +1,24 @@
+#include "numbered_actions.h"
+
+
+int16_t motion_counter = 0;
+bool process_numbers(uint16_t keycode, const keyrecord_t *record) {
+#ifdef VIM_NUMBERED_JUMPS
+ if (keycode >= KC_1 && keycode <= KC_0) {
+ if (record->event.pressed) {
+ motion_counter *= 10;
+ if (keycode != KC_0) {
+ motion_counter += keycode - KC_1 + 1;
+ }
+ }
+ return motion_counter == 0;
+ }
+#endif
+ return true;
+}
+
+inline void decrement_motion_counter(void) {
+#ifdef VIM_NUMBERED_JUMPS
+ motion_counter -= motion_counter > 0;
+#endif
+}
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/numbered_actions.h b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/numbered_actions.h
new file mode 100644
index 000000000000..c952d31b429f
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/numbered_actions.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include QMK_KEYBOARD_H
+
+// Process hook for numbered action motion counter
+bool process_numbers(uint16_t keycode, const keyrecord_t *record);
+
+// Function to safely decrement the motion counter
+void decrement_motion_counter(void);
+
+#ifdef VIM_NUMBERED_JUMPS
+
+// Define the do numbered action command which will repeat the given code
+// according to the motion counter
+#define DO_NUMBERED_ACTION(ACTION) \
+ do { \
+ extern int16_t motion_counter; \
+ do { \
+ ACTION; \
+ } while (motion_counter && motion_counter-- > 1); \
+ } while (0)
+
+#else
+#define DO_NUMBERED_ACTION(ACTION) \
+ do { \
+ ACTION; \
+ } while (0)
+#endif
+
+
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/process_func.c b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/process_func.c
new file mode 100644
index 000000000000..0924df4e5820
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/process_func.c
@@ -0,0 +1,3 @@
+#include "process_func.h"
+
+process_func_t process_func = NULL;
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/process_func.h b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/process_func.h
new file mode 100644
index 000000000000..16abc9caeb6c
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/process_func.h
@@ -0,0 +1,6 @@
+#pragma once
+
+#include QMK_KEYBOARD_H
+
+// Function pointer type for process keycode functions
+typedef bool (*process_func_t)(uint16_t, const keyrecord_t*);
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/vim.c b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/vim.c
new file mode 100644
index 000000000000..1b7fecace567
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/vim.c
@@ -0,0 +1,149 @@
+/* Copyright 2021 Andrew Rae ajrae.nv@gmail.com @andrewjrae
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "vim.h"
+#include "modes.h"
+#include "actions.h"
+#include "process_func.h"
+
+// the current process func, from in process_func.c
+extern process_func_t process_func;
+
+static bool vim_enabled = false;
+
+#ifdef VIM_FOR_ALL
+// Check to see if mac mode is enabled
+bool vim_for_mac_enabled(void) {
+ return vim_for_mac;
+}
+// Enable mac mode
+void enable_vim_for_mac(void) {
+ vim_for_mac = true;
+}
+// Disable mac mode
+void disable_vim_for_mac(void) {
+ vim_for_mac = false;
+}
+// Toggle mac mode
+void toggle_vim_for_mac(void) {
+ vim_for_mac = !vim_for_mac;
+}
+#endif
+
+// Check to see if vim mode is enabled
+bool vim_mode_enabled(void) {
+ return vim_enabled;
+}
+// Enable vim mode
+void enable_vim_mode(void) {
+ vim_enabled = true;
+ normal_mode();
+}
+// Disable vim mode
+void disable_vim_mode(void) {
+ vim_enabled = false;
+}
+// Toggle vim mode
+void toggle_vim_mode(void) {
+ if (vim_enabled) {
+ disable_vim_mode();
+ }
+ else {
+ enable_vim_mode();
+ }
+}
+
+#ifdef ONESHOT_VIM
+extern bool process_normal_mode(uint16_t keycode, const keyrecord_t *record);
+extern bool process_insert_mode(uint16_t keycode, const keyrecord_t *record);
+
+static bool oneshot_vim_enabled = false;
+static process_func_t last_process_func;
+// Start vim mode
+void start_oneshot_vim(void) {
+ oneshot_vim_enabled = true;
+ last_process_func = process_normal_mode;
+ enable_vim_mode();
+}
+// Stop vim mode
+void stop_oneshot_vim(void) {
+ oneshot_vim_enabled = false;
+ disable_vim_mode();
+}
+static inline void vim_oneshot_termination(uint16_t keycode) {
+ if (oneshot_vim_enabled &&
+ (keycode == KC_ESC ||
+ process_func == process_insert_mode ||
+ (process_func == process_normal_mode && last_process_func != process_func))) {
+ stop_oneshot_vim();
+ }
+ last_process_func = process_func;
+}
+#endif
+
+// Process keycode for leader sequences
+bool process_vim_mode(uint16_t keycode, const keyrecord_t *record) {
+ if (vim_enabled) {
+ // Get the base keycode of a mod or layer tap key
+ if ((QK_MOD_TAP <= keycode && keycode <= QK_MOD_TAP_MAX)
+ || (QK_LAYER_TAP <= keycode && keycode <= QK_LAYER_TAP_MAX)) {
+ // Earlier return if this has not been considered tapped yet
+ if (record->tap.count == 0)
+ return true;
+ keycode = keycode & 0xFF;
+ }
+
+ // let through anything above normal keyboard keycode or a mod
+ if ((keycode < KC_A || keycode > KC_CAPS_LOCK) && (keycode < QK_MODS || keycode > QK_MODS_MAX)) {
+ return true;
+ }
+
+ const uint8_t mods = get_mods();
+ const uint8_t oneshot_mods = get_oneshot_mods();
+ // hoping this gets optimized away by the compiler
+ const uint8_t all_mods = mods | oneshot_mods;
+ // this takes mod bits adds them to to the keycode, but always as the left mod (lower 4 mod bits)
+ // for some reason with AVR gcc 8.3.0, the compile size is larger if you use a |= ???
+ keycode = all_mods & 0xF0 ? keycode | (all_mods << 4) : keycode | (all_mods << 8);
+
+ // clear the mods
+ clear_mods();
+ clear_oneshot_mods();
+
+ // process the current keycode
+ bool do_process_key = process_func(keycode, record);
+
+#ifdef VIM_DOT_REPEAT
+ if (record->event.pressed) {
+ add_repeat_keycode(keycode);
+ }
+#endif
+
+ set_mods(mods);
+ // only restore one shot mods if the key was passed through
+ if (do_process_key) {
+ set_oneshot_mods(oneshot_mods);
+ }
+
+#ifdef ONESHOT_VIM
+ // this function checks for oneshot termination conditions and stops if applicable
+ vim_oneshot_termination(keycode);
+#endif
+
+ return do_process_key;
+ }
+ return true;
+}
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/vim.h b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/vim.h
new file mode 100644
index 000000000000..59e97ad3fa54
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/src/vim.h
@@ -0,0 +1,48 @@
+/* Copyright 2021 Andrew Rae ajrae.nv@gmail.com @andrewjrae
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#pragma once
+
+#include QMK_KEYBOARD_H
+
+// Check to see if vim mode is enabled
+bool vim_mode_enabled(void);
+// Enable vim mode
+void enable_vim_mode(void);
+// Disable vim mode
+void disable_vim_mode(void);
+// Toggle vim mode
+void toggle_vim_mode(void);
+
+#ifdef ONESHOT_VIM
+// Start vim mode
+void start_oneshot_vim(void);
+// Stop vim mode
+void stop_oneshot_vim(void);
+#endif
+
+#ifdef VIM_FOR_ALL
+// Check to see if mac mode is enabled
+bool vim_for_mac_enabled(void);
+// Enable mac mode
+void enable_vim_for_mac(void);
+// Disable mac mode
+void disable_vim_for_mac(void);
+// Toggle mac mode
+void toggle_vim_for_mac(void);
+#endif
+// Process keycode for vim mode
+bool process_vim_mode(uint16_t keycode, const keyrecord_t *record);
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/update-readme/Dockerfile b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/update-readme/Dockerfile
new file mode 100644
index 000000000000..172af7e190d7
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/update-readme/Dockerfile
@@ -0,0 +1,10 @@
+FROM qmkfm/qmk_firmware:latest
+
+ENV MY_KEYMAP_PATH=/qmk_firmware/keyboards/uno/keymaps/qmk-vim-update-readme
+
+WORKDIR /qmk_firmware
+
+COPY keymap $MY_KEYMAP_PATH
+COPY run.py /qmk_firmware/qmk_vim_update_readme.py
+
+CMD python3 qmk_vim_update_readme.py
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/update-readme/keymap/config.h b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/update-readme/keymap/config.h
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/update-readme/keymap/keymap.c b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/update-readme/keymap/keymap.c
new file mode 100644
index 000000000000..0efb94fba709
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/update-readme/keymap/keymap.c
@@ -0,0 +1,21 @@
+#include QMK_KEYBOARD_H
+#include "qmk-vim/src/vim.h"
+
+enum keycodes {
+ QMK_VIM = SAFE_RANGE
+};
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [0] = LAYOUT(QMK_VIM)
+};
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ if (!process_vim_mode(keycode, record)) {
+ return false;
+ }
+ if (keycode == QMK_VIM && record->event.pressed) {
+ toggle_vim_mode();
+ return false;
+ }
+ return true;
+}
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/update-readme/keymap/rules.mk b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/update-readme/keymap/rules.mk
new file mode 100644
index 000000000000..0f57b4214a26
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/update-readme/keymap/rules.mk
@@ -0,0 +1 @@
+include keyboards/uno/keymaps/qmk-vim-update-readme/qmk-vim/rules.mk
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/update-readme/run.py b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/update-readme/run.py
new file mode 100644
index 000000000000..c00aae40cc2b
--- /dev/null
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/qmk-vim/update-readme/run.py
@@ -0,0 +1,52 @@
+import os
+import re
+import subprocess
+
+# Path to QMK keymap used for firmware size calculations
+MY_KEYMAP_PATH = os.getenv('MY_KEYMAP_PATH')
+README_PATH = os.path.join(MY_KEYMAP_PATH, 'qmk-vim/README.org')
+
+# Split readme into sections: before feature macros table, table itself, and after table
+BEFORE, MACROS, AFTER = 0, 1, 2
+lines = [[], [], []]
+position = BEFORE
+with open(README_PATH) as f:
+ for line in f:
+ if ((position == BEFORE and line.startswith('| ='))
+ or (position == MACROS and not line.startswith('|'))):
+ position += 1
+ lines[position].append(line)
+
+# Compile and parse output for firmware size
+def get_firmware_size():
+ process = subprocess.run(
+ ['qmk', 'compile', '-kb', 'uno', '-km', 'qmk-vim-update-readme'], capture_output=True)
+ matches = re.search(r'The firmware size is fine - (\d+)', process.stdout.decode('utf-8'))
+ return int(matches[1])
+
+# Determine firmware size without any macros defined
+baseline = get_firmware_size()
+
+# Iterate over rows in table
+for i in range(len(lines[MACROS])):
+ # Parse macro name
+ line = lines[MACROS][i]
+ cells = line.split('|')
+ macro = cells[1].strip('= ')
+ # Add macro to config
+ with open(os.path.join(MY_KEYMAP_PATH, 'config.h'), 'w') as f:
+ f.write(f'#define {macro}')
+ # Determine firmware size difference
+ size = get_firmware_size()
+ size_diff = baseline - size
+ if size_diff >= 0:
+ new_val_str = f' +{size_diff} B'
+ else:
+ new_val_str = f' {size_diff} B'
+ # Update table
+ cells[3] = new_val_str.ljust(len(cells[3]), ' ')
+ lines[MACROS][i] = '|'.join(cells)
+
+# Overwrite readme with new values
+with open(README_PATH, 'w') as f:
+ f.write(''.join(line for section in lines for line in section))
diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/rules.mk b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/rules.mk
index babbb9530306..021156e5d30e 100644
--- a/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/rules.mk
+++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/rootiest/rules.mk
@@ -33,3 +33,11 @@ SERIAL_ENABLE = yes
NKRO_ENABLE = yes
#KEYBOARD_SHARED_EP = yes
#LTO_ENABLE = yes
+# note that the order is important here
+SRC += qmk-vim/src/mac_mode.c
+SRC += qmk-vim/src/process_func.c
+SRC += qmk-vim/src/numbered_actions.c
+SRC += qmk-vim/src/motions.c
+SRC += qmk-vim/src/actions.c
+SRC += qmk-vim/src/modes.c
+SRC += qmk-vim/src/vim.c
diff --git a/users/rootiest/qmk-vim b/users/rootiest/qmk-vim
new file mode 160000
index 000000000000..7bede58fa649
--- /dev/null
+++ b/users/rootiest/qmk-vim
@@ -0,0 +1 @@
+Subproject commit 7bede58fa649018b062ef8a83bdcffd6009240d6
diff --git a/users/rootiest/rootiest.c b/users/rootiest/rootiest.c
index 98b4c3063337..57a69fd95d5e 100644
--- a/users/rootiest/rootiest.c
+++ b/users/rootiest/rootiest.c
@@ -1,6 +1,6 @@
/**
* Copyright (C) 2024 Chris Laprade (chris@rootiest.com)
- *
+*
* This file is part of rootiest.
*
* rootiest is free software: you can redistribute it and/or modify
@@ -18,7 +18,6 @@
*/
#include "quantum.h"
#include "os_detection.h" // OS detection
-#include "vscode_macros.h" // VSCode macros
__attribute__ ((weak))
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
diff --git a/users/rootiest/rootiest.h b/users/rootiest/rootiest.h
index 514db9fa88ee..f14c6f7926da 100644
--- a/users/rootiest/rootiest.h
+++ b/users/rootiest/rootiest.h
@@ -105,8 +105,10 @@ enum custom_keycodes {
SECTION, // Types section symbol: §
PARAGRAPH, // Types paragraph symbol: ¶
EURO, // Types euro symbol: €
+ ESC_CLOSE, // Closes the current window/tab
VSC_CMD = VSCODE_COMMAND_KEY, // VSCode command key
- ALT4KEY // Applies Alt modifier for next 4 keypresses
+ ALT4KEY, // Applies Alt modifier for next 4 keypresses
+ TOG_VIM, // Toggles VIM mode
};
#endif