Я использую vim/gvim в качестве текстового редактора по умолчанию.
Когда я редактирую текстовые файлы без подсветки синтаксиса, он автоматически добавляет отступ, когда я нажимаю клавишу ввода, если последний символ в завершающей строке - запятая.
Этот отступ имеет переменную длину, чтобы поместить курсор под первое слово в предыдущей строке.
например, последовательность клавиш
a <space> b <enter> a <space> b , <enter> a <space> b
производит это
a b
a b,
a b
Если я :setlocal filetype?
Я получаю filetype=text
.
Вот мой ~/.vimrc
:
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather then 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
set backupdir=/home/bernie/.vim/tmp
set directory=/home/bernie/.vim/tmp
endif
set history=500 " 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
set autoindent " always set autoindenting on
set smartindent " guesses indents
set cindent " more flexible indenting.
set cino =>s, " 1 tab after each brace
set cino+=e0, " Braces starting on a new line treated the same
set cino+=n0, " Treat ifs the same even if there are no braces
set cino+=f0, " Functions aren't special either.
set cino+={0,}0,^0, " No per-brace fiddling.
set cino+=:0,=s, " Don't indent "case"s but indent their bodies
set cino+=l1, " Cases with braces get no extra indentation
set cino+=g0,h0, " No extra indents for "public", "private", etc.
set cino+=p0,t0, " No extra indents for function types and locals
set cino+=+s, " Continued lines are indented.
set cino+=cs,C1,N0, " Indent multi-line comments.
set cino+=)50,*50 " Search wide for unclosed brackets and comments
" Don't understand the (n un Un wn mn commads
set guioptions-=T " no toolbar
set vb t_vb= " flashing
set columns=80
set lines=80
colorscheme koehler
set autowrite " save all buffers before certain commands
" 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
" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
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 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
else
endif " has("autocmd")
set guifont=Monospace\ 8
set formatoptions-=t
Я не хочу, чтобы vim пытался быть умным с простыми текстовыми файлами. Как это отключить, но оставить авто / умный отступ для других типов файлов?