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

VIM: efficient code search and pretty-printing

Miklos V
September 26, 2013
250

VIM: efficient code search and pretty-printing

Miklos V

September 26, 2013
Tweet

Transcript

  1. VIM: efficient code
    search and pretty­
    printing
    Miklós Vajna
    2013­09­26

    View Slide

  2. 2 / 6 LibreOffice Conference 2013 | Miklós Vajna
    Offline code search
    ● git grep, of course
    ● Though ctags / id­utils is better
    ● 'make tags' after 'make'
    ● Builds a database of symbols
    ● A 'string file:lineno' map

    ● One­time config in your vimrc

    View Slide

  3. 3 / 6 LibreOffice Conference 2013 | Miklós Vajna
    How to use ctags?
    ● Place the cursor on a symbol:
    ● Ctrl­] jumps to the symbol (first hit in the db)
    ● Ctrl­t jumps back in the stack
    ● Explicit search:
    ● :ts Class, then you can choose from the results
    ● :ts Class::Method also works
    ● So that you can stop remembering file
    names :­)

    View Slide

  4. 4 / 6 LibreOffice Conference 2013 | Miklós Vajna
    fugitive.vim
    ● Maps ':Gfoo' to 'git foo'
    ● Most useful: :Gblame
    ● Runs 'git blame'
    ● Jumps directly to the line where your cursor
    was before you ran ':Gblame'

    View Slide

  5. 5 / 6 LibreOffice Conference 2013 | Miklós Vajna
    Pretty­printing in general
    ● XML, RTF
    ● Tolerate if the input is not well­formed!
    ● xmllint can't do that
    ● Provide a general 'prettyprint' tool that does the
    right thing
    ● Vim can be configured to run pretty­print in­place
    ● Can be even combined with in­place ZIP editing

    View Slide

  6. 6 / 6 LibreOffice Conference 2013 | Miklós Vajna
    formatxml, formatrtf
    ● formatxml:
    ● Initially created by Lubos
    ● Formats the XML input without parsing it
    ● Handles not well­formed XML properly
    ● formatrtf:
    ● Something similar for RTF
    ● Instructions: TDF Wiki /Development/Vim

    View Slide