Search code examples
vimconfigurationindentationvi

Vim Indentation Configuration


What happens in my vim editor is --> LOOK AT THE CURSOR...

int main() {|

After pressing enter.. The cursor always comes at the beginning of the line, it does not indent automatically !!

int main() {
|
}

OR

int main() {
    if () {
|
    }
}

What I want is...

int main() {
    |
}

the cursor to have 2 or 4 white-space indentation !!

How can I do this ??

My .vimcr:

" when I close tab, remove the buffer
set nohidden

" Highlight things that we find with the search
set hlsearch

" Incremental searching 
set incsearch

set smartcase

" Enable mouse support in console
set mouse=a

" Line numbers PWN!
set number 

set shiftwidth=3
set softtabstop=3

set smarttab

set autoindent
set smartindent 
set tabstop=4
set shiftwidth=4
set expandtab

inoremap {<cr> {<CR><CR>}<Esc>-cc

Solution

  • Well I sorted out the solution myself, just remove smartindent !!!