Vim and Macvim

From CMEE4K
Jump to navigation Jump to search

Installation

Windows

Go to https://www.vim.org to download gvim_8.2.####_x86_signed.exe installation file.

Mac

Go to https://macvim-dev.github.io/macvim/ to download MacVim pkg file.

Add the vim into PATH

Windows

The Vim installer will add the %VIM_EXE_DIR% and the path into system %PATH%. The normal installation path is c:\Program Files (x86)\Vim (Let call this MVIM_HOME. This directory has all .vimrc files).
You can manually adding the vim into the environment variable

  • Start Control Panel > System (pop-up window) > search "edit system environment variables"
  • In Advance System Setting window: Edvironment Variables
    • Edit and Add (for example) c:\Program Files (x86)\Vim\vim81 into PATH variable.

Mac

MacVim installer only copy MacVim.app into Application directory, but it does not add the path into user's .profile file. To enable command line to use mvim command:

  • cd $HOME
  • vi .profile
    • Find the PATH line. Add this new line before PATH line: MVIM_HOME=/Applications/MacVim.app/Contents
    • Add MVIM_HOME into PATH line: PATH=$MVIM_HOME/bin:...

Gvim configuration file

For Windows, find out the _vimrc and _gvimrc files location

  • Start vim, enter :version and :echo $HOME
  • The normal setup, the $HOME is c:\Users\{UID}
  • Edit $HOME\_gvimrc file.

For Mac, it is user HOME directory, just 'cd' to switch back to $HOME directory.

  • Edit $HOME/.gvimrc

.gvimrc file

set columns=120 lines=50
syntax on
hi Normal guibg=lightgreen guifg=black
""" Windows: hi Normal guibg=darkgreen guifg=black
set bg=dark bs=2 cin ek hid paste ru sm sta sw=4 ts=8
""" Windows: set bs=2 cin ek hid paste ru sm sta sw=4 ts=8
set number
set hlsearch

" From https://github.com/macvim-dev/macvim/wiki/FAQ
set guifont=Monaco:h16
""" Windows: set guifont=Consolas:h14:cANSI
set guioptions+=T

" Setting from
"   https://www.programmersought.com/article/46274365900/
"
set showtabline=1               "Hide the top tab bar"
set guioptions+=r               "Hide the right scroll bar" 
set guioptions+=L               "Hide the left scroll bar"
set guioptions+=b               "Hide bottom scroll bar"
set cursorline                  "Highlight the current line"
set cursorcolumn                "Highlight current column"

set tabstop=3
set shiftwidth=3                "How many spaces are indented at each level
set backspace+=indent,eol,start "set backspace& can reset it
set showmatch                   "Show matching brackets"
set scrolloff=5                 "5 lines from top and bottom"
set laststatus=2                "The command line is two lines"

set ignorecase                  "Ignore case"

My vim command reminder

vim has lot of commands, press F1 to see the topic level of help. The following is only my reminder.

Only my vim command reminder
Split vertical Ctrl-W v, or :vsp
Split and reverse :sp top, only
Change window and size Ctrl-W twice, Ctrl-W +/-
Block mode v, V, Ctrl-v
Marking to 'm' mm
Yank to 'm' y'm
Delete to 'm' d'm