This haven been bugging me since the first day using Vim for 3 years. Whenever I try to indent a line via Shift + > when the FIRST CHARACTER of the line starts with a "#", it doesn't work at all, regardless of the file types (.php, .txt, etc.). Because # is used for comment in PHP and I also use it for decoration for text files something like:
# This is a comment ### 1. Instruction one # ------------ this is an sample --------------
I use Vim 7.2 in Ubuntu with the following .vimrc
settings
syntax on
set t_Co=256
set incsearch
set hlsearch
set number
set nowrap
set nowrapscan
set ignorecase
set et
set sw=4
set smarttab
set smartindent
set autoindent
set textwidth=0
set noequalalways
set formatoptions=1
set lbr
set vb
set foldmethod=marker
Thanks!
vim" in 'runtimepath'. This disables auto-indenting for files you will open. It will keep working in already opened files. Reset 'autoindent', 'cindent', 'smartindent' and/or 'indentexpr' to disable indenting in an opened file.
To indent the current line, or a visual block: ctrl-t, ctrl-d - indent current line forward, backwards (insert mode) visual > or < - indent block by sw (repeat with . ) then try hitting the F5 key while in insert mode (or just :set paste ).
Insert the following in your .vimrc
:
set nosmartindent
It is smartindent
that causes lines beginning with #
to not be indented as you want. You can read more about it by typing :help smartindent
. If you use an indenting file for python scripts (or any other syntax), include the following too.
filetype indent on
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With