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

vim script question

Expand Messages
  • ryan kulla
    in a script how can i tell if im in visual mode? I know to find out if im in insert-mode i can check the return value of &insertmode, but theres no &visualmode
    Message 1 of 5 , Nov 29, 2003
    • 0 Attachment
      in a script how can i tell if im in visual mode? I know to find out if im in
      insert-mode i can check the return value of &insertmode, but theres no
      &visualmode
    • Thomas Adam
      Hi All, I apologise for the lack of info that this e-mail brings, but does anyone know why: C/C++ HTML etc... files are not automatically indenting as I type?
      Message 2 of 5 , Nov 29, 2003
      • 0 Attachment
        Hi All,

        I apologise for the lack of info that this e-mail brings, but does anyone
        know why:

        C/C++
        HTML

        etc...

        files are not automatically indenting as I type? I have checked :set and I
        see that the indent tag is there, yet my lines refuse to indent. I am
        running vim 6.2 and it makes no odds whether I am using gvim or vim.

        Cheers,

        Thomas Adam

        =====
        "The Linux Weekend Mechanic" -- http://linuxgazette.net
        "TAG Editor" -- http://linuxgazette.net

        ________________________________________________________________________
        Download Yahoo! Messenger now for a chance to win Live At Knebworth DVDs
        http://www.yahoo.co.uk/robbiewilliams
      • Antoine J. Mechelynck
        ... Anyway, &insertmode doesn t tell you if you are in Insert mode but if you are in permanent Insert mode (i.e., so-called easy Vim). And the mode()
        Message 3 of 5 , Nov 29, 2003
        • 0 Attachment
          ryan kulla <toxicpulse@...> wrote:
          > in a script how can i tell if im in visual mode? I know to find out
          > if im in insert-mode i can check the return value of &insertmode, but
          > theres no &visualmode

          Anyway, &insertmode doesn't tell you if you are in Insert mode but if you
          are in permanent Insert mode (i.e., so-called "easy" Vim). And the mode()
          function is said not to give reliable results except in the 'statusline'
          option.

          It all depends on how you came to invoking that script. If from a keyboard
          mapping you can use vmap/imap/nmap to invoke it slightly differently so you
          know which is which. But I don't have an all-embracing solution covering all
          possibilities.

          Regards,
          Tony.
        • Antoine J. Mechelynck
          ... [advert snipped] What indent settings have you got? Try ... with the cursor in a file of each of the concerned types, then look at the corresponding help.
          Message 4 of 5 , Nov 29, 2003
          • 0 Attachment
            Thomas Adam <thomas_adam16@...> wrote:
            > Hi All,
            >
            > I apologise for the lack of info that this e-mail brings, but does
            > anyone know why:
            >
            > C/C++
            > HTML
            >
            > etc...
            >
            > files are not automatically indenting as I type? I have checked :set
            > and I see that the indent tag is there, yet my lines refuse to
            > indent. I am running vim 6.2 and it makes no odds whether I am using
            > gvim or vim.
            >
            > Cheers,
            >
            > Thomas Adam
            [advert snipped]

            What indent settings have you got? Try

            :filetype
            :set autoindent? smartindent? cindent? indentexpr?

            with the cursor in a file of each of the concerned types, then look at the
            corresponding help. The command

            :filetype indent on

            may (or may not) be what you want. (I had it set by default in the
            vimrc-example, and I didn't like it, so finally I added "filetype indent
            off", among other settings, somewhere near the end of my own vimrc.)

            Regards,
            Tony.
          • Benji Fisher
            ... I do not think that &insertmode tells you what you think it does. ... In a script, you are always in Command-line mode, except when you explicitly switch
            Message 5 of 5 , Nov 30, 2003
            • 0 Attachment
              On Sat, Nov 29, 2003 at 04:35:02PM -0800, ryan kulla wrote:
              > in a script how can i tell if im in visual mode? I know to find out if im in
              > insert-mode i can check the return value of &insertmode, but theres no
              > &visualmode

              I do not think that &insertmode tells you what you think it does.

              :help 'insertmode'

              In a script, you are always in Command-line mode, except when you
              explicitly switch to another mode.

              :echo "This is Command-line mode."
              :execute "normal aThis is Insert mode.\<Esc>"

              Perhaps with some contxt, I can give a more satisfactory answer.

              HTH --Benji Fisher
            Your message has been successfully submitted and would be delivered to recipients shortly.