Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Navigating in VIM

Navigating in VIM

michaelavila

October 14, 2015
Tweet

More Decks by michaelavila

Other Decks in Programming

Transcript

  1. :help quickfix In vim the quickfix commands are used more

    generally to find a list of positions in files.
  2. :help location-list A location list is similar to a quickfix

    list and contains a list of positions in files.
 … A location list is associated with a window and each window can have a separate location list.
 … The location list is independent of the quickfix list.
  3. QUICKFIX: SYNTAX ERRORS autocmd FileType ruby nmap <buffer> <leader>sc 


    :cexpr system (‘ruby -c ‘ . bufname(“%”))<cr>
  4. QUICKFIX: TESTS autocmd FileType ruby nmap <buffer> <leader>tf 
 :cexpr

    system (‘rspec 
 -r ./spec/support/quickfix_formatter.rb 
 —format RSpec::Core::Formatters::QuickfixFormatter ’ 
 . bufname(“%”))<cr>
  5. QUICKFIX: TESTS require 'rspec/core/formatters/base_text_formatter' module RSpec module Core module Formatters

    class QuickfixFormatter < BaseTextFormatter RSpec::Core::Formatters.register self, :example_failed def initialize(output) @output = output end def example_failed(notification) @output << format(notification) + "\n" end def format(notification) fmt = "%s: %s" % [notification.example.location, notification.exception.message] fmt.gsub("\n", ' ')[0,160] end end end end end http://git.io/vCwCw
  6. :help tags A tag is an identifier that appears in

    a “tags” file. It is a sort of label that can be jumped to. … The “tags” file has to be generated by a program like ctags, before the tag commands can be used. CTAGS
  7. :help mark Set mark {a-zA-z} at cursor position 
 (does

    not move the cursor, this is not a motion command). m{a-zA-Z} MARKS
  8. :help ‘[ ‘. jump to position where last change occurred

    in buffer ‘“ jump to position where last exited current buffer ‘0 jump to position in last file edited (when exited vim) ‘1 like ‘0 but the previous file (also ‘2 etc) ‘’ jump back to line `` jump back to position ‘[ or ‘] jump to beginning/end of changed or yanked text ‘< or ‘> jump to beginning/end of last visual selection SPECIAL MARKS