├── LICENSE ├── README.md └── preview-vim.json /LICENSE: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | 3 | Copyright (C) 2020 Rishav Kundu 4 | 5 | Everyone is permitted to copy and distribute verbatim or modified 6 | copies of this license document, and changing it is allowed as long 7 | as the name is changed. 8 | 9 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 10 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 11 | 12 | 0. You just DO WHAT THE FUCK YOU WANT TO. 13 | 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vim bindings for macOS Preview.app 2 | 3 | This is a [Karabiner](https://karabiner-elements.pqrs.org) rule that binds **vim** movement keys in Preview, so you can scroll using the keyboard. 4 | 5 | ## Why 6 | 7 | Zathura looks like shit. 8 | 9 | ## How to use 10 | 11 | 1. Install Karabiner. 12 | 2. Copy `preview-vim.json` to `~/.config/karabiner/assets/complex_modifications` 13 | 3. Enable the rule from the complex modifications pane. 14 | 15 | ## Keybindings 16 | 17 | ### Movements: 18 | 19 | - Left => `h` 20 | - Right => `l` 21 | - Down => `j` 22 | - Up => `k` 23 | - Previous position => `H` 24 | - Next position => `L` 25 | - Previous page => `K` 26 | - Next page => `J` 27 | - First page => `g` 28 | - Last page => `G` 29 | 30 | ### Zoom: 31 | 32 | - Zoom In => `=` 33 | - Zoom Out => `-` 34 | - Actual size => `0` 35 | - Zoom to fit => `9` 36 | 37 | ## Contributors 38 | 39 | Thanks to [Daniel Rivas](https://github.com/DanielRivasMD) for contributing substantial functionality! 40 | 41 | ## Todo 42 | 43 | - [ ] make more zathura-like 44 | -------------------------------------------------------------------------------- /preview-vim.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Preview a la vim", 3 | "rules": [ 4 | { 5 | "description": "vim-preview: map jk (down/up)", 6 | "manipulators": [ 7 | { 8 | "type": "basic", 9 | "from": { 10 | "key_code": "j" 11 | }, 12 | "to": [ 13 | { 14 | "key_code": "down_arrow" 15 | } 16 | ], 17 | "conditions": [ 18 | { 19 | "type": "frontmost_application_if", 20 | "bundle_identifiers": [ 21 | "^com.apple.Preview$" 22 | ] 23 | } 24 | ] 25 | }, 26 | { 27 | "type": "basic", 28 | "from": { 29 | "key_code": "k" 30 | }, 31 | "to": [ 32 | { 33 | "key_code": "up_arrow" 34 | } 35 | ], 36 | "conditions": [ 37 | { 38 | "type": "frontmost_application_if", 39 | "bundle_identifiers": [ 40 | "^com.apple.Preview$" 41 | ] 42 | } 43 | ] 44 | } 45 | ] 46 | }, 47 | { 48 | "description": "vim preview: map JK (previous / next page)", 49 | "manipulators": [ 50 | { 51 | "type": "basic", 52 | "from": { 53 | "key_code": "j", 54 | "modifiers": { 55 | "mandatory": [ 56 | "left_shift" 57 | ] 58 | } 59 | }, 60 | "to": [ 61 | { 62 | "key_code": "down_arrow", 63 | "modifiers": [ 64 | "left_option" 65 | ] 66 | } 67 | ], 68 | "conditions": [ 69 | { 70 | "type": "frontmost_application_if", 71 | "bundle_identifiers": [ 72 | "^com.apple.Preview$" 73 | ] 74 | } 75 | ] 76 | }, 77 | { 78 | "type": "basic", 79 | "from": { 80 | "key_code": "k", 81 | "modifiers": { 82 | "mandatory": [ 83 | "left_shift" 84 | ] 85 | } 86 | }, 87 | "to": [ 88 | { 89 | "key_code": "up_arrow", 90 | "modifiers": [ 91 | "left_option" 92 | ] 93 | } 94 | ], 95 | "conditions": [ 96 | { 97 | "type": "frontmost_application_if", 98 | "bundle_identifiers": [ 99 | "^com.apple.Preview$" 100 | ] 101 | } 102 | ] 103 | } 104 | ] 105 | }, 106 | { 107 | "description": "vim-preview: map hl (left / right)", 108 | "manipulators": [ 109 | { 110 | "type": "basic", 111 | "from": { 112 | "key_code": "h" 113 | }, 114 | "to": [ 115 | { 116 | "key_code": "left_arrow" 117 | } 118 | ], 119 | "conditions": [ 120 | { 121 | "type": "frontmost_application_if", 122 | "bundle_identifiers": [ 123 | "^com.apple.Preview$" 124 | ] 125 | } 126 | ] 127 | }, 128 | { 129 | "type": "basic", 130 | "from": { 131 | "key_code": "l" 132 | }, 133 | "to": [ 134 | { 135 | "key_code": "right_arrow" 136 | } 137 | ], 138 | "conditions": [ 139 | { 140 | "type": "frontmost_application_if", 141 | "bundle_identifiers": [ 142 | "^com.apple.Preview$" 143 | ] 144 | } 145 | ] 146 | } 147 | ] 148 | }, 149 | { 150 | "description": "vim-preview: map HL (previous / next position)", 151 | "manipulators": [ 152 | { 153 | "type": "basic", 154 | "from": { 155 | "key_code": "h", 156 | "modifiers": { 157 | "mandatory": [ 158 | "left_shift" 159 | ] 160 | } 161 | }, 162 | "to": [ 163 | { 164 | "key_code": "open_bracket", 165 | "modifiers": [ 166 | "left_command" 167 | ] 168 | } 169 | ], 170 | "conditions": [ 171 | { 172 | "type": "frontmost_application_if", 173 | "bundle_identifiers": [ 174 | "^com.apple.Preview$" 175 | ] 176 | } 177 | ] 178 | }, 179 | { 180 | "type": "basic", 181 | "from": { 182 | "key_code": "l", 183 | "modifiers": { 184 | "mandatory": [ 185 | "left_shift" 186 | ] 187 | } 188 | }, 189 | "to": [ 190 | { 191 | "key_code": "close_bracket", 192 | "modifiers": [ 193 | "left_command" 194 | ] 195 | } 196 | ], 197 | "conditions": [ 198 | { 199 | "type": "frontmost_application_if", 200 | "bundle_identifiers": [ 201 | "^com.apple.Preview$" 202 | ] 203 | } 204 | ] 205 | } 206 | ] 207 | }, 208 | { 209 | "description": "vim-preview: map zoom (9/0/-/=)", 210 | "manipulators": [ 211 | { 212 | "type": "basic", 213 | "from": { 214 | "key_code": "9" 215 | }, 216 | "to": [ 217 | { 218 | "key_code": "9", 219 | "modifiers": [ 220 | "left_command" 221 | ] 222 | } 223 | ], 224 | "conditions": [ 225 | { 226 | "type": "frontmost_application_if", 227 | "bundle_identifiers": [ 228 | "^com.apple.Preview$" 229 | ] 230 | } 231 | ] 232 | }, 233 | { 234 | "type": "basic", 235 | "from": { 236 | "key_code": "0" 237 | }, 238 | "to": [ 239 | { 240 | "key_code": "0", 241 | "modifiers": [ 242 | "left_command" 243 | ] 244 | } 245 | ], 246 | "conditions": [ 247 | { 248 | "type": "frontmost_application_if", 249 | "bundle_identifiers": [ 250 | "^com.apple.Preview$" 251 | ] 252 | } 253 | ] 254 | }, 255 | { 256 | "type": "basic", 257 | "from": { 258 | "key_code": "hyphen" 259 | }, 260 | "to": [ 261 | { 262 | "key_code": "hyphen", 263 | "modifiers": [ 264 | "left_command" 265 | ] 266 | } 267 | ], 268 | "conditions": [ 269 | { 270 | "type": "frontmost_application_if", 271 | "bundle_identifiers": [ 272 | "^com.apple.Preview$" 273 | ] 274 | } 275 | ] 276 | }, 277 | { 278 | "type": "basic", 279 | "from": { 280 | "key_code": "equal_sign" 281 | }, 282 | "to": [ 283 | { 284 | "key_code": "equal_sign", 285 | "modifiers": [ 286 | "left_command" 287 | ] 288 | } 289 | ], 290 | "conditions": [ 291 | { 292 | "type": "frontmost_application_if", 293 | "bundle_identifiers": [ 294 | "^com.apple.Preview$" 295 | ] 296 | } 297 | ] 298 | } 299 | ] 300 | }, 301 | { 302 | "description": "vim-preview: map gG (go to first / last page)", 303 | "manipulators": [ 304 | { 305 | "type": "basic", 306 | "from": { 307 | "key_code": "g" 308 | }, 309 | "to": [ 310 | { 311 | "key_code": "up_arrow", 312 | "modifiers": [ 313 | "left_command" 314 | ] 315 | } 316 | ], 317 | "conditions": [ 318 | { 319 | "type": "frontmost_application_if", 320 | "bundle_identifiers": [ 321 | "^com.apple.Preview$" 322 | ] 323 | } 324 | ] 325 | }, 326 | { 327 | "type": "basic", 328 | "from": { 329 | "key_code": "g", 330 | "modifiers": { 331 | "mandatory": [ 332 | "left_shift" 333 | ] 334 | } 335 | }, 336 | "to": [ 337 | { 338 | "key_code": "down_arrow", 339 | "modifiers": [ 340 | "left_command" 341 | ] 342 | } 343 | ], 344 | "conditions": [ 345 | { 346 | "type": "frontmost_application_if", 347 | "bundle_identifiers": [ 348 | "^com.apple.Preview$" 349 | ] 350 | } 351 | ] 352 | } 353 | ] 354 | } 355 | ] 356 | } 357 | --------------------------------------------------------------------------------