Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 04-09-2013, 09:31 PM   #1
LQ Newbie
Registered: Feb 2013
Posts: 10

Rep: Reputation: Disabled
Question Remove Double tab indent on vim

I edited vim configuration file vimrc so that when I press return(enter) in a place I'd like the code automatically be indented.
Changed the spaces on tab press to 4 too.

But when I press return vim puts 2 indentation, resulting on 8 indent spaces and not 4 like I want.

eg in a C source code:
if (condition) {<when I press return here ...>
    code <Should be here>
        code <But comes here>
And is to much anoing press backspace every single case like that to go where i whould like.

How do I make vim do a SINGLE automatic indentation.

ps: I removed all plugins but still have the problem.

My vimrc file:
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"

execute pathogen#infect()

" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" allow backspacing over everything in insert mode
set backspace=indent,eol,start

if has("vms")
  set nobackup		" do not keep a backup file, use versions instead
  set backup		" keep a backup file
set history=50		" keep 50 lines of command line history
set ruler		" show the cursor position all the time
set showcmd		" display incomplete commands
set incsearch		" do incremental searching

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" Don't use Ex mode, use Q for formatting
map Q gq

" CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>

" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
  set mouse=a

" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mgl 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

  " 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).
  " Also don't do it when the mark is in the first line, that is the default
  " position when opening a file.
  autocmd BufReadPost *
    \ if line("'\"") > 1 && line("'\"") <= line("$") |
    \   exe "normal! g`\"" |
    \ endif

  augroup END


  set autoindent	" always set autoindenting on

endif " has("autocmd")

" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
  command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
		  \ | wincmd p | diffthis

syntax on
set ic hls is
"set expandtab		" spaces and not tab on indentation
set tabstop=4
set showmatch

" Clang config
let g:clang_use_library=1
let g:clang_library_path="/usr/lib"
let g:clang_complete_auto=1
let g:clang_complete_copen=1
let g:clang_snippets=1
let g:clang_trgling_placeholder=1

" Visual configurations
colorscheme jellybeans
set laststatus=2	"Always show the statusline
set encoding=utf-8
set t_Co=256
set fillchars+=stl:\ ,stlnc:\

" Powerline config
let g:Powerline_colorscheme='solarized256'
Old 04-09-2013, 09:46 PM   #2
LQ Newbie
Registered: Feb 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
I solved the problem adding set "shiftwidth=4" to the end of the vimrc.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Command to indent text in vim xeon123 Linux - Software 3 03-01-2011 05:05 PM
do you use tab or the spacebar to indent? newbiesforever General 12 05-23-2010 11:06 PM
vim , indent and printing reddog Programming 3 05-09-2009 05:23 PM
Vim re indent? dlublink Linux - Software 3 10-02-2006 01:37 PM
vim tab key redhax8 Programming 3 09-02-2006 09:44 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:33 PM.

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