Loading ...
Sorry, an error occurred while loading the content.
 

Re: vim: current best available jekyll plugin?

Expand Messages
  • Paul Isambert
    ... Something like this, perhaps: com! -nargs=1 NewPost execute !rake post title= | e YOUR_FILE Of course I don t know how you can identify
    Message 1 of 4 , Feb 17, 2013
      ping <songpingemail@...> a écrit:
      > I've recently started my blogging via jekyll and immediately feel
      > addicted into it.
      > but it looks not quite feel a vim way .
      > I have to
      > 1) :!rake post title="my title"
      > 2) go find that generated post template in _post dir and open it
      > 3) and edit

      Something like this, perhaps:

      com! -nargs=1 NewPost execute '!rake post title=<q-args>' | e YOUR_FILE

      Of course I don't know how you can identify YOUR_FILE.

      > 4) :!git .... or use fugitive git plugin to get it published

      Same way: create a :command.

      > is there a good way to automate at least step 1 and 4 ?
      >
      > and there is one thing specifically I really wanted to archive for quite
      > a while:
      >
      > I usually work in some a long , but organized text file. and sometime I
      > really want to quickly put
      > some really good texts that I'm editing/viewing into a blog post and
      > publish it.
      > currently I have to:
      > 1) visual select the texts that i want to post
      > 2) copy them into a new buffer
      > 3) add some yaml front matter stuff like the following:
      >
      > ---
      > layout: post
      > title: "github/jeklly notes"
      > description: ""
      > category:
      > tags: []
      > ---
      > {% include JB/setup %}
      >
      > 4) save them as a md file into the _post folder
      >
      > what is the best vim-way to automate these?

      I'd say, again, write a command/function, e.g.:

      function! s:Post (fname) range
      exe a:firstline . "," . a:lastline . "yank"
      exe "tabnew /path/to/your/dir/" . a:fname . ".md"
      call append(0, ["Some", "lines", "of", "text."])
      normal p
      endfunction

      com! -nargs=1 Post call s:Post(<q-args>)

      Best,
      Paul

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • ping
      ... hi Paul: Thanks for the good sample code. I spend some time to develop it into my need, I found 2 small (but key) issues here: 1) to make command support
      Message 2 of 4 , Feb 17, 2013
        On 2/17/2013 11:39 AM, Paul Isambert wrote:
        I usually work in some a long , but organized text file. and sometime I 
        > really want to quickly put
        > some really good texts that I'm editing/viewing into a blog post and 
        > publish it.
        > currently I have to:
        > 1) visual select the texts that i want to post
        > 2) copy them into a new buffer
        > 3) add some yaml front matter stuff like the following:
        > 
        >   ---
        >   layout: post
        >   title: "github/jeklly notes"
        >   description: ""
        >   category:
        >   tags: []
        >   ---
        >   {% include JB/setup %}
        > 
        > 4) save them as a md file into the _post folder
        > 
        > what is the best vim-way to automate these?
        
        I'd say, again, write a command/function, e.g.:
        
        function! s:Post (fname) range
          exe a:firstline . "," . a:lastline . "yank"
          exe "tabnew /path/to/your/dir/" . a:fname . ".md"
          call append(0, ["Some", "lines", "of", "text."])
          normal p
        endfunction
        
        com! -nargs=1 Post call s:Post(<q-args>)
        
        Best,
        Paul
        
        hi Paul:
        Thanks for the good sample code.
        I spend some time to develop it into my need, I found 2 small (but key) issues here:

        1) to make command support range, it seems i need to add "-range":
        com! -nargs=1 Post call s:Post(<q-args>)

        2) even with that,  I still can't catch the selected text range, but instead my test shows only 1st line(or "current") line
        is yanked. so I tried this:

        com! -range=% -nargs=1 Post :<line1>,<line2>call Post(<q-args>)

        now it seems to work.

        so it seems that to support "range" in command -- a common usage is to pass that range into a called func (also ranged),
        that 2 elements can't be ignored...

        not sure my understanding is correct or I still miss anything here?


        regards
        ping


        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
         
        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
         
         
      • Paul Isambert
        ... You’re correct, I was too hasty when writing the command. Best, Paul -- -- You received this message from the vim_use maillist. Do not top-post! Type
        Message 3 of 4 , Feb 17, 2013
          ping <songpingemail@...> a écrit:
          > 2) even with that, I still can't catch the selected text range, but
          > instead my test shows only 1st line(or "current") line
          > is yanked. so I tried this:
          >
          > com! -range=% -nargs=1 Post :<line1>,<line2>call Post(<q-args>)
          >
          > now it seems to work.
          >
          > so it seems that to support "range" in command -- a common usage is to
          > pass that range into a called func (also ranged),
          > that 2 elements can't be ignored...
          >
          > not sure my understanding is correct or I still miss anything here?

          You’re correct, I was too hasty when writing the command.

          Best,
          Paul

          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        Your message has been successfully submitted and would be delivered to recipients shortly.