Vim Binaries for MacOSX. One Full-Stack Observability user. 100GB/mo telemetry data ingest. 100 million app transactions/mo and 1,000 incident events/mo in New Relic AI. I'm using Vim 8.1 from homebrew on MacOs 10.14.6. Whenever I exit vim back to the terminal, the first keypress in the terminal afterward results in a beachball and CPU spike to 100%, with terminal.
On Mac OS X (and Linux), vi is symlinked to vim (vi improved), a more modern free software version. Vim It is the default editor when changing a crontab.
If you gave vi a whirl and don't see the beauty of it, give the nano editor a try. It also ships with Mac OS X.
note: a chunk of this small guide came from a web page I found long ago, but I don't remember where so I can't give proper credit. I've added and changed things from the original text.
Mac Os Vim Syntax Highlighting
Vi has two modes, command and insert (really, three if you count replace mode). Command mode is used to navigate, search, and issue other commands. Insert mode is used to enter text.
Vi starts in command mode.
You can precede most commands with a number indicating how many times to perform a command. For example, entering 99 followed by the down arrow will move the cursor down 99 lines. '99x' will delete 99 characters.While in command mode (case sensitive)
- move the cursor with arrow keys; if there aren't any arrow keys, use j,k,h,l
- i - change to insert mode (before cursor)
- a - change to insert mode (after cursor)
- A - change to insert mode (at end of line)
- r - replace one character
- R - overwrite text
- x - delete one character
- dd - delete one line
- yy - yank line (copy)
- p - paste deleted or yanked text after cursor
- P - paste deleted or yanked text before cursor
- G - go to end of the file
- 1G - go to top of the file
- J - merge next line with this one
- / - search, follow / with text to find
- :wq - write file and quit
- :q! - quit without saving
- %s/old/new/g - substitute; replace 'old' with 'new' on all lines
- :g/pattern/d - delete all lines that match the pattern
- ESC - change to command mode
- any text typed is entered at the cursor
- Type 'vi file.txt' at command prompt
- Move cursor to where new text will be added
- Type 'i' to change to insert mode
- Type new text
- Type ESC to go back to command mode
- type ':wq' and ENTER to write the file and quit
All configuration options for vim are stored in the user’s home directory in a file named .vimrc
The script code is below but there are somethings you’ll want to do before setting it up.
You’ll need to create directories for the following: backups, colors, swaps and undo.
Execute this command to set up the directories in the terminal ( The ~ character will set the path to your home directory. ex: /Users/username/ ):
$ cd ~/.vim ; mkdir backups ; mkdir colors ; mkdir swaps; mkdir undo;
This will keep all your backups, swaps and undos in your .vim user directory. Also the colors directory is for installing themes.
Macos Vim Syntax Highlighting
Visit vimninjas.com if you would like to download a color scheme. Once you find a color scheme you like, just download it and copy and paste the code into the relevant scheme file and place the file in ~/.vim/colors/
For example if you download the Candy theme, you would name the file candy.vim and place it in the relevant directory described above. Then in your .vimrc config file you would set the theme like so:
I've created a github repo with the .vimrc configuration. Please take a look at the repo and download from here.
Checkout or download the git zip and setup the .vimrc file by using the cp command.
$ cd ~/Downloads/MacOSVimConfig-master
$ cp vimrc-example ~/.vimrc
Otherwise you can create your .vimrc file by copying the Raw text from github and pasting the text below. NOTE: While in vim before you paste try doing this command.
This should paste the text with the best result. Once the .vimrc file is configured open a new terminal windows and open a file to test out the setup.
$ vim ~/.vimrc
------------ .vimrc example configuration ------------------
Then paste in these configuration options: