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

A list of questions that I can't find in FAQs

Expand Messages
  • py
    Hi, I m using Vim6.3. I had look through quite a number of FAQs and have not found the answer to the following question, please help How do I 1. filter out
    Message 1 of 3 , May 1, 2005
    • 0 Attachment
      Hi,

      I'm using Vim6.3. I had look through quite a number of FAQs and have not
      found the answer to the following question, please help

      How do I
      1. filter out lines in a file that does not match a certain regex? No
      change is made to the file, I only want to look at content that matches
      the regex

      2. How can I beautify code automatically(like EMACs)? I believe every
      language would requires some kind of rule set for this. Beautify
      includes: indentation, code alignment, comment alignment, trailing space
      removal, etc.

      3. How can I insert a comment block? For example, EMACs's VHDL mode can
      insert
      ---------------
      into the code with a couple keystroke. So it's quite easy to create this

      ---------------
      -- comment here
      ---------------

      It will also take indentation into account, so the lines always extend
      from the indentation to end of line.

      4. This one might be a little bit fishy. At my company people have
      different tab/space preferences(including use of softab)... and some of
      them ended up editing the same python script(the horror!). Is there a
      way to fix the tab issue inside a file? I always want to pull my hair
      out when a block of code is has 4 spaces while another block use tabs.

      5. What's the keyboard shortcut to copy and paste from different vim
      session? By copy and paste I mean the copy and paste button in Gvim's
      window. I don't want to open multiple files in the same session.

      That's all for now

      Thanks!
    • Eric Arnold
      You need to get used to navigating the online help system, since it contains nearly everything, though not necessarily spoon-fed as nicely as an FAQ. However,
      Message 2 of 3 , May 1, 2005
      • 0 Attachment
        You need to get used to navigating the online help system, since it contains
        nearly everything, though not necessarily spoon-fed as nicely as an FAQ.
        However, so this isn't a complete ReadTheFM reply, this is what I know as
        another new Vim user:

        Some useful tips:

        use the <TAB> and ^d keys to expand possibilities for you after
        :help comment^D
        :comment +comments map-comments engspchk-comment
        'comments' 'commentstring' format-comments :syn-sync-ccomment


        :helpgrep will search through all the help files that aren't already
        indexed and hyper linked through the normal :help
        and don't forget to use the :copen command (which should be the default
        action) to open the sub-window with all the subsequent matches hyperlinked.

        The :options window is also really helpful for getting familiar with all
        the settings available/vs what you've got set.

        Otherwise, and off hand, check into:

        :. !grep pattern file

        you can do it all inside Vim with some extra effort, but if you've got grep,
        why not use it?

        Most all languages have file type syntax support in Vim, which you should be
        seeing automatically if you have a full installation. The "=" command is
        the default re-format for area.

        For setting options on a per file basis, you can add a comment at the
        top/bottom of a file:

        " vim6:ts=4

        I'm using MS-win which has a decent GUI default set, and ^v/^c/^x are mapped
        to the usual MS defaults. I did find that setting

        set clipboard=unnamed

        was really helpful for having yank/put integrated nicely with cut/paste etc.
        across GUI instances. The help files have a big section on X11 and MSwin.
        I found stuff like this in my .gvimrc file:

        " Use ^C ^X ^V for copy/cut/paste:
        autocmd GUIEnter * source C:/cygwin/home/Owner/vim/vim61/mswin.vim




        --- py <pyjunk@...> wrote:
        > Hi,
        >
        > I'm using Vim6.3. I had look through quite a number of FAQs and have not
        > found the answer to the following question, please help
        >
        > How do I
        > 1. filter out lines in a file that does not match a certain regex? No
        > change is made to the file, I only want to look at content that matches
        > the regex
        >
        > 2. How can I beautify code automatically(like EMACs)? I believe every
        > language would requires some kind of rule set for this. Beautify
        > includes: indentation, code alignment, comment alignment, trailing space
        > removal, etc.
        >
        > 3. How can I insert a comment block? For example, EMACs's VHDL mode can
        > insert
        > ---------------
        > into the code with a couple keystroke. So it's quite easy to create this
        >
        > ---------------
        > -- comment here
        > ---------------
        >
        > It will also take indentation into account, so the lines always extend
        > from the indentation to end of line.
        >
        > 4. This one might be a little bit fishy. At my company people have
        > different tab/space preferences(including use of softab)... and some of
        > them ended up editing the same python script(the horror!). Is there a
        > way to fix the tab issue inside a file? I always want to pull my hair
        > out when a block of code is has 4 spaces while another block use tabs.
        >
        > 5. What's the keyboard shortcut to copy and paste from different vim
        > session? By copy and paste I mean the copy and paste button in Gvim's
        > window. I don't want to open multiple files in the same session.
        >
        > That's all for now
        >
        > Thanks!
        >
      • Wind
        Hello py, Monday, May 2, 2005, 7:48:52 AM, you wrote: p Hi, p I m using Vim6.3. I had look through quite a number of FAQs and have not p found the answer to
        Message 3 of 3 , May 1, 2005
        • 0 Attachment
          Hello py,

          Monday, May 2, 2005, 7:48:52 AM, you wrote:

          p> Hi,

          p> I'm using Vim6.3. I had look through quite a number of FAQs and have not
          p> found the answer to the following question, please help

          p> How do I
          p> 1. filter out lines in a file that does not match a certain regex? No
          p> change is made to the file, I only want to look at content that matches
          p> the regex
          How about "global" command? I think it is what you want.
          :help :global


          p> 2. How can I beautify code automatically(like EMACs)? I believe every
          p> language would requires some kind of rule set for this. Beautify
          p> includes: indentation, code alignment, comment alignment, trailing space
          p> removal, etc.
          For automatic indentation there is
          'smartindent','autoindent','cindent' options try them.
          And yet there is "=" normal command, hence try "gg=G" this will
          reindent the hole file.

          p> 3. How can I insert a comment block? For example, EMACs's VHDL mode can
          p> insert
          p> ---------------
          p> into the code with a couple keystroke. So it's quite easy to create this

          p> ---------------
          p> -- comment here
          p> ---------------

          p> It will also take indentation into account, so the lines always extend
          p> from the indentation to end of line.
          try the folowing mapping:
          :noremap t :execute "normal ".(&columns-virtcol('$'))."A*"<cr>

          p> 4. This one might be a little bit fishy. At my company people have
          p> different tab/space preferences(including use of softab)... and some of
          p> them ended up editing the same python script(the horror!). Is there a
          p> way to fix the tab issue inside a file? I always want to pull my hair
          p> out when a block of code is has 4 spaces while another block use tabs.
          try to use modeline feature:
          At the end or the beginning of the file type:
          # vim:ts=4

          see
          :h modeline
          for more information


          p> 5. What's the keyboard shortcut to copy and paste from different vim
          p> session? By copy and paste I mean the copy and paste button in Gvim's
          p> window. I don't want to open multiple files in the same session.
          Try the way you do it in a normal aplication(I mean you Windows or
          Xwindow application) with mouse it might work.
          p> That's all for now

          p> Thanks!



          --
          Best regards,
          Wind mailto:sonic_wind@...
        Your message has been successfully submitted and would be delivered to recipients shortly.