Thread: VIM Question

  1. #1
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681

    VIM Question

    Anyone know if you can change how much VIM indents when it does auto-indenting? I checked the vimrc file but all I found was the option to turn autoident on or off.
    I want to change it from a tab to two spaces. Found the indent directory but not sure which file to change.

    Thanks

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    It should be something along the lines of
    Code:
    :set autoindent tabstop 2
    for a two space indention.
    My best code is written with the delete key.

  3. #3
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Thanks Prelude. Unfortunately that didn't do it. Looking through the help and stuff more I found that the setting I'm looking for is called sw. I can change it for that session by doing :set sw=2 but it doesn't change permeantly. I'll keep looking though.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Unfortunately that didn't do it.
    I would be able to help better if I were running Unix at the moment. My .rc file for vi sets the autoindent to 2. I'll grab it for you the next time I boot into Unix if you haven't solved your problem by then.
    My best code is written with the delete key.

  5. #5
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187

    Re: VIM Question

    >> I want to change it from a tab to two spaces.
    I'm not sure I understand your question.
    normally I use tab indenting.
    if I want to change tab to spaces, I type ``:1,$s/\t/ /g'' before exporting to other editors.
    if you mean autoindent with spaces, i don't know.
    that's very bad for me and might cause me to change my avatar

    >>:set sw=2 but it doesn't change permanently.
    howabout put it in vimrc file?
    slackware 10.0; kernel 2.6.7
    gcc 3.4.0; glibc 2.3.2; vim editor
    migrating to freebsd 5.4

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Here's my .vimrc file (used for gvim as well)
    Code:
    :set guifont=*
    :syntax on
    :set tabstop=4
    :set shiftwidth=4
    :set smartindent
    :set smarttab
    :set expandtab
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  7. #7
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187
    I tested individual command.
    seems that only :set expandtab is required.
    Thx Hammer
    slackware 10.0; kernel 2.6.7
    gcc 3.4.0; glibc 2.3.2; vim editor
    migrating to freebsd 5.4

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. VIM: The (un)official thread
    By MK27 in forum Programming Book and Product Reviews
    Replies: 32
    Last Post: 04-20-2011, 06:43 PM
  2. Pico vs Vi(m) read lock question
    By Overworked_PhD in forum Linux Programming
    Replies: 1
    Last Post: 06-29-2009, 06:38 AM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. VIM Question
    By bludstayne in forum Tech Board
    Replies: 4
    Last Post: 01-01-2004, 12:16 PM
  5. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM