P
P
petrant2020-02-14 10:22:58
vim
petrant, 2020-02-14 10:22:58

Changing Vim behavior based on file type?

Is it possible to set different behavior (mapping, plugin loading, indentation options) for vim for different files? For *.cpp one, for *.hs another, etc.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-02-14
@petrant

Perhaps an example:

function Set_python_settings()
    "Настройки табов для Python, согласно рекоммендациям
    set tabstop=4
    set shiftwidth=4
    set smarttab
    set expandtab "Ставим табы пробелами
    set softtabstop=4 "4 пробела в табе
    set smartindent
    set tags=tags
"   set tags=tags.da,python.tags,twisted.tags,tags
"   set path+=~/work/da/python/**
endfunction

function Unset_python_settings()
  set tags=tags;/
endfunction

autocmd BufNewFile,BufEnter *.{py} call Set_python_settings()
autocmd BufLeave *.{py} call Unset_python_settings()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question