Skip to content

Instantly share code, notes, and snippets.

@psygo
Created February 18, 2021 01:37
Show Gist options
  • Save psygo/e1a80f6688ed343a16adfd094b48da2e to your computer and use it in GitHub Desktop.
Save psygo/e1a80f6688ed343a16adfd094b48da2e to your computer and use it in GitHub Desktop.
Do 90% of What Vim Plugins with Only Vim
set hlsearch
" Don't bother with pretending that it wants to be compatible with Vi
set nocompatible
" Enable syntax and plugins (for netrw)
syntax enable
filetype plugin on
" Finding Files:
" Search down into subfolders:
" Provides tab-completion for all file-related tasks
set path+=**
" Display all matching files when we tab complete
set wildmenu
" Now we can
" - Hit tab to :find by partial match
" - Use * to make it fuzzy
" - ** means recursive find
"
" Things to consider:
" - :b lets you autocomplete any open buffer
" - :ls mentions all of the files
" - :b <any_file_identifier>
" TAG JUMPING
" Create the `tags` file (may need to install ctags first)
command! MakeTags !ctags -R .
" Now we can:
" - Use ^] to jump to tag under cursor.
" - Use g^] for ambiguous tags
" - Use ^t to jump back up the tag stack
" Things to consider:
" - This doesn't help if you want a visual list of tags
" Use `:echo expand("%")` to get the current file name
" Autocomplete:
"
" The good stuff is documented in |ins-completion|
"
" Highlights:
" - ^x^n for JUST this file
" - ^x^f for filenames (works with our path trick!)
" - ^x^] for tags only
" - ^n for anything specified by the 'complete' option
"
" Now we can:
" - Use ^n and ^p to go back and forth in the suggestion list
"
" File browsing:
"
" Tweaks for browsing
let g:netrw_banner=0 "disable annoying banner
let g:netrw_browse_split=4 "open in prior window
let g:netrw_altv=1 "open splits to the right
let g:netrw_liststyle=3 "tree view
let g:netrw_list_hide=netrw_gitignore#Hide()
let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+'
" Now we can:
" - :edit a folder to open a file browser
" - <CR>/v/t to open in an h-split/v-split/tab
" - check |netrw-browse-maps| for more mappings
"
" Use for example `:edit <filename>` to open files in a tree
"
" Snippets
"
" Read an empty HTML template and move cursor to title
nnoremap ,html :-1read $HOME/.vim/.skeleton.html<CR>3jwf>a
"<CR> is carriage return, without it we would simply type the command into
"command mode
"3jwf>a is how you end up with the cursor in a specific spot, using Vim
"commands
"nnoremap is so there is no recursive invocation of ,html
"-1 in the read command is so it doesn't add a boilerplate line when it adds
"the snippet
" Now we can:
" - Take over the world!
" (with much fewer keystrokes)
"
" Build Integration:
"
" Steal Mr. Bradley's formatter & add it to our spec_helper
" http://philippbradley.net/rspec-into-vim-with-quickfix
"
" Configure the `make` command to run RSpec
set makeprg=bundle\ exec\ rspec\ -f\ QuickfixFormatter
" Now we can:
" - Run :make to run RSpec
" - :cl to list errors
" - :cc# to jump to error by number
" - :cn and :cp to navigate forward and back
"
" Help:
"
" Use :help ^n to show everything Ctrl + n does in Vim.
" Or :help i_^n for insert mode
" :help c_^n
" :helpgrep
"
" He uses
" - Vundle
" - Nerdtree
set clipboard=unnamedplus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment