Skip to content

mattpage/vimfiles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vim setup

requirements

  • neovim
  • Homebrew or Linuxbrew

install vim-plug

use vim-plug for installing plugins and runtime files.

mkdir -p ~/.vim/autoload ~/.vim/backup ~/.vim/bundle ~/.vim/colors
cp -r ./vim/ ~/.vim/
cp -r ./config/ ~/.config/

install dotfiles

cp .vimrc ~
cp .ctags ~

install vim plugins

Open nvim and run :PlugInstall

install fzf and ripgrep

fzf is a command-line fuzzy finder. It is a replacement for ctrl+p.

git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install

use ripgrep for searching since it supports ignoring directories like 'node_modules'

brew install ripgrep

or see ripgrep installation

then add the following to ~/.fzf.bash or ~/.fzf.zsh

# set fzf source to ripgrep and ignore some dirs
# see https://github.com/junegunn/fzf#respecting-gitignore
export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow -g "!{.git,node_modules,coverage}/*" 2> /dev/null'

install ctags

#macos
brew install universal-ctags

#linux
sudo apt install universal-ctags

remap capslock

To map capslock to ctrl, add this to .bashrc

#linux
setxkbmap -layout us -option ctrl:nocaps

language support

C/C++

brew install cppcheck
brew install clang-format

go

brew install go

In vim, type

:GoInstallBinaries

javascript

npm install eslint --save-dev
eslint --init
npm install prettier-eslint --save-dev

ruby

For ruby linting, make sure rubocop is on your path.

yaml

brew install yamllint

key mappings and commands

'jj'      leave insert mode (same as esc)
'v'       leave visual mode
'esc+esc' no highlight
'\s'      save
'ctrl+d'  scroll down
'ctrl+u'  scroll up
'\rtw'    remove trailing whitespace
'\rts'    remove trailing whitespace
'\cp'     copy the file path of the current buffer to the clipboard
']q'      next item in quickfix
'[q'      prev item in quickfix

a.vim

'\o'    toggle between source and header file
'\os'   toggle and open in a split
'\ov'   toggle and open in a vertical split
'\ot'   toggle and open in a tab

buffer and bufexplorer

'\be'       open buffer explorer (normal)
'\bs'       open buffer explorer (horiz split)
'\bv'       open buffer explorer (vert split)
'\bf'       buffer forward
'\bb'       buffer back
'\bn'       buffer next
'\bp'       buffer previous
'\bc'       buffer close - deletes buffer w/o closing window
'\bd'       buffer delete - same as above
'\buf'      same as :buf commands below.
':buf file' autocomplete filename with <Tab>
':buf + n'  where n is the buffer number

window commands

'Ctrl-W H'          Moves the cursor to the left window
'Ctrl-W J'          Moves the cursor to the window below
'Ctrl-W K'          Moves the cursor to the window upper
'Ctrl-W L'          Moves the cursor to the right window
'Ctrl-W V'          Opens a new vertical split
'Ctrl-W S'          Opens a new horizontal split
'Ctrl-W C'          Closes a window
'Ctrl-W O'          Makes the current window the only one on screen and closes other windows
'Ctrl-W V'          Opens a new vertical split
'Ctrl-W S'          Opens a new horizontal split
'Ctrl-W C'          Closes a window
'Ctrl-W O'          Makes the current window the only one on screen and closes other windows
':vsplit filename'  Split window vertically
':split filename'   Split window horizontally
':new filename'     Create new window

nerdtree

'\n'      toggle nerdtree

tagbar

'\tt' Toggle Tagbar

fzf

'\fb'     fuzzy find buffers
'\fc'     fuzzy find git commits
'\ff'     fuzzy find files
'\fl'     fuzzy find lines
'\ft'     fuzzy find tags
# fzf search syntax
foo       Fuzzy match (default)
^foo      Starts with 'foo'
bar$      Ends with 'bar'
'baz      Must Include the term 'baz'
'baz'     Matches 'baz' at word boundary
foo|bar   Logical OR operator. Matches 'foo' or 'bar'
!baz      Inverse exact match. Items that do not include 'baz'
!^foo     Inverse starts with. Items that do not start with 'foo'
!bar$     Inverse ends with. Items that do not end with 'bar'

ripgrep

':Rg'     <string|pattern>
':RgRoot' show root search dir

find/replace all

'/fr'     Prompts for Find/Replace text then does a ripgrep search followed by 'cfdo %s/<find>/<replace>/gc | update'

bookmarks

'mm'   Add/remove bookmark at current line
'mi'   Add/edit/remove annotation at current line
'mn'   Jump to next bookmark in buffer
'mp'   Jump to previous bookmark in buffer
'ma'   Show all bookmarks (toggle)
'mc'   Clear bookmarks in current buffer only
'mx'   Clear bookmarks in all buffers

session commands

'\ss'  Start a session
'\sr'  Restore a session
'\sp'  Pause a session
'\sx'  Destroy a session

snipmate commands

'\vv'  Insert
'\vb'  Back
'\vs'  Show available snippets based on previous text

JSON commands

':PrettyPrintJSON'  Prettify JSON
':PrettyJSON'       Alias to above
':PrettyJson'       Alias to above
':FormatJSON'       Alias to above
':FormatJson'       Alias to above

Treesitter mappings

# Motions
']m'	next function start
'[m'	previous function start
']M'	next function end
'[M'	previous function end
']]'	next class/module start (class in Ruby, type/interface in Go, class in JS, struct in C)
'[['	previous class/module start
']['	next class/module end
'[]'	previous class/module end

# Text Objects
'vaf'	around function
'vif'	inside function
'vac'	around class/module (Ruby: class/module; Go: type; JS: class; C: struct/union)
'vic'	inside class/module
'vab'	around block ({ ... } or do/end in Ruby)
'vib'	inside block
'vap'	around parameter list
'vip'	inside parameter list
'vas'	around statement (if, for, return, etc.)
'vis'	inside statement

# Incremental Selection
'gnn'	start Treesitter selection at cursor
'grn'	expand to next node
'grc'	expand to outer scope (function/class/module)
'grm'	shrink selection

resources

About

my vim configuration and files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published