My dotfiles utilizing Chezmoi for management https://www.chezmoi.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Ryan Reed b3a7b784fa Moving to vim-plug for plugin management 2 years ago
..
after/ftplugin Moving VIM to XDG location 3 years ago
spell Moving VIM to XDG location 3 years ago
README.md Moving to vim-plug for plugin management 2 years ago
vimrc Moving to vim-plug for plugin management 2 years ago

README.md

VIM

Note: Some features require version 8+ of vim. For instance, the ALE plugin which utilizes the built-in ~/.vim/pack/ for autoloading plugins

Table of Contents

Keybinding Shortcuts/Snippets

<v><e><y>       # select to end of word/variable and yank
<c><t><)>       # cut everything before )  [eg func(text-to-cut)]

Incrementing a column of numbers

<ctrl><v>       # Select all number columns to increment
<g><ctrl+a>     # If using tmux config, may need to hit a twice (e.g. <ctrl+a+a>

Plugins

Plugins are managed using vim-plug. vim-plug is downloaded automatically on first run.

To update the plugins, run PlugInstall

Below is a list of currently installed plugins:

  • Easymotion - Easily navigate documents Disabled recently as unused, although useful
  • Gruvbox - Retro colorscheme (colorscheme in vimrc)
  • Matchit - For expanding % matching (matches start/end tags for html, for example) Disabled recently as possibly unused
  • Lightline - Configurable statusline/tabline
  • Markdown TOC - A markdown Table of Contents generator
  • NERDCommenter - Quick commenting/uncommenting of lines
  • NERDTree - Local file explorer
  • python-syntax - Better syntax highlighting for python
  • Tabular - Easily align text based on delimeters (e.g. |)
  • surround.vim - Easily surround with delimeters (e.g. "Something")
  • IndentLines - View the indentations (<leader>i)
  • vim-rainbow - Different colors for different levels of brackets Disabled as interfers with spellcheck for some reason
  • UltiSnips - Snippets manager for vim
  • vim-snippets - Snippets for various languages

Keybindings

Leader Key: , (comma)

Shortcut Description Plugin
<leader><F3> Toggle wordwrap
<leader>bg Toggle dark/light background
<leader>h Disable search highlight
<leader>f<0-9> Set foldlevel (0-9)
<leader>i Toggle indent guides IndentLines
<leader>sp Toggle spellchecking (us-en)
Shortcut Description Plugin
- Comment out selected lines (filetype needs to be configured in vimrc for support) NERDcommenter
_ Uncomment selected lines (filetype needs to be configured in vimrc for support) NERDcommenter
<leader><F2> Remove trailing whitespace from file
<leader>a<delimiter> Accept various common delimiters for tabulizing blocks of code (e.g. varname = something, = being the delimiter) Tabular
<leader>d Add delimiters around entire line (normal mode) or selection (visual mode) vim-surround
<leader>j Pretty print json (current open file)
<leader>D Add delimiters around current word (normal mode) vim-surround
<leader>q Format a paragraph/line to better fit the textwidth
<leader>p Toggle paste mode
S) Add delimiters current selection vim-surround
cs<delimiter><delimiter> Replace a character with anothere charcter (e.g. cs"', or cs'<p class="test">) vim-surround
ds<delimiter> Remove a delimiter vim-surround
ysiw] Add delimiters around current word vim-surround
yss) Add delimiters around entire line vim-surround
Shortcut Description Plugin
% Find the end {}, [], or start/end tags (e.g. html) Base, Matchit
* Highlight all occurences of word under cursor (default in vim)
ff Display all occurences of word under cursor
cwd Change working dirctory to current file's
<leader>n Toggle NERDTree NERDTree
<leader>j Move to next linting error ALE
<leader>k Move to previous linting error ALE
Shortcut Description Plugin
<leader>sh Split horizontally
<leader>sv Split vertically
<leader>t Tab Next
<leader>T Tab Previous
<leader>w cycle through split windows
<leader><+> Resize horizontal pane (3/2)
<leader><-> Resize horizontal pane (2/3)
<leader><<> Resize vertical pane (3/2)
<leader><>> Resize vertical pane (2/3)
Shortcut Description Plugin
<leader><F4> Reload vimrc file
w!! Attempt to sudo and write to file

Snippets

Snippets have a few extra things to note:

  • Snippet Leader: <shortcut><tab> (e.g. class<tab>)
  • List Snippets: <ctrl-l>
  • Forward Through Snippet: <ctrl-j>
  • Backward Through Snippet: <ctrl-k>

You run the snippet completion while in insert mode.

A simple example: Type #!<tab> automatically inserts #!/usr/bin/env python

A more in depth example:

1. `class<tab>`
2. Start typing to provide name of class (already selected)
3. `<ctrl-j>` to move to the parent class (`class MyObject(<parent-object>):`)
4. `<ctrl-j>` to move to docstring
5. `<ctrl-j>` to move to inputs of the `__init__` function (typing a new input name automatically adds `self._varname = varname`)

Adding/Editing Custom Snippets

You can edit the snippets for the current filetype that's open by using :UltiSnipsEdit

After making any changes to the snippets, run :call UltiSnips#RefreshSnippets() to refresh the snippets

Important Note: If using chezmoi, make sure to copy the snippet to the chezmoi repo so it isn't overwritten during next chezmoi apply

Common Snippet Examples

These are taken from this article.

Go Snippets

All Go snippets. Also, see Ultisnips specific snippets

Snippet Trigger Description
fun Go function
fum Go Method
for Infinite for loop
forr Range based for loop
err Go Basic Error Handling
im Import Packages
pf fmt.Printf(…)
pl fmt.Println(…)
ps fmt.Sprintf(…)
om if key in map
if Go basic if statement
ife Go basic if/else statement
sw Switch statement
sl Go select for channels
ga goroutine anonymous function
test Go Test function
testt Go Table test function

Python Snippets

All python snippets. Also see Ultisnips specific snippets

Snippet Trigger Description
cl New Python class
dataclass Create a dataclass (Custom)
def New Python function definition
adef Python Async function definition
err Go Basic Error Handling
try Try/Except Block
trye Try/Except/Else Block
tryf Try/Except/Finally Block
tryef Try/Except/Else/Finally Block
" Python docstring
if Python basic if statement
el Python basic else statement
for Range based for loop
forkey Enumerate using key value of an interable (Custom)
lcp List comprehension

Markdown Snippets

All shell snippets. Also, see Ultisnips specific snippets

Snippet Trigger Description
* Italics text
** Bold text
/* Markdown/HTML Comment
cbl Code block
link or [ Markdown link
img or ![ Markdown image
tb Markdown Table
tbN,M Responsive Table
(tb12 creates a table with 1 row & 2 columns)