Find the answer to your Linux question:
Results 1 to 7 of 7
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2005
    Location
    INDIA
    Posts
    28

    Running Vi Scripts


    Hello....can we run vim scripts as soon as i open vi editor..
    If yes...can anyone please tell me how?
    Thanks in advance.

  2. #2
    Just Joined!
    Join Date
    Nov 2005
    Location
    Chicago, IL
    Posts
    46
    I am having a little trouble trying to understand what you are asking. Do you mean writing the script in the vi editor and then executing it from the command line? If so....after writing it, you have to change the user rights and make it an executable. Meaning use chmod to modify the rights as so:
    chmod +x [filename]
    Look at the man pages to understand the chmod function and the parameters it takes:
    man chmod

    The example I showed you above is the quickest way. From there you can execute that scripts a number of ways (depending on the shell you are working from)....for example in the Bourne shell (sh) and in the Bourne Again shell (bash) you can just simply type if you are in that working directory (if not you have to type the path):
    ./[filename]
    or
    sh [filename]
    To find out what shell you are in...at the command line type:
    echo $SHELL


    If this is not what you meant...please clarify.

  3. #3
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    I think I know what you're referring to, some sort of .vim script?

    While I've never used one myself, you can use the ~/.vimrc file to execute commands whenever you start vim. Mine, for example, is:
    Code:
    alex@tux ~ $ cat .vimrc
    :set autoindent
    :set smartindent
    :set sw=4
    :set softtabstop=4
    You could put the command to execute the script into this file and it would run at startup.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Nov 2005
    Location
    Chicago, IL
    Posts
    46
    aaahhh....that would make more sense....that is the beauty of vim, it is VERY scriptable...i didn't think of that for some reason. Thanks for pointing that out Cabhan.

  6. #5
    Just Joined!
    Join Date
    Jun 2005
    Location
    INDIA
    Posts
    28
    Thank you...
    i was referring to a .vim script, not a shell one..
    thank you guyz for i now got how to write a .vim script

  7. #6
    Just Joined!
    Join Date
    Nov 2005
    Location
    Chicago, IL
    Posts
    46
    If you need more of a direction you can check out some of my friend's stuff:
    http://root-squash.ath.cx/zsh/vimrc.d/

    Main page:
    http://root-squash.ath.cx/zsh/main.html

  8. #7
    Just Joined!
    Join Date
    Jun 2005
    Location
    INDIA
    Posts
    28
    thanks for the info..
    now im able to start tweaking Vi in my own way!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •