LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-20-2007, 11:20 AM   #1
kryptobs2000
Member
 
Registered: Dec 2003
Distribution: Slackware
Posts: 306

Rep: Reputation: 30
vim auto indenting?


I would like to change vim's auto indenting (where it indents depending on file type, useful for programming). It currently is 8 spaces and I'd like to make it 3 or 4 as that's too much for me. I've checked in the .vimrc but I don't know what I'm looking for.
 
Old 10-20-2007, 12:26 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Use "locate vimrc" to locate the sample .vimrc and .gvimrc which are probably in /usr/share/doc/packages/vim/.
Here is a segment that involves a filetype plugin and indentation:
Code:
" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  filetype plugin indent on

  " Put these in an autocmd group, so that we can delete them easily.
  augroup vimrcEx
  au!

  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78

  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal! g`\"" |
    \ endif

  augroup END
There are plugins for each filetype in /usr/share/vim/current/ftplugin/

---

You might try simply using "shiftwidth" and "softtabstop" in your .vimrc. From what I've seen the filetype plugins deal with how to indent but not by how much.

Last edited by jschiwal; 10-20-2007 at 12:46 PM.
 
Old 10-20-2007, 03:11 PM   #3
kryptobs2000
Member
 
Registered: Dec 2003
Distribution: Slackware
Posts: 306

Original Poster
Rep: Reputation: 30
Thank you, changing the shiftwidth fixed it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic indenting not working in Kate on Ubuntu Robhogg Linux - Software 0 01-11-2007 07:57 AM
disable indenting in VIM Ygrex Linux - Software 3 12-24-2005 04:07 AM
vim and fortran smart-indenting s_siouris Linux - Software 0 11-23-2004 05:00 AM
Make vi stop indenting tumana Linux - Newbie 1 04-06-2004 09:12 PM
XEmacs and automatic indenting jeempc Programming 3 03-17-2003 06:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration