Giter Site home page Giter Site logo

vimrc's Introduction

Lance's Vim Notes

[TOC]

This repo stores my most used bundles and tricks.

General

Scripts

  1. install.sh handles vim, tmux, terraformrc and bash_profile. It will install Homebrew, vim and jq by default.
  2. set-golang.sh handles all dependencies of vim plugin and environment setup. Since Go would set GOPATH to $HOME/go from version 1.8 hence we just put bin/ into our environment variable setup.
  3. set-php.sh is deprecated.

Take jq tutorial from here.

Bundle: Vim-go

As title, for golang.

:GoUpdateBinaries

Action Sub actions KeyMap Commands NOTE!
Next error in quickfix
Previous error in quick fix
Close quick fix a
Build b (build_go_files) run :GoBuild or :GoTestCompile based on the file we currently have
Test t :GoTest
:GoTestFunc
Coverage c :GoCoverageToggle
C :GOCoverageBrowser
Go Import :GoImport strings :GoImportAs str strings
Go Drop :GoDrop strings
Range, Inside the function if vif
Range, All the function at vaf, includes comment
GoAlternate Jump between go and go test file :GoAlternate :A :AV :AS :AT :AV vSplit :ASSplit :ATTab
Go To Definition d :GoDef
in Tab gt
Previous Tab gT
Navigation Jump to previous position
Jump to previous location
Open GoDef history :GoDefStack
Clear GoDef history :GoDefStackClear
Jump to previous function [[ v[[
Jump to next function ]] 3[[
Looking for declaration :GoDecls :GoDeclsDir :GoDeclsClear Required ctrlp
Looking for documentation K :GoDoc
Show identifier i :GoInfo auto_type_info
List package dependency files :GoFiles
List all dependency files :GoDeps
Find reference :GoReferrers
Show identifier advanced :GoDescribe
List interfaces the type is implementing :GoImplements
List possible error value of the type :GoWhicherrs
Describe channels :GoChannelPeers
Who been called as the function? :GoCallees
Who call the function? :GoCallers
List call stack from root :GoCallstack
Change guru scope :GoGuruScope :GoGuruScope ...
Refactory name :GoRename Change struct field
Detect Free Vars :GoFreevars Select a range...
AutoGen - Implement a :GoImpl Put your cursor on top of T :GoImpl io.ReadWriteCloser
:GoImpl b *B fmt.Stringer
let g:go_guru_scope = ["github.com/fatih/vim-go-tutorial"]
let g:go_guru_scope = ["..."]
let g:go_guru_scope = ["github.com/...", "golang.org/x/tools"]
let g:go_guru_scope = ["encoding/...", "-encoding/xml"]

Bundle: Struct Split and Join

package main

type Foo struct {
    Name    string
    Ports   []int
    Enabled bool
}

func main() {
    foo := Foo{Name: "gopher", Ports: []int{80, 443}, Enabled: true}
}
  • gS: Move your cursor at foo in #10, spit it into multiple line.
  • gJ: Move your cursor at foo, join it into oneline.

Bundle: Snippets

type foo struct {
    Message    string .
                      ^ put your cursor here
    Ports      []int
    ServerName string
}

In insert mode, type json and hit tab. You'll see that it'll be automatically expanded to valid field tag.

Bundle: AutoClose

Matching the counterpart when you're typing.

Bundle: Align

Help folks to align text, equals, declarations, tables, etc.

Usage:

  • <leader>t= Align assignments.
  • <leader>t, Align on commas.
  • <leader>tsp Align on whitespace.
  • <leader>acom Align comments.
  • <leader>Htd Align HTML tables.

Bundle: Commentary

Makes commenting out your code with ease!

Usage:

  • gcc Comments/uncomments one line
  • <Range>gc Comments/uncomments a visual range

Command:

  • :g/TODO/Commentary
  • :7,17Commentary

Bundle: Surround

Delete/change/add parentheses/quotes/XML-tags/much more with ease.

Usage:

  • Normal mode:
    • cs<$1><$2> Replace(c) surrounding(s) from $1 to $2.
    • cs'" Replace single quotes with double quotes.
    • cs'<q> Replace single quotes with tags.
    • cst" Replace tags with double quotes.
    • ds<$1> Delete(d) $1 surrounding.
    • ds" Delete surrounding double quotes.
    • yss<$1> Wrap entire line with $1.
  • Visual mode:
    • S<$1> Wrap with $1.
    • S<p class="foo">

Bundle: Vimux/vimux-golang

You have to step into Tmux and start vim before you can run/test golang code in Tmux panel.

Usage:

  • ra :GolangTestCurrentPackage
  • rw :GolangTestFocused

Bundle: vim-hjson

The zf operator not only creates a fold but also folds the text. To unfold, it press zo, and then zc closes the fold again. Mnemonics of this is also quite smart (:help usr_28). z looks like a folded piece of paper, and then o stands for "open", and c for "close".

There is also zM and zR to close / open all the folds in the file, no matter how deep. That's super useful with big files when you need to get an overview of the whole file.

And of course, let's not forget about za, which works like a toggle. When the cursor is on an open fold, it will close it and the other way around. I'm using it so often that I have it mapped to Space:

nnoremap <space> za

Notes

Vim-go has the functionality to go over the reference by using :GoReferrer but it just works for go language. There is another option we can use for the other languages, most are ruby and javascript.

https://github.com/eapache/starscope

scriptease.vim

The tool box for creating vim plugins.

vimrc's People

Contributors

lancekuo avatar lancekuo-newtopia avatar

Watchers

James Cloos avatar  avatar

vimrc's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.