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
, andsettings.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.
Modern MacVim Configuration |
|
VimBox with Atom inspired one-dark theme.
VimBox's matching application icon
Quickly try VimBox in place of your existing setup. Back up your existing vim files, and move them out of the way as instructed:
-
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
-
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
-
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
-
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. -
[Recommended]
Install the included vim-airline font soVimBox
looks like the screenshot with thevim-airline
bar. From the command line:open ./VimBox/dotVim/Fonts/InconsolataDz/Inconsolata-dz\ for\ Powerline.otf # Then click "Install Font"
-
Install up-to-date node.js if you want JS linting (http://nodejs.org/)
-
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.
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).
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 theCapsLock
key andl
right on the home row.
Key | Action |
---|---|
^+l |
Mega Escape |
VimBox
includes vim-airline
and Spacegray
color scheme.
- 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.
- Completions pop up automatically.
- Like Sublime,
VimBox
accepts highlighted entries viatab
orenter
. tab
also triggers a snippet when applicable, andtab
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
orcontrol+enter
.
- 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.
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.
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.)
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
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 |
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
- Excellent JavaScript indenting and inline linting with support for
JSX
. - Syntax error highlighting via Syntastic.
- Type error highlighting via
flow
. Just haveflow
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 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 |
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 |
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:
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
.
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
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.
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 |
mkdir ~/.config
ln -s ~/.vim ~/.config/nvim
ln -s ~/.vimrc ~/.config/nvim/init.vim
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.
See ./ORIGINS.md.