Overview

October 20, 2023 · View on GitHub

ExcelLikeVim provides vim-like interface for Excel aiming to provide

  • Vim-like key mapping which has mode notion and is customizable(in ~/vimx/user_configure.bas).
  • Extensible plugin system. By default, some plugins are mimicked and included from popular vim plugin like unite.

Installation

Go to the releases page, download the latest zip file.(Or you can clone this repository) Then unzip it and put whole folders anywhere you like and register vimx.xlam as Excel addin. Additionaly you may need to 'Trust access to the VBA project object model' from security center. This is because this addin manages their own codes outside of .xlam file as text file. Also you may need to set reference to DAO 3.6 library if you are using old excel.

That's all. Now you can use Excel like vim!

If you have some issue, please let me know from submit an issue.

Usage

  • In normal-mode 'hjkl' to move around cells and some other operations.
  • To edit values in a cell, enter insert mode by typing 'i' in normal-mode
  • You can execute function with a string in command-mode entered by typing ':'in normal-mode
  • You can select cells in visual mode entered by 'v' in normal-mode Please see the section 'Default Key bindings' for more detailed list you can do.

Default Keybindings

ModeKeystrokeFunction name
Normalhmove_left
Normaljmove_down
Normalkmove_up
Normallmove_right
Normalgggg
NormalGG
Normalwvim_w
Normalbvim_b
Normal<c-u>scroll_up
Normal<c-d>scroll_down
Normal^move_head
Normal$move_tail
Normaliinsert_mode
Normalainsert_mode
Normalvn_v
NormalVn_v
Normal:command_vim
Normal*unite command
Normal/find
NormalnfindNext
NormalNfindPrevious
NormaloinsertRowDown
NormalOinsertRowUp
Normalddn_dd
Normaldcn_dc
Normalyyn_yy
Normalyvyank_value
Normalpn_p
Normalun_u
Normal<ESC>n_ESC
Visual<ESC>v_ESC
Visualjv_j
Visualkv_k
Visualhv_h
Visuallv_l
Visualggv_gg
VisualGv_G
Visualwv_w
Visualbv_b
Visual<c-u>v_scroll_up
Visual<c-d>v_scroll_down
Visual^v_move_head
Visual$v_move_tail
Visualav_a
Visual<HOME>v_move_head
Visual<END>v_move_tail
Visual:command_vim
Visualyv_y
Visualdv_d
VisualDv_D
Visualxv_x
LineVisualjv_j
LineVisualkv_k
LineVisualggv_gg
LineVisualGv_G
LineVisual<ESC>v_ESC
LineVisualyv_y
LineVisualdlv_d
LineVisualxlv_d
Emergency(※)F3coreloade.reload

Note that this binding will be lost when some error occurs because this settings are stored as macro variables. So press 'F3' to reload the settings. Only this key is directly assigned by Application.onkey so that it won't be lost at that time.

Customization

key mapping

Firstly you need to make ~/vimx/user_configure.bas Then editing ~/vimx/user_configure.bas, you can customize key-mapping and behaviror of some function through setting option. This configure file will be loaded every time a Excel instance launchs.

your plugin

Firstly you need to make directory ~/vimx/plugin/plugin-name/ If you put on .bas .cls files under this directory, it will be loaded when you press 'F3' within Excel. See ExcelLikeVim/doc/sample_user_config_dir/vimx/plugin for a sample.

Example configuration of user_configure.bas

Attribute VB_Name = "user_configure"

Public Sub init()
  Application.Cursor = xlNorthwestArrow
  Call SetAppEvent
  Call keystrokeAsseser.init
  call vimize.main
  call mykeymap
  application.onkey "{F3}", "coreloader.reload"
End Sub 

private sub mykeymap()
  'You can exclude any keys from this software and use them for excel default feature like {^f} => search.
  Application.OnKey "^{f}" 
  Application.OnKey "^{a}"
  Application.OnKey "^{c}"
  Application.OnKey "^{n}"
  Application.OnKey "^{p}"
  Application.OnKey "^{s}"
  Application.OnKey "^{v}"
  Application.OnKey "^{w}"
  Application.OnKey "^{x}"
  Application.OnKey "^{z}"
  Application.OnKey "{F11}"
  Application.OnKey "{F12}"

  Call nmap("<HOME>", "move_head")
  Call nmap("<END>", "move_tail")
  Call nmap("t", "insertColumnRight")
  Call nmap("T", "insertColumnLeft")
  Call nmap(";n", "InteriorColor(0)")
  Call nmap(";r", "InteriorColor(3)")
  Call nmap(";b", "InteriorColor(5)")
  Call nmap(";y", "InteriorColor(6)")
  Call nmap(";d", "InteriorColor(15)")
  Call nmap("m", "merge")
  Call nmap("M", "unmerge")
  Call nmap(">", "biggerFonts")
  Call nmap("<", "smallerFonts")
  Call nmap("z", "SetRuledLines")
  Call nmap("Z", "UnsetRuledLines")
  Call nmap("F9", "toggleVimKeybinde")
  Call nmap("F10", "-a updatemodules(ActiveWorkbook.Name)")
  Call nmap("<c-r>", "update")
  Call nmap("+", "ZoomInWindow")
  Call nmap("-", "ZoomOutWindow")
  Call nmap("gs", "SortCurrentColumn")
  Call nmap("gF", "focusFromScratch")
  Call nmap("gf", "focus")
  Call nmap("g-", "exclude")
  Call nmap("gc", "filterOff")
  Call nmap("H", "ex_left")
  Call nmap("J", "ex_below")
  Call nmap("K", "ex_up")
  Call nmap("L", "ex_right")
  Call nmap(",m", "unite mru")
  Call nmap(",s", "unite sheet")
  Call nmap(",b", "unite book")
  Call nmap(",p", "unite project")
  Call nmap(",f", "unite filter")
  Call nmap("th", "ActivateLeftSheet")
  Call nmap("tl", "ActivateRightSheet")
  Call nmap("tH", "ActivateFirstSheet")
  Call nmap("tL", "ActivateLastSheet")
  Call vmap("<HOME>", "v_move_head")
  Call vmap("<END>", "v_move_tail")
  Call vmap(";n", "visual_operation InteriorColor(0)")
  Call vmap(";r", "visual_operation InteriorColor(3)")
  Call vmap(";b", "visual_operation InteriorColor(5)")
  Call vmap(";y", "visual_operation InteriorColor(6)")
  Call vmap(";d", "visual_operation InteriorColor(15)")
  Call vmap("m", "visual_operation merge")
  Call vmap("M", "visual_operation unmerge")
  Call vmap(">", "visual_operation biggerFonts")
  Call vmap("<", "visual_operation smallerFonts")
  Call vmap("z", "visual_operation SetRuledLines")
  Call vmap("Z", "visual_operation UnsetRuledLines")
  Call lvmap(";n", "visual_operation InteriorColor(0)")
  Call lvmap(";r", "visual_operation InteriorColor(3)")
  Call lvmap(";b", "visual_operation InteriorColor(5)")
  Call lvmap(";y", "visual_operation InteriorColor(6)")
  Call lvmap(";d", "visual_operation InteriorColor(15)")
  Call lvmap("m", "visual_operation merge")
  Call lvmap("M", "visual_operation unmerge")
  Call lvmap(">", "visual_operation biggerFonts")
  Call lvmap("<", "visual_operation smallerFonts")
  Call lvmap("z", "visual_operation SetRuledLines")
  Call lvmap("Z", "visual_operation UnsetRuledLines")
End Sub

Contributing

Nice that you want to spend some time improving this Addin. Solving issues is always appreciated. If you're going to add a feature, it would be best to submit an issue.