lo__tp
lo__tp

Reputation: 365

vim:filetype plugin conflict

I need to do python and js program at the same time.

And also, I have some language specific seetings located at the ~/.vim/after/ftplugin/ directory

Here I'll show you the content of these files:

In python.vim

    set tabstop=4
    set shiftwidth=4
    set expandtab
    set softtabstop=4
    nnoremap Y :Autoformat<CR>

In my javascript.vim

    nnoremap Y :call JsBeautify()<CR>

Imagine this scenery:

That's not what I want

Now I'm wondering if there is a way to make vim work like this:

Upvotes: 0

Views: 132

Answers (1)

romainl
romainl

Reputation: 196546

You must make your options and mappings as local as possible.

In ~/.vim/after/ftplugin/python.vim:

setlocal tabstop=4
setlocal shiftwidth=4
setlocal expandtab
setlocal softtabstop=4
nnoremap <buffer> Y :Autoformat<CR>

In ~/.vim/after/ftplugin/javascript.vim:

nnoremap <buffer> Y :call JsBeautify()<CR>

As FDinoff wrote in his comment:

:help :setlocal
:help :map-local

Upvotes: 3

Related Questions