Skip to content

Instantly share code, notes, and snippets.

@strawberryjello
Last active August 29, 2015 14:18
Show Gist options
  • Save strawberryjello/956d2d5b4dc916118082 to your computer and use it in GitHub Desktop.
Save strawberryjello/956d2d5b4dc916118082 to your computer and use it in GitHub Desktop.
Notes for Vim and Emacs beginners.

Notes on Vim and Emacs

Why Vim?

  • Vim is the descendant of vi, designed to be (mostly) backwards-compatible
    • learning vi is useful when you need to edit a file over ssh, since vi is usually installed in any UNIX/UNIX-based system by default
  • Vim’s shortcuts and design, once you learn them, help you search/create/edit/etc files quicker
    • these shortcuts are also used in UNIX-based terminals, such as the man page viewer
  • Vim offers flexible window management (splitting, etc) and works well with tmux, a popular terminal multiplexer
  • Vim’s plugin ecosystem is thriving and full of useful tools for development in most (if not all) languages
  • you can extend Vim yourself using Vimscript

Why Emacs?

  • Emacs is highly extensible – if you need a particular function, either someone has released it or you can code it yourself using Emacs Lisp
  • Emacs’s abundance of packages gives it the same functionality as a modern IDE
    • write code using autocomplete, search, etc within Emacs
    • compile code in a shell within Emacs
    • debug code within Emacs
    • commit/push/pull/view repo history/etc within Emacs
      • for Git, use magit (can also be configured to access and create Github pull requests)
  • … and offers other things as well

Caveats

  • both Emacs and Vim have a very steep learning curve – expect to be slow for at least a week
    • both allow you to use the mouse and common navigation keys (eg, the arrow keys, Page Up, Page Down, etc), so go ahead and use them (and a cheatsheet) during the transition period
  • Emacs’s heavy reliance on the Ctrl key will literally hurt you – many workarounds exist to avoid RSI
    • make your Caps Lock another Ctrl key, or avoid using your pinky when typing
    • use a mode such as CUA mode (or a set of configs, such as Spacemacs) that remaps common shortcuts to different keys

Installation

OS X

Vim

  • Homebrew: brew install vim
  • macvim
    • requires full installation of Xcode (available from App Store)
    • brew install macvim
    • see MacVim in Yosemite article from usevim for possible issues

Emacs

Basics (WIP)

Vim

Modes

  • insert mode
  • command mode
  • visual mode

Cheatsheet

  • movement
  • buffers
  • cut/copy/paste

Files

Configuration

Plugins

Installing with Vundle
  • copy sample config for .vimrc from Github readme
  • to install a plugin from Github, include the ff. line in .vimrc (between call vundle#begin() and call vundle#end()):
    Plugin 'username/reponame'
        
  • after saving .vimrc, run :source % then :PluginInstall
  • restart Vim and check if plugin commands are working

Emacs 24

Cheatsheet

  • movement
  • buffers
  • cut/copy/paste

Modes

major

Examples:

  • dired - edit directories and the files within them
minor

Files

Configuration

init.el (.emacs for pre-Emacs 24)

Packages

How to install packages

Sample Rails development environment

Vim

Another sample config: Vim Config for Rails

Other plugins: 10 Vim plugins for Ruby

Note: Use tmux to get more mileage out of your shell

Emacs

Another sample config: Emacs Config for Rails

Note: Emacs on its own can act as a terminal multiplexer, but you can also integrate it with tmux using a package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment