Python用のVimの構成

今日は、お気に入りのVimエディター(あるモードではきしみ、別のモードではすべてを台無しにする)を設定してPythonコードを記述する方法を説明します。 この記事は初心者を対象にしています。

私は次の写真を得ました:





.vimrc



開始するには、 〜/ .vimrcでいくつかのオプションを設定する必要があります。 ファイル全体を持ってくるので、誰かが役に立つかもしれません。



" VI:

set nocompatible



" - :

filetype on

filetype plugin on



" Python,

set tabstop=4

set shiftwidth=4

set smarttab

set expandtab "

set softtabstop=4 "4

"

set autoindent

"

let python_highlight_all = 1

" 256 , ?

" , gnome-terminal

set t_Co=256



" omnicomletion Python ( js, html css)

autocmd FileType python set omnifunc=pythoncomplete#Complete

autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS

autocmd FileType html set omnifunc=htmlcomplete#CompleteTags

autocmd FileType css set omnifunc=csscomplete#CompleteCSS



"

function InsertTabWrapper()

let col = col('.') - 1

if !col || getline('.')[col - 1] !~ '\k'

return "\"

else

return "\<cp>"

endif

endfunction

imap <cr>=InsertTabWrapper()"

set complete=""

set complete+=.

set complete+=k

set complete+=b

set complete+=t



" ( .py )

autocmd BufWritePre *.py normal m`:%s/\s\+$//e ``

" .py

autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class



"""" ,

"""" ,



" SnippletsEmu(. ) ctrl-j

" tab ( )

let g:snippetsEmu_key = "<Cj>"



" / Ctrl+C/Ctrl+V

vmap <CC> "+yi

imap <CV> "+gPi



colorscheme wombat256 "

syntax on "

set nu "

set mousehide "

set mouse=a "

set termencoding=utf-8 "

set novisualbell "

set t_vb= " ! ( ' ', , )

" backspace

set backspace=indent,eol,start whichwrap+=<,>,[,]

"

set showtabline=0

", :

set foldcolumn=1



" ,

set wrap

set linebreak



" .swp ~ ()

set nobackup

set noswapfile

set encoding=utf-8 "

set fileencodings=utf8,cp1251 " , unicode ,

" cp1251







Power of Vim, -.

, , Vimball - . . ~/.vim/



. - Python ( Django - ). ~/.vim/syntax/ ( - , )



- pythoncomplete.vim ~/.vim/autoload/ . .vimrc Tab.



, ?.. runscript.vim ~/.vim/plugin/ . , :

sudo apt-get install tofrodos #

dos2unix ~/.vim/plugin/runscript.vim









Vim :



" ,

let s:PathToExecutable = '/usr/bin/python'



" Map keys to function calls

" , ""

if !hasmapto('RunScript')

nmap ExecuteScript

endif

"

if !hasmapto('SetMainScript')

nmap SetMainScript

endif

"

if !hasmapto('ClearMainScript')

nmap <S-F11> ClearMainScript

endif

"/

if !hasmapto('ToggleOutputWindow')

nmap ToggleOutputWindow

endif



.vimrc , .



- SnippletsEmu - . . for, ( .vimrc ctrl-j ), :



, ... , , , .

(, , Textmate) vba : . vim, :

:source %







, .



, :

:Snippet <{}> <{}>. <{}>.









, .

SnippletEmu ,



, , - ! desert256 , - ScrollColor.vim .



:COLOR







.








" VI:

set nocompatible



" - :

filetype on

filetype plugin on



" Python,

set tabstop=4

set shiftwidth=4

set smarttab

set expandtab "

set softtabstop=4 "4

"

set autoindent

"

let python_highlight_all = 1

" 256 , ?

" , gnome-terminal

set t_Co=256



" omnicomletion Python ( js, html css)

autocmd FileType python set omnifunc=pythoncomplete#Complete

autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS

autocmd FileType html set omnifunc=htmlcomplete#CompleteTags

autocmd FileType css set omnifunc=csscomplete#CompleteCSS



"

function InsertTabWrapper()

let col = col('.') - 1

if !col || getline('.')[col - 1] !~ '\k'

return "\"

else

return "\<cp>"

endif

endfunction

imap <cr>=InsertTabWrapper()"

set complete=""

set complete+=.

set complete+=k

set complete+=b

set complete+=t



" ( .py )

autocmd BufWritePre *.py normal m`:%s/\s\+$//e ``

" .py

autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class



"""" ,

"""" ,



" SnippletsEmu(. ) ctrl-j

" tab ( )

let g:snippetsEmu_key = "<Cj>"



" / Ctrl+C/Ctrl+V

vmap <CC> "+yi

imap <CV> "+gPi



colorscheme wombat256 "

syntax on "

set nu "

set mousehide "

set mouse=a "

set termencoding=utf-8 "

set novisualbell "

set t_vb= " ! ( ' ', , )

" backspace

set backspace=indent,eol,start whichwrap+=<,>,[,]

"

set showtabline=0

", :

set foldcolumn=1



" ,

set wrap

set linebreak



" .swp ~ ()

set nobackup

set noswapfile

set encoding=utf-8 "

set fileencodings=utf8,cp1251 " , unicode ,

" cp1251







Power of Vim, -.

, , Vimball - . . ~/.vim/



. - Python ( Django - ). ~/.vim/syntax/ ( - , )



- pythoncomplete.vim ~/.vim/autoload/ . .vimrc Tab.



, ?.. runscript.vim ~/.vim/plugin/ . , :

sudo apt-get install tofrodos #

dos2unix ~/.vim/plugin/runscript.vim





Vim :



" ,

let s:PathToExecutable = '/usr/bin/python'



" Map keys to function calls

" , ""

if !hasmapto('RunScript')

nmap ExecuteScript

endif

"

if !hasmapto('SetMainScript')

nmap SetMainScript

endif

"

if !hasmapto('ClearMainScript')

nmap <S-F11> ClearMainScript

endif

"/

if !hasmapto('ToggleOutputWindow')

nmap ToggleOutputWindow

endif



.vimrc , .



- SnippletsEmu - . . for, ( .vimrc ctrl-j ), :



, ... , , , .

(, , Textmate) vba : . vim, :

:source %







, .



, :

:Snippet <{}> <{}>. <{}>.









, .

SnippletEmu ,



, , - ! desert256 , - ScrollColor.vim .



:COLOR







.












" VI:

set nocompatible



" - :

filetype on

filetype plugin on



" Python,

set tabstop=4

set shiftwidth=4

set smarttab

set expandtab "

set softtabstop=4 "4

"

set autoindent

"

let python_highlight_all = 1

" 256 , ?

" , gnome-terminal

set t_Co=256



" omnicomletion Python ( js, html css)

autocmd FileType python set omnifunc=pythoncomplete#Complete

autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS

autocmd FileType html set omnifunc=htmlcomplete#CompleteTags

autocmd FileType css set omnifunc=csscomplete#CompleteCSS



"

function InsertTabWrapper()

let col = col('.') - 1

if !col || getline('.')[col - 1] !~ '\k'

return "\"

else

return "\<cp>"

endif

endfunction

imap <cr>=InsertTabWrapper()"

set complete=""

set complete+=.

set complete+=k

set complete+=b

set complete+=t



" ( .py )

autocmd BufWritePre *.py normal m`:%s/\s\+$//e ``

" .py

autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class



"""" ,

"""" ,



" SnippletsEmu(. ) ctrl-j

" tab ( )

let g:snippetsEmu_key = "<Cj>"



" / Ctrl+C/Ctrl+V

vmap <CC> "+yi

imap <CV> "+gPi



colorscheme wombat256 "

syntax on "

set nu "

set mousehide "

set mouse=a "

set termencoding=utf-8 "

set novisualbell "

set t_vb= " ! ( ' ', , )

" backspace

set backspace=indent,eol,start whichwrap+=<,>,[,]

"

set showtabline=0

", :

set foldcolumn=1



" ,

set wrap

set linebreak



" .swp ~ ()

set nobackup

set noswapfile

set encoding=utf-8 "

set fileencodings=utf8,cp1251 " , unicode ,

" cp1251







Power of Vim, -.

, , Vimball - . . ~/.vim/



. - Python ( Django - ). ~/.vim/syntax/ ( - , )



- pythoncomplete.vim ~/.vim/autoload/ . .vimrc Tab.



, ?.. runscript.vim ~/.vim/plugin/ . , :

sudo apt-get install tofrodos #

dos2unix ~/.vim/plugin/runscript.vim









Vim :



" ,

let s:PathToExecutable = '/usr/bin/python'



" Map keys to function calls

" , ""

if !hasmapto('RunScript')

nmap ExecuteScript

endif

"

if !hasmapto('SetMainScript')

nmap SetMainScript

endif

"

if !hasmapto('ClearMainScript')

nmap <S-F11> ClearMainScript

endif

"/

if !hasmapto('ToggleOutputWindow')

nmap ToggleOutputWindow

endif



.vimrc , .



- SnippletsEmu - . . for, ( .vimrc ctrl-j ), :



, ... , , , .

(, , Textmate) vba : . vim, :

:source %







, .



, :

:Snippet <{}> <{}>. <{}>.









, .

SnippletEmu ,



, , - ! desert256 , - ScrollColor.vim .



:COLOR







.











All Articles