Slide 1

Slide 1 text

NAVIGATING IN VIM FOR PROGRAMMERS

Slide 2

Slide 2 text

BEYOND THE BASICS SOME ASSEMBLY REQUIRED

Slide 3

Slide 3 text

OVERVIEW • documentation • quickfix • ctags • marks

Slide 4

Slide 4 text

DOCUMENTATION

Slide 5

Slide 5 text

DOCUMENTATION: MAN K

Slide 6

Slide 6 text

DOCUMENTATION: VIM autocmd FileType vim setlocal keywordprg=:help

Slide 7

Slide 7 text

DOCUMENTATION: RUBY autocmd FileType ruby setlocal keywordprg=ri

Slide 8

Slide 8 text

QUICKFIX

Slide 9

Slide 9 text

:help quickfix In vim the quickfix commands are used more generally to find a list of positions in files.

Slide 10

Slide 10 text

: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.

Slide 11

Slide 11 text

QUICKFIX: MAPPINGS map cn :cnext map cp :cprev map co :copen map cc :ccl

Slide 12

Slide 12 text

QUICKFIX: INSTALL GREP • brew tap homebrew/dupes • brew install —with-default-names grep

Slide 13

Slide 13 text

QUICKFIX: SEARCH RESULTS nmap fw :grep -r .

Slide 14

Slide 14 text

QUICKFIX: SYNTAX ERRORS autocmd FileType ruby nmap sc 
 :cexpr system (‘ruby -c ‘ . bufname(“%”))

Slide 15

Slide 15 text

QUICKFIX: LINTERS autocmd FileType ruby nmap li 
 :cexpr system (‘rubocop ‘ . bufname(“%”))

Slide 16

Slide 16 text

QUICKFIX: TESTS autocmd FileType ruby nmap tf 
 :cexpr system (‘rspec 
 -r ./spec/support/quickfix_formatter.rb 
 —format RSpec::Core::Formatters::QuickfixFormatter ’ 
 . bufname(“%”))

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

QUICKFIX: LOGGING Integrating with Quickfix

Slide 19

Slide 19 text

CTAGS

Slide 20

Slide 20 text

CTAGS: INSTALL brew install ctags

Slide 21

Slide 21 text

: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

Slide 22

Slide 22 text

CTAGS: MAPPINGS set tags=.ctags;$HOME nmap tt :execute “!ctags -R -f ./.ctags .” nmap gd nmap gb

Slide 23

Slide 23 text

MARKS

Slide 24

Slide 24 text

A mark is some position in some file that can be motioned to. MARKS

Slide 25

Slide 25 text

: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

Slide 26

Slide 26 text

Local: m{a-z} Global: m{A-Z} MARKS: LOCAL AND GLOBAL

Slide 27

Slide 27 text

:help mark ` (backtick): `{a-zA-Z} ‘ (single quote): ’{a-zA-Z} MARKS: JUMPING

Slide 28

Slide 28 text

: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

Slide 29

Slide 29 text

–Johnny Appleseed “Type a quote here.” END TRANSMISSION

Slide 30

Slide 30 text

janko-m/vim-test
 powerman/vim-plugin-viewdoc
 scrooloose/syntastic
 xolox/vim-easytags
 michaelavila/see-note