Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
描述您为Python/Django开发定制的Vim编辑器?_Python_Django_Vim_Ide - Fatal编程技术网

描述您为Python/Django开发定制的Vim编辑器?

描述您为Python/Django开发定制的Vim编辑器?,python,django,vim,ide,Python,Django,Vim,Ide,最近,我的所有Python/Django开发都完全转向了Vim。我花了很多时间来定制它,直到今天,天知道我很难找到适合Python/Django开发的最佳vim插件的帮助 我决定问这个问题,这样像我这样的人可以直接从你的经历中受益: 您已经构建了完美的Python/Djangoish Vim编辑器?为我们描述它(插件、脚本、定制的.vimrc、配色方案等等) 谢谢 我的配置 好的,这是我自己的配置。实际上,我已经选择创建一个简单的Vim配置,这样我就可以掌握我选择安装的少量插件,而不是制作一大堆

最近,我的所有Python/Django开发都完全转向了Vim。我花了很多时间来定制它,直到今天,天知道我很难找到适合Python/Django开发的最佳vim插件的帮助

我决定问这个问题,这样像我这样的人可以直接从你的经历中受益: 您已经构建了完美的Python/Djangoish Vim编辑器?为我们描述它(插件、脚本、定制的.vimrc、配色方案等等)

谢谢

我的配置 好的,这是我自己的配置。实际上,我已经选择创建一个简单的Vim配置,这样我就可以掌握我选择安装的少量插件,而不是制作一大堆我永远不会掌握也不会使用的插件。以下是我使用最多的插件列表:

  • 用于文件管理
  • 是TextMate的代码片段功能的实现
  • 代码完成由Vim中默认的Omnicompletion处理
  • 要将Python文档集成到Vim中
  • 用于源代码浏览,在大文件中非常有用
  • 脚本以动态突出显示带有警告的Python代码
此外,我还在$HOME/.vim/ftplugin/中创建了一个python.vim文件,其中包含此脚本,因此我可以通过运行Shift+e从vim运行python代码:

" Execute file being edited with <Shift> + e:
map <buffer> <S-e> :w<CR>:!/usr/bin/env python % <CR>
“使用+e执行正在编辑的文件:
地图:w:!/usr/bin/env python%
我还收集了一些有用的.vimrc定制:

set nocompatible    " use vim defaults
set number          " show line numbers
colorscheme desert
set tags=tags;$HOME/.vim/tags/ "recursively searches directory for 'tags' file
set expandtab       " tabs are converted to spac
set tabstop=4       " numbers of spaces of tab character
set shiftwidth=4    " numbers of spaces to (auto)indent
set showcmd         " display incomplete commands
set hlsearch        " highlight searches
set incsearch       " do incremental searching
set ruler           " show the cursor position all the time
set numberwidth=4   " line numbering takes up 5 spaces
set ignorecase      " ignore case when searching
set nowrap          " stop lines from wrapping
filetype plugin indent on " turn on the indent plugins
syntax on                 " syntax highlighing
" TagList Plugin Configuration
let Tlist_Ctags_Cmd='/usr/bin/ctags'       " point taglist to ctags
let Tlist_GainFocus_On_ToggleOpen = 1      " Focus on the taglist when its toggled
let Tlist_Close_On_Select = 1              " Close when something's selected
let Tlist_Use_Right_Window = 1             " Project uses the left window
let Tlist_File_Fold_Auto_Close = 1         " Close folds for inactive files
" Omnicompletion functions
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
au FileType py set expandtab
au FileType py set foldmethod=indent
map <F2> :previous<CR>                  " map F2 to open previous buffer
map <F3> :next<CR>                      " map F3 to open next buffer
map <F4> :NERDTreeToggle<CR>            " map F4 to open NERDTree
map <F5> :TlistToggle<CR>               " map F5 to toggle the Tag Listing
map <silent><C-Left> <C-T>              " taglist - map Ctrl-LeftArrow to jump to the method/property under your cursor
map <silent><C-Right> <C-]>             " taglist - map Ctrl-RhitArrow to jump back to your source code
map <silent><A-Right> :tabnext<CR>      " map Alt-RightArrow to jump to the next tab
map <silent><A-Left> :tabprevious<CR>   " map Alt-LeftArrow to jump to the previous tab
set nocompatible“使用vim默认值
“设置编号”显示行号
沙漠配色方案
set tags=tags;$HOME/.vim/tags/“递归地在目录中搜索“tags”文件
“设置展开选项卡”选项卡转换为spac
设置tabstop=4“制表符的空格数
将shiftwidth=4“空格数设置为(自动)缩进
设置showcmd“显示不完整的命令
设置hlsearch“突出显示搜索”
设置incsearch“执行增量搜索
“设置标尺”始终显示光标位置
set numberwidth=4“行编号占用5个空格
设置ignorecase“搜索时忽略大小写”
设置nowrap“停止包装线
文件类型插件缩进打开“打开缩进插件
关于“语法高亮度”的语法
“标记列表插件配置”
让Tlist_Ctags_Cmd='/usr/bin/Ctags'将标记列表指向Ctags
在切换标记列表时,让Tlist_GainFocus_On_ToggleOpen=1“将焦点放在标记列表上
让Tlist_Close_On_Select=1“选择某项内容时关闭”
让Tlist_Use_Right_Window=1“项目使用左窗口
对于非活动文件,让Tlist_File_Fold_Auto_Close=1“关闭折叠
“全方位完成功能
autocmd文件类型python集omnifunc=pythoncomplete#Complete
autocmd文件类型javascript集omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd文件类型css集omnifunc=csscomplete#CompleteCSS
au文件类型py set expandtab
au FileType py set foldmethod=indent
映射:上一个“映射F2以打开上一个缓冲区
映射:下一个“映射F3以打开下一个缓冲区
映射:NERDTree切换“映射F4”以打开NERDTree
map:TlistToggle“映射F5以切换标记列表
map“taglist-map Ctrl LeftArrow以跳转到光标下的方法/属性
map“taglist-map Ctrl RhitArrow以跳回源代码
map:tabnext“将Alt RightArrow映射到下一个选项卡
map:tabprevious“将Alt LeftArrow映射到上一个选项卡

我实际上没有太多Django特定的mod,尽管我给了jinja2语法比Django模板语法更高的优先级

具体来说,对于Python:
  • 对于Python语法检查,我使用PyFlakes和突出显示拼写错误的字符mbg=darkred
  • 有时(很少)我觉得需要自动完成,在这种情况下,我使用Eclim
  • 对于其余的,默认的东西。标签大小4,软标签,等等
Vim设置:
  • 256色方案
    256

    if ((&term == 'screen') || (&term == 'screen-bce') || (&term == 'xterm')) 
        set t_Co=256                                                          
        set t_Sb=^[[4%dm                                                      
        set t_Sf=^[[3%dm                                                      
        colo desert256                                                        
    endif
    
  • 大量选项卡(
    tabe
    tabn
  • 大量拆分(垂直和水平)

我不打算在这里发布我的整个.vimrc文件,但我有一个与您类似的设置。不过,这不是Python/Django特有的,除了一些用于snipMate和Python模式的自定义代码片段。我使用的vim插件如下:

  • :在.vim目录中更好地组织了vim插件结构
  • :使用ctrl-c和ctrl-x进行更快的特定于语言的注释
  • :语法检查插件(对我来说主要用于非python代码)
  • 和:更容易处理支架、打开和关闭标签等
  • :扩展
    %
    命令,使其也匹配并循环遍历例如html标记。要循环遍历Python代码语句(例如,如果elif else),您可以下载并将其放入
    ftplugin/Python/
    目录。我将其放入
    ~/.vim/bundle/matchit/ftplugin/Python/
  • :用于Python编辑的优秀插件。在文件保存时自动检查pyflakes/pep8(或pylint,如果您愿意)。我通过
    让我的
    文件中的g:pymode\u rope=0
    禁用了自动完成,因为它在每次文件保存时对我来说都滞后。此外,语法突出显示对Python代码进行了扩展
  • (下面是python的自定义代码段)
  • :我不能没有庞大代码文件的大纲
我经常使用的一些自定义python代码片段:

snippet #utf
    # -*- coding: utf-8 -*-

snippet ds
    """
    ${1: }
    """
# just the first (or last) three quites for the docstring
snippet dss
    """${1: }
# For file headers
snippet dsfile  
    """
    :File: ${1:`Filename('$1.py', 'foo.py')`}
    :Author: ${2:`g:snips_author`}
    :Description: ${3}
    """
snippet pdb
    import pdb
    pdb.set_trace()

我的一个幻想是掌握vim,我已经试过配置我的vim一次,但没有成功,我没有找到任何简单的图托开始,但我认为它不会是坏的,如果你把你的co