LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Remove Double tab indent on vim (https://www.linuxquestions.org/questions/linux-software-2/remove-double-tab-indent-on-vim-4175457575/)

d4nt3 04-09-2013 09:31 PM

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:
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:
Code:

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

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
else
  set backup                " keep a backup file
endif
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
endif


" 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
  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).
  " 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

else

  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
endif

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'


d4nt3 04-09-2013 09:46 PM

I solved the problem adding set "shiftwidth=4" to the end of the vimrc.


All times are GMT -5. The time now is 12:39 AM.