Some Vim Tips

  • Select previous visual block gv.
  • Profiling vim plugins or who is making my vim less-awesome

    Thanks https://stackoverflow.com/a/12216578/1805129

    :profile start profile.log
    :profile func *
    :profile file *
    " At this point do slow actions
    :profile pause
    :noautocmd qall!
    
  • Using As difftool
    • Once you are done with the merge, run :wqa to save all the windows and quit. If you want to abandon the merge instead, run :cq to abort all changes and return an error code to the shell. This will signal to Git that it should ignore your changes.
  • Diffget can also accept a range. If you want to pull in all changes from one of the top windows rather than working chunk by chunk, just run :1,$+1diffget {LOCAL,BASE,REMOTE}. The +1 is required because there can be deleted lines “below” the last line of a buffer.
  • The “patience” algorithm often produces more human-readable output than the default, “myers.” Set it in your .vimrc like so:
    if has("patch-8.1.0360")
        set diffopt+=internal,algorithm:patience
    endif
    
  • Going back in time: There’s always [u]ndo or you can use :earlier 2mto go back 2 minutes in time

  • Profiling who is making you vim slow:

    How to see which plugins are making Vim slow?

  • Search and replace everywhere:

    • :%s/foo/bar/g.
    • Replace the word under cursor everywhere in the buffer/file.

    Just use * and then:

    :%s//new value/
    
    

    If you don’t specify a pattern, the substitute command uses the last searched one.
    Depending on the value of gdefault in your configuration, you might need to add a /g modifier to that command.

    In Vim, replace all occurrences of current term under cursor

Rust

Leave a Reply