• Stars
    star
    915
  • Rank 49,917 (Top 1.0 %)
  • Language
    Vim Script
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple, Modern MacVim Configuration

📢 Announcement: 📢

I have been working on a new version of vimbox that uses Atom/VSCode style json configuration and allows you to just drag a VimBox.app into your applications directory. Some good features:

  • Self contained .app (but still requires that you have MacVim installed).
  • .json based configuration.
  • When loading the app, it automatically pulls everything down from this repo.
  • It creates an isolated Vim environment that doesn't disturb your current ~/.vim/~/.vimrc. It is a different approach - better in my opinion. It really is "vim in a box" - a sandbox.
  • Also will work on terminal / Linux / Windows. Share your config across platforms. Json configuration can be platform specific settings.json vs. settings.linux.json, and settings.osx.gui.json etc. (no one click .app for linux/windows though, you need to create your own launcher).

Here is the branch that it lives at. Follow the instructions there to try it out.

Thank you for your patience while I have not been super responsive to issues on #master branch - it is because I have been working on the new #json branch linked above which should take the place of #master. Feedback appreciated.

VimBox

Modern MacVim Configuration
  • Mac Keyboard mappings
  • Familiar autocomplete behavior
  • JavaScript indentation and lint support
  • Snippets (with JavaScript examples)
  • Spacegray theme with matching app icon.

VimBox with Atom inspired one-dark theme.

VimBox's matching application icon

Installation:

Quickly try VimBox in place of your existing setup. Back up your existing vim files, and move them out of the way as instructed:

  1. If you already have a vim setup, move it safely out of the way or back it up.

     mv ~/.vim ~/.vim_backup    #No trailing slashes to preserve symlinks!
     mv ~/.vimrc ~/.vimrc_backup
     mv ~/.gvimrc ~/.gvimrc_backup
    
  2. You Must Install a Recent Version of MacVim: (with python support)

     # Alternatively, if you'd rather install via `brew`
     brew install macvim --with-cscope --python --HEAD
     brew linkapps    # Put the app in your /Applications directory
    
  3. Clone VimBox wherever you like to keep your github clones

     # cd ~/github/     # Or wherever you like to keep github clones
     git clone https://github.com/jordwalke/VimBox/
     ln -s `pwd`/VimBox/dotVim ~/.vim      # Link to the cloned vim config
     ln -s `pwd`/VimBox/dotVimRc ~/.vimrc
     ln -s `pwd`/VimBox/dotGVimRc ~/.gvimrc
    
  4. Start MacVim that you just installed. It will prompt you to download the plugins in the background. If you opt to do so, it may take a while to startup but be patient.

  5. [Recommended] Install the included vim-airline font so VimBox looks like the screenshot with the vim-airline bar. From the command line:

     open ./VimBox/dotVim/Fonts/InconsolataDz/Inconsolata-dz\ for\ Powerline.otf # Then click "Install Font"
    
  6. Install up-to-date node.js if you want JS linting (http://nodejs.org/)

  7. Make your MacVim use the VimBox icon (optional):

open /Applications/
# Find the MacVim app icon and press `⌘+i` to open the information window
open ./dotVim/images
# drag the ApplicationIcon.icns onto the little icon in the information window
# and restart MacVim.

Features:

Familiar Mac Key Commands

Key Action
⌘+p Open Anything (ctrl-p)
⌘+n New Tab
⌘+shift+n New Window
⌘+shift+t Reopen Last Closed Tab
⌘+w Close tab/split: Opens to the left (like Sublime) not right (like vim)
⌘+s Save file
⌘+z Undo
⌘+shift+z Redo
⌘+enter Special Distraction-Free FullScreen Mode
⌘+\ Toggle File Explorer (Docked NERDTree)
⌘+shift+\ Find current file in file explorer
^+\ Toggle focus between file explorer
⌘+shift+[ / ⌘+shift+] Go to previous/next tab
^+tab / ^+shift+tab Go to previous/next tab (in normal Vim mode)
⌘+1 Go to tab 1
F5 Sort lines (like Textmate)
⌘+/ Toggle comments - selected range - or line
⌘+shift+c format/indent entire file then restore cursor
⌘+d Toggle Diagnostics (errors in location list)
⌘+D Toggle QuickFix list
⌘+r "Run" - invokes pwd/runFromEditor.sh

The file browser shortcuts are carefully setup so that when you use the shortcuts for opening/closing/toggling-focus, the window positions will not be resized. Make sure to use ^+\ if you want to jump back and forth between the file tree and your editor - it will remember the editor you were last in, and not disturb window positions (just like Atom or other modern editors).

Mega Escape

  • VimBox has mapped ^+l to exit out of any modal window/prompt/mode/command to bring you back to normal Vim navigation mode.
  • It's like the home button on the iPhone.
  • Unlike regular <Esc>, mega-escape doesn't move your cursor when escaping.
  • Remap CapsLock to control and never reach for Escape again. Hit the CapsLock key and l right on the home row.
Key Action
^+l Mega Escape

Airline/Spacegray

VimBox includes vim-airline and Spacegray color scheme.

Braces and Pairs

  • Inserting {, [, ', or " automatically inserts the closing character.
  • When hitting enter with the cursor between two braces {|} the newline is formatted with an extra indentation.
  • The behavior is identical to Sublime/Textmate.

AutoComplete/Snippets

  • Completions pop up automatically.
  • Like Sublime, VimBox accepts highlighted entries via tab or enter.
  • tab also triggers a snippet when applicable, and tab will allow "tabbing" through the snippet placeholders.
  • Place custom snippets in ~/.vim/myUltiSnippets/
  • If the completion window is open and you want to insert a newline instead of inserting the completion, press shift+enter or control+enter.

Distraction Free UI Tabs

  • When not in full screen mode, Mac style metalic tabs are used.
  • When in full-screen mode, those tabs become flat and blend into the background so you can focus on the code.

One File, One Location

Included plugins are configured so that opening a file will always focus the window/tab/split where that file is already open. This is how most modern editors work.

Many Plugins, One Interaction Language

Multiple plugins (ctrl-p and NERDTree) have been configured so that they have consistent keyboard mappings. For example, s represents the notion of a "vertical split", and h represents horizontal in both plugins (though one plugin might require a ctrl modifier in some cases.)

Command-P Search Window

The ctrl-p plugin has been configured to "do the right thing", which means searching for some combination of recently used files and/or the contents under the current working directory. It caches the results, but if you open it from your home directory, it could take a while to scan your entire directory.

Key Action
⌘+p Open Anything and begin searching for file
enter While searching, opens the top hit in new tab or jump to existing window if already open
c-s While searching, opens the top hit in a vertical split or jump to existing window if already open
c-h While searching, opens the top hit in horizontal split or jump to existing window if already open
⌘+shift+c While searching, refreshes the search results if files have changed on disk
ctrl+c Kills a slow search

NERDTree

NERDTree is included and is configured to act as a left-nav bar (toggle it via ⌘+e). Its keymappings have been configured to be consistent with the ctrl-p plugin.

Key Action
⌘+e Toggle side bar file explorer
⌘+E Reveal current file in side bar file explorer
j/k While explorer focused, move up and down
enter While explorer focused, opens a file in new tab or jump to existing window if already open
s While explorer focused, opens a file in a vertical split or jump to existing window if already open
h While explorer focused, opens a file in horizontal split or jump to existing window if already open
u While explorer focused, Move up a directory
o While explorer focused, Expand a subdirectory
CD While explorer focused, Make the file explorer's directory equal to Vim's cwd
cd While explorer focused, make Vim's cwd equal to the directory under the cursor
m While explorer focused, show complete menu of possible commands to execute

Tabs And Splits Navigation

Jump around quickly to the next tab or split with a single key press. Go back the other direction by pressing shift.

Key Action
⌘+shift+h, ⌘+shift+l While in Vim's normal mode - focus split to the left or right
⌘+shift+j, ⌘+shift+k While in Vim's normal mode - focus split to the top or bottom (not in diff mode)
⌘+shift+j, ⌘+shift+k While in Vim's normal mode - and diff mode, go to next / previous changes
⌘+shift+p While in Vim's normal mode - focus previously focused tab
Space/shift+Space While in Vim's normal mode - go to next/preious tab
tab/shift+tab While in Vim's normal mode - go to next/previous split

####JavaScript Development

JavaScript Linting

  • Excellent JavaScript indenting and inline linting with support for JSX.
  • Syntax error highlighting via Syntastic.
  • Type error highlighting via flow. Just have flow installed on your path, and type/syntax errors will be underlined in red. As always, hit ⌘+l to toggle the summary of the file's errors.

JavaScript Snippets

  • JavaScript snippets are include, but you can add your own for any language you like
Key Action
for tab for loop
if if statement
forin tab for-in loop
fun tab function definition
lam tab Lambda function
try tab try/catch
log tab console.log
logo tab Log stringified object to console
tag tab JSX tag <typeHere att={}></typeHere>
logo tab Many more including ReactJS helpers

JavaScript DocBlock Generator

The following key mapping generates docblock comments. <tab> will select the parameters in the generated docblock so you can edit the descriptions/types. Works with ES6 functions.

Key Action
⌘+shift+i Generate JS Docblock - when cursor is above a function

Git Integration:

Setup DiffTool:

Any result of a git diff command can be viewed in a side-by-side diff view inside of MacVim. All of your familiar vim key commands work while browsing your diff. Place this in your ~/.gitconfig:

    [diff]
        tool = default-difftool
    [difftool "default-difftool"]
        cmd = "~/.vim/mvimgitdiff.sh " $LOCAL $REMOTE

Now you can use the git difftool command exactly like you use git diff, but a MacVim window will appear:

Setup MergeTool:

Resolving merge conflicts is simple with MacVim. Just put this in your ~/.gitconfig.

    [mergetool]
      prompt = false
      # See bashrc for exporting the editor across all apps, not just git.
    [mergetool "mvimdiff"]
      cmd="/Applications/MacVim.app/Contents/MacOS/Vim -g -f '+windo set diff scrollbind scrollopt+=hor nowrap' -c 'Gdiff' $MERGED -c 'au VimLeave * !open -a iTerm'"
      # cmd="mvim -c 'Gdiff' $MERGED"     # use fugitive.vim for 3-way merge
      keepbackup=false

    [merge]
      tool = mvimdiff

Now, git mergetool will resolve rebase and merge conflicts directly inside of MacVim.

Setup Commit Message Editor:

Make sure to tell your shell that MacVim is the way that you'd like to edit commit messages. This special command will ensure that when you close your MacVim window, you will return back to the command line iTerm. Replace with your shell rc file and terminal app name.

echo export EDITOR='mvim -f --nomru -c "au VimLeave * !open -a iTerm"' >> ~/.bashrc
echo export GIT_EDITOR='mvim -f --nomru -c "au VimLeave * !open -a iTerm"' >> ~/.bashrc

Plugin System:

VimBox achieves its features through configuration of several plugins, but those should be considered implementation details of the VimBox distribution. VimBox uses modern editors as a "spec" for features and will configure several plugins in order to conform to that spec.

  • You can add any plugin you like using the Plug command.
  • Add custom plugins using the Plug command inside ~/.vim/bundlesVimRc.custom.
  • Customize ~/.vim/vimrc.custom.before to configure Vim before any of the bundles are loaded, and customize ~/.vim/vimrc.custom.after to configure Vim after plugins are loaded.

Customizing:

In ~/.vim/vimrc.custom.before/~/.vim/vimrc.custom.after you may set any options you like. (See "Plugin System" section above).

VimBox will look to see if you have defined the following variables defined in your ~/.vim/vimrc.custom.before:

Key Behavior
let g:textColumns = 82 Set text wrapping width
let g:tabSize = 2 Set tab width

Using VimBox's configuration from NeoVim

mkdir ~/.config
ln -s ~/.vim ~/.config/nvim
ln -s ~/.vimrc ~/.config/nvim/init.vim

License:

See the license file included. Any dependencies that are included in VimBox may have their own license. In the event any dependency is include in VimBox, an attempt has been made to also include its corresponding license in the directory containing that licensed work.

Origins:

See ./ORIGINS.md.

More Repositories

1

flex

Reason CSS Flexbox implementation
Reason
389
star
2

FaxJs

Fax Javascript Ui Framework
JavaScript
375
star
3

one-click.js

One Click, Offline, CommonJS Modules in the browser
JavaScript
332
star
4

rehp

ReHp
OCaml
222
star
5

paradoc

One Click Docs
JavaScript
179
star
6

pesy

Builds simple esy native packages with minimal configuration.
Shell
114
star
7

flatlandia

Vim colorscheme based on flatland with Airline integration.
Vim Script
113
star
8

vim-reasonml

esy + vim + reason +the latest Merlin
Vim Script
108
star
9

CommonML

Simple OCaml Development Workflow on CommonJS
CSS
96
star
10

reason-project-ideas

ReasonML Projects That People Have Expressed Demand For.
86
star
11

navigating-reason

Overview of Reason tooling options for the curious.
70
star
12

reactapp

Starter App For React and CommonJS
JavaScript
51
star
13

esy-issues

Easy ISSUES
JavaScript
49
star
14

vim-taste

Colors based on elementaryOS
Vim Script
34
star
15

reasonml-manual

ReasonML Manual
HTML
33
star
16

native-reason-react-roadmap

Public design discussion about various approaches to building Native Reason React.
24
star
17

PackageJsonForCompilers

Proposal for allowing compiled languages to use the package.json sandbox model
24
star
18

VimCompleteLikeAModernEditor

Make Vim complete like a modern editor - does the right thing. Works with Ultisnips and neocomplete.
Vim Script
23
star
19

reason-wall-demo

Wall (NanoVG port) demo converted to Reason.
OCaml
15
star
20

VimSplitBalancer

Vim Script
14
star
21

common-native-reason-issues

Common Issues When Developing Native Reason Projects
13
star
22

effective-esy-packaging

Effective Esy Packaging Guide
12
star
23

VimCleanColors

Collection of Clean Vim ColorSchemes With Airline Themes
Vim Script
11
star
24

moodules

OO style Libraries for Dune
Reason
8
star
25

file-driven-development

Utilities for a stateless, serverless development environment.
8
star
26

VimJSXHint

Inline JSHint error highlighting with support for JSX
JavaScript
7
star
27

moodules-demo

Demo of virtual libraries implemented in user space.
JavaScript
5
star
28

esy-pesy-starter

Starter example using pesy
C++
3
star
29

refmt-as-ocp-indent

A quick workaround for Nuclide LSP bridge
Shell
3
star
30

VimAutoMakeDirectory

Asks to create directories in Vim when needed
Vim Script
3
star
31

VimJSDocSnippets

Automatically create JSDoc comments for functions using UltiSnips for Vim
Vim Script
3
star
32

create-reason

Esy template for Reason Projects.
3
star
33

VimCloser

Make Vim close tabs the way every other editor does - by switching to the next tab to the left.
Vim Script
2
star
34

atom-reason

CoffeeScript
2
star
35

npm-react-core

NPM build of Facebook's React JavaScript framework.
JavaScript
2
star
36

crayon

Vim Colorscheme Generator
1
star
37

CommonMLAnotherExampleDependency

Another example dependency for https://github.com/jordwalke/CommonML
OCaml
1
star
38

MacVimSmartGUITabs

Shows GUI tabs only when not in fullscreen mode.
Vim Script
1
star
39

VimLastTab

Switch to the most recently used Tab
Vim Script
1
star
40

EditorsWithVimMode

List and summaries of editors that support vim mode. Brief evaluations of completeness.
1
star
41

CommonMLExampleDependency

Example dependency for https://github.com/jordwalke/CommonML
OCaml
1
star