ciplogic.com
Live with grace. Write superb software.

vim

  • Fast Iteration With Byobu, Vim and fast-live-reload

    A while back I wrote a small program named fast-live-reload. The point of it was to be able to do things whenever files change (be that refreshing browsers, or executing programs, such as Compass compilation).

    Here is another sample on how I use it to try out python snippets really fast:

    I basically split my current view in two (using byobu), and I edit in the left view with my trusty vim. Whenever I save, fast-live-reload picks it up and executes the script.

    Instant feedback is instant ;-).

  • Live reloading web pages using VIM

    Do you want to live reload the browser as you edit and save using VIM?

    Well wait no more, you can install the application by simply running:

    1
    2
    npm install -g fast-live-reload
    fast-live-reload

    Afterwards whenever saving, the page is automatically reloaded. Without any browser plugins.

    fast-live-reload in action

  • Vim AsciiDoc (or Markdown) Source Code Blocks Highlight

    Do you want your editing of AsciiDoc (or Markdown) to look like this?

    In order to get AsciiDoc support working nicely in VIM, you'll need a couple of things:

    • asciidoc-vim: (the syntax highlight support)
    • SyntaxRange: (to enable text ranges to be highlighted with different syntax files)
      • ingo-library: (not really documented, but this is a dependency for SyntaxRange)

    Then add another syntax file for AsciiDoc, by creating another plugin, with just the /syntax folder in it. (If you use pathogen, it should look something like this). In it configure your SyntaxRange plugin for matching for various languages:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    function! AsciidocEnableSyntaxRanges()
    " source block syntax highlighting
    if exists('g:loaded_SyntaxRange')
      for lang in ['c', 'python', 'vim', 'javascript', 'cucumber', 'xml', 'typescript', 'sh', 'java', 'cpp', 'sh']
        call SyntaxRange#Include(
              \  '\c\[source\s*,\s*' . lang . '.*\]\s*\n[=-]\{4,\}\n'
              \, '\]\@<!\n[=-]\{4,\}\n'
              \, lang, 'NonText')
      endfor
     
      call SyntaxRange#Include(
            \  '\c\[source\s*,\s*gherkin.*\]\s*\n[=-]\{4,\}\n'
            \, '\]\@<!\n[=-]\{4,\}\n'
            \, 'cucumber', 'NonText')
    endif
    endfunction
     
    call AsciidocEnableSyntaxRanges()

    The gherkin one, is there separately, since for the gherkin language, we're going to use the cucumber syntax file.

    Since the SyntaxRange registration it's in the syntax file, it will only activate when editing asciidoc files.

    Enjoy :)

    PS: I inspired for the SyntaxRange calls from dahu's vim-asciidoc, but I just rewrote the RegExp to better match the start of the source.

    PS2: For doing live html visualising of the file, you can use fast-live-reload:

    1
    2
    3
    4
    5
    6
    fast-live-reload test.adoc -e "asciidoctor test.adoc" -nn test.html
    1. Will notify the changes for clients on port 9001
    2. and will serve the content from test.adoc on port 9000
    3. and will monitor and execute when files change in subfolders:
       a: test.adoc -> asciidoctor test.adoc (no refresh)
       b: test.html    

    Then just open the http://localhost:9000/test.html in the browser and watch it change as you save.

    PS3: In the screenshot there is also vim-airline installed with the powerline fonts active.

    PS4: For Markdown you need another syntax file, and different regexps for matching code blocks.

  • Vimscript: Where "true" is False, and "false" is Still False.

    Found this gem while reading the documentation from good ol' vim:

       What Vim calls true is anything that is not zero.  Zero is false.
            Note:
            Vim automatically converts a string to a number when it is looking for
            a number.  When using a string that doesn't start with a digit the
            resulting number is zero.  Thus look out for this:
                    :if "true"
            The "true" will be interpreted as a zero, thus as false!

    First language that I know of, where checking references to stuff actually return false.

Germanium

The one to rule them all. The browsers that is.

SharpKnight

SharpKnight is an Android chess game.

MagicGroup

MagicGroup is an eclipse plugin.