Skip to content

Excel vba file to use emacs key bindings and some other useful procedures on Excel

License

Notifications You must be signed in to change notification settings

kkatsuyuki/myExcelVbaEmacsKey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

myExcelVbaEmacsKey

My configuration of Excel vba to use Emacs key bindings

Features

  • Emacs-like selection moving (forward: C-f, backward: C-b, next: C-n, previous: C-p)
  • Move end/start in the active row (end: C-e, start: C-a)
  • Kill/Insert row (kill: C-k insert: C-i)
  • Keep windows common keybindings (Copy: C-c, Paste: C-v, Cut: C-x)
  • Scroll up/down (up: C-u, down: C-d)
  • Other powerful functions
    • SheetForward / SheetPrevious : Select the next/previous sheet
    • CreateSheet : Create the new sheet named by your input
    • MoveRow / MoveCol : Move the selection toward the row/column direction by inputted number/alphabet
  • Refered to EmacsMode.bas in this

Requirements

  • Excel

I saw this program work on Excel 2007 and Windows7.

Install

Use only on the specified book

Import the module file (myEmacsKey.bas) as the standard module and execute the procedure MyEmacsMode.

  1. Open the Excel book.
  2. Click Developer>”Visual Basic” on Ribbon (or Alt + F11).

    → VBE (Visual Basic Editor) is opened

  3. Select the desired project in Project explorer and File>”Import File…” on menu bar (or right click on the desired project and click “Import File…”)
  4. Select the module file (myEmacsKey.bas) and import.

    → The new module is created under the module hierarchy on “Project explorer”

  5. Return to the Excel book window and click Developer>macro on Ribbon and execute MyEmacsMode.

Use globally

Create Personal.xlsb (which is always opened internally ,whatever book is opened) and import the module file (myEmacsKey.bas) on it. Additionaly you have to register MyEmacsMode procedure as follows so that it can be read every time the book is opened.

  1. Create Personal.xlsb seeing Copy your macros to a Personal Macro Workbook. You may delete the macro which is made only to create this file.
  2. Open VBE and import above module files.
  3. The following codes are put into ThisWorkbook under the project of PERSONAL.xlsb. The procedure MyEmacsMode is read every time Excel is opened.
Private Sub Workbook_Open() 
  Call MyEmacsMode          
End Sub                     

Default key bindings and function descriptions

Key BindingFunction NameDescription
C-fForwardCellModifiedselect forward cell
C-bBackwardCellselect backward cell
C-nNextLineModifiedselect next line
C-pPreviousLineselect previous line
C-M-f C-M-bMoveColMove the selection to the row directed by the inputted number
C-M-n C-M-pMoveRowMove the selection to the column directed by the inputted alphabet
M-gMoveRowColMove the selection to the cell directed by inputted ID
C-lRecenterScroll up/down to center the active row
C-uScrollUpScroll up by one page
C-dScrollDownScroll down by one page
C-M-jSmallScrollDownScroll down by one row
C-M-kSmallScrollUpScroll up by one row
C-M-lSmallScrollRightScroll right by one column
C-M-hSmallScrollLeftScroll left by one column
C-+WindowZoomzoom in the active window
C--WindowShrinkzoom out the active window
C-TABSheetForwardSelect the forward sheet
C-S-TABSheetPreviousSelect the previous sheet
C-!FirstSheetSelect the first sheet
C-(LastSheetSelect the last sheet
C-kKillRowKill the active row
C-S-kKillMultipleRowKill the multiple rows by the inputted number
C-iInsertRowInsert a new row
C-S-iInsertMultipleRowInsert the multiple rows by the inputted number
M-<BeginningOfUsedRangeSelect the first cell in the used range
M->EndOfUsedRangeSelect the last cell in the used range
C-M-aBeginningOfUsedRangeRowMove the selection to the first row in the used range
C-M-eEndOfUsedRangeRowMove the selection to the last row in the used range
C-gGroupCommandGroup the selected shapes
C-uUnGroupCommandUngroup the selected group shape
C-tCreateSheetCreate the new sheet you named after the active sheet
C-sSearchOpen the search dialog
C-rReplaceOpen the replace dialog
C-ypasteoriginal paste
M-sMySaveFileSave the book
C-M-rMyFindFileOpen the dialog and select the file to be opened
S-ESCEnable_KeysDeactivate this emacs key bindings

Modify

Since the configuration meets only my needs, I encourage you to modify some configurations especially about key bindings. Modifying is enabled only by modifying imported module directly on VBE or by importing the module file (myEmacsKey.bas) you edited.

Future works (I want your ideas to solve them)

  • Move the window of InputBox where it does not prevent viewing
  • Use the other input method not to create the window instead of using InputBox
  • I want to assign C-M-... commands to M-... keys, but many M-... keys were shadowed by the default access keys. I want to make them disable.
  • Translate C-m into Enter like Emacs
  • Create the undo procedure

About

Excel vba file to use emacs key bindings and some other useful procedures on Excel

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published