Tony Chen
Tony Chen

Reputation: 183

Why after I set python-mode indent=1 I still can't get my code indented automatically when I am coding python

So recently I watched a youtube video about "using vim as a python editor" and I decided to use it. It's the first time I use Vim. My System is OS X 10.9.5 and I am using MacVim. So I added following code to my gvimrc file.

    " Setting for python-mode"
    map <Leader> g :call RopeGotoDefinition() <CR>
    let ropevim_enable_shortcuts = 1
    let g:pymode_rope_goto_def_newwin = "vnew"
    let g:pymode_rope_extended_complete = 1
    let g:pymode_breakpoint = 0
    let g:pymode_syntax = 1
    let g:pymode_syntax_builtin_objs = 0
    let g:pymode_syntax_builtin_funcs = 0
    let g:pymode_indent = 1
    map <Leader> b Oimport ipdb; ipdb.set_trace() #BREAKPOINT<C-c>


    " ???set completeopt = longest,menuone"
    function! OmniPopup(action)
       if pumvisible()
            if a:action == 'j'
                return "\<C-N>"
            elseif a:action == 'k'
                return "<\C-P>"
            endif
        endif
        return a:action
        endfunction

    inoremap <silent><C-j> <C-R>=OmniPopup('j')<CR>
    inoremap <silent><C-k> <C-R>=OmniPopup('k')<CR>

    set nofoldenable

So I should actually invoke the indentation about python using this code: let g:pymode_indent = 1. But when I create a new Python file and use it to code Python. I still can't get the indentation to work.

I don't know anything about how to set up gvimrc file and I am just copy the code from that video. What went wrong? Thx!

Upvotes: 0

Views: 109

Answers (1)

rgoliveira
rgoliveira

Reputation: 936

You're probably missing filetype plugin on in your vimrc. This will enable vim to identify the type of file you're editing and run plugins (and maybe some extra stuff) accordingly.

You can read more here about filetype detection and plugins, or using :help filetype.

Upvotes: 1

Related Questions