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

Re: Split editor vertically to show code comments on the right

Expand Messages
  • michaelg
    Hi Tony, Thanks firstly for taking an interest in the question. I m aware that others may prefer different coding styles and there are varying views on line
    Message 1 of 4 , Aug 1 12:15 PM
    • 0 Attachment
      Hi Tony,

      Thanks firstly for taking an interest in the question. I'm aware that others may prefer different coding styles and there are varying views on line lengths and wrapping. You'll note from my OP that I specifically don't want to spend so much time manually formatting long end-of-line comments - I want to write a plugin which will do it for me. So I'm grateful that you put such time as you did into your answer but I would argue that it misses the point of my original post.

      I have, since posting to this list, been in touch with someone on the subject of vim plugins and he suggested that the following approach might work:

      * Open an .asm file as a normal Vim buffer.
      * Press a key to enter "yourplugin mode". An autocommand could do this for you whenever opening a file automatically.
      * When you enter yourplugin mode, hide the actual .asm file buffer and create two new buffers, foo.asm__CODE and foo.asm__COMMENTS. These buffers will be entirely managed by your plugin.
      * Your plugin will parse foo.asm and fill in these two new buffers appropriately. Assembly is pretty simple so I think you're going to get lucky here and not have to worry about actually *parsing* the ASM -- a simple regex will probably get the job done.
      * When the user saves either of these buffers, both are "saved". The plugin parses their content and renders it back into foo.asm, and then saves that.

      This reflects a concern I had which was that simply concealing part of the line in each pane wasn't going to work. I would welcome any comment on the pros and cons of the above approach, or in fact, any other approach which could deliver this particular feature-request.

      Regards

      Michael

      --
      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
    • Ben Fritz
      ... simply concealing part of the line in each pane WILL work, I think. You would need to use the conceal feature combined with the :ownsyntax feature to
      Message 2 of 4 , Aug 1 2:03 PM
      • 0 Attachment
        On Wednesday, August 1, 2012 2:15:47 PM UTC-5, michaelg wrote:
        > Hi Tony,
        >
        > Thanks firstly for taking an interest in the question. I'm aware that others may prefer different coding styles and there are varying views on line lengths and wrapping. You'll note from my OP that I specifically don't want to spend so much time manually formatting long end-of-line comments - I want to write a plugin which will do it for me. So I'm grateful that you put such time as you did into your answer but I would argue that it misses the point of my original post.
        >
        > I have, since posting to this list, been in touch with someone on the subject of vim plugins and he suggested that the following approach might work:
        >
        > * Open an .asm file as a normal Vim buffer.
        > * Press a key to enter "yourplugin mode". An autocommand could do this for you whenever opening a file automatically.
        > * When you enter yourplugin mode, hide the actual .asm file buffer and create two new buffers, foo.asm__CODE and foo.asm__COMMENTS. These buffers will be entirely managed by your plugin.
        > * Your plugin will parse foo.asm and fill in these two new buffers appropriately. Assembly is pretty simple so I think you're going to get lucky here and not have to worry about actually *parsing* the ASM -- a simple regex will probably get the job done.
        > * When the user saves either of these buffers, both are "saved". The plugin parses their content and renders it back into foo.asm, and then saves that.
        >
        > This reflects a concern I had which was that simply concealing part of the line in each pane wasn't going to work. I would welcome any comment on the pros and cons of the above approach, or in fact, any other approach which could deliver this particular feature-request.
        >

        "simply concealing part of the line in each pane" WILL work, I think. You would need to use the "conceal" feature combined with the :ownsyntax feature to set up syntax highlighting for each window. Implementation would:

        1. set up two side-by-side windows on the buffer
        2. set scrollbind (and maybe cursorbind) on each window
        3. set a syntax on the first window which highlights the assembly and conceals the comments
        4. set a syntax on the second window which highlights the comments and conceals the code

        I think you'd want to set 'wrap' the same on each window, but I'm not sure how well that works with the conceal feature on scrollbound windows, so maybe you can't use soft wrapping very well.

        --
        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
      Your message has been successfully submitted and would be delivered to recipients shortly.