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

Re: How to set USERNAME in RHS of "set" command

Expand Messages
  • AndyHancock
    ... I find the vim help and vim-specific FAQs/wikis helpful if I now the right words. Google helps me find the right words, and often points me to relevant
    Message 1 of 8 , Jul 2, 2012
    • 0 Attachment
      On Jun 27, 1:38 am, John Little <John.B.Lit...@...> wrote:
      > Before googling, vim's help is usually the first place to go, and
      > then the vim FAQhttp://vimhelp.appspot.com/vim_faq.txt.htmland the
      > Vim tips wikihttp://vim.wikia.com/wiki/Vim_Tips_Wiki.

      I find the vim help and vim-specific FAQs/wikis helpful if I now the
      right words. Google helps me find the right words, and often points
      me to relevant pages.

      > In particular, you should read
      >
      > :help file-formats
      >
      > if you haven't already.

      Thanks. That was quite helpful.

      >> ... You tend to lose track of the fact that
      >> you're writing text files or source code using filetype=unix.
      >
      > I have an expression in my status line option
      >
      > %1*%{&ff=~'u'?'':&ff}%*
      >
      > which shows me the file format if it's not my usual unix, in a
      > different colour to the rest of the status line (which I always have
      > on with :set ls=2).

      It never ceases to amaze me how deep the vim coding can be for
      seemingly simple things that the casual user takes for granted. In
      trying to understand the help for the statusline option, a few helpful
      pages I found were:

      http://vim.wikia.com/wiki/Showing_syntax_highlight_group_in_statusline
      http://got-ravings.blogspot.ca/2008/10/vim-pr0n-conditional-stl-highlighting.html
      http://www.vim.org/scripts/script.php?script_id=3383
      http://vim.runpaint.org/display/changing-status-line

      Currently, I use only the simplest concepts from the 2nd last link:

      highlight StatusLineNC guibg=tan
      highlight StatusLine guibg=white

      The first link is great for illustrating the curly brace expression
      evaluation that you use.

      My brain started to disconbobulate when reading about highlight group
      1 in "%1*", but I get the idea. Different suites of highlight
      colours.

      Anyway, I think the use of cautionary colours to bring attention to
      the fileformat is a great idea, especially since I often use a scratch
      file for manipulating text that is meant for others as well as for
      piping to bash. However, I like the items shown on the default
      statusbar, so I'll look into cobbling together a statusline that
      incorporates this feature along with the standard items. It's a bit
      of a longer term to-do.

      I also confirmed that there is no special escaping needed to pipe text
      through dos2unix prior to bash. For example, to execute everything
      from the mark 'a to . (current insertion point), I would do:

      :w !dos2unix|bash

      Thanks!

      --
      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
    • Bee
      ... I have wondered about coloring the statusline. Thank you John. These work the way I would like. Is it possible to make it a one liner? That is
      Message 2 of 8 , Jul 2, 2012
      • 0 Attachment
        On Jun 26, 10:38 pm, John Little <John.B.Lit...@...> wrote:
        > I have an expression in my status line option
        >
        > %1*%{&ff=~'u'?'':&ff}%*

        I have wondered about coloring the statusline. Thank you John.

        These work the way I would like.
        Is it possible to make it a one liner?
        That is conditionally color the ff?
        I could not get the %1* to work inside the false part,
        so split into two statusline commands.

        set statusline+=%{&ff=~'u'?'u':''} " unix fileformat
        set statusline+=%1*%{&ff=~'u'?'':strpart(&ff,0,1)}%* " not unix
        fileformat

        Bill

        --
        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
      • John Little
        ... Perhaps I should have given all the details, the way Tony M does. My statusline is set to %
        Message 3 of 8 , Jul 2, 2012
        • 0 Attachment
          On Tuesday, July 3, 2012 7:34:55 AM UTC+12, Bee wrote:

          > Is it possible to make it a one liner?

          Perhaps I should have given all the details, the way Tony M does.

          My 'statusline' is set to

          %<%f%1*%{&ff=~'u'?'':&ff}%* %h%m%r%=%-16.(%l,%2c %L%) %P

          so I've got the usual stuff, with the dos or mac warning sitting right by the file name. My colour scheme has, amongst others,

          hi Normal guifg=white guibg=black
          hi StatusLine guifg=green guibg=DarkSlateGrey gui=underline,bold
          hi StatusLineNC guifg=darkgreen gui=underline,italic

          So the status line for the current window has a grey background, quite different from the black of the file I'm editing. The ff bit is coloured with highlight group User1, which I don't usually bother to define, so it comes out as Normal, white on black, not bold green underline on grey, quite distinct.

          Now the bit in the %{ ... } is a vim expression, not a status line specifier, so status line specifiers won't work in it. However, if the %{ ... } has zero length, you don't see it, so just include both of them:

          set statusline+=%{&ff=~'u'?'u':''}%1*%{&ff=~'u'?'':strpart(&ff,0,1)}%*

          Regards, John

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