what's the fastest way to select a function of Python via VIM?

你。 提交于 2019-12-22 01:53:27

问题


Is it possible without any plugins? Or what's the best plugin for edit python file?


回答1:


try vis to visualy select and o to jump edges




回答2:


With this plugin https://github.com/bps/vim-textobj-python you can select, delete, change, etc:

af: a function
if: inner function
ac: a class
ic: inner class



回答3:


The way I do it is not specific to functions. It will just select a continuous code of Python code:

v]] if what you want to select is below the cursor
v[[ if it is above the cursor.

Just remove one bracket if the cursor is on the first line of the code block you want to select.




回答4:


I assume you mean visually selecting the whole function quickly. One way is to use Indent text object. You can use vai to select the whole function, provided your cursor is inside the function and only 1 indentation level lower.

If you really want select function regardless of indentation level, I suggest you read this and write your own text object. I imagine it would be quite easy since Python has def keyword for defining function.




回答5:


you have to use omnicompletion for vim7 but it's only working with vim-nox, vim-gtk, vim-gnome o vim-athen

also read throu this page for configuring vim with python (autoindend, syntax highlight and autocompletion)



来源:https://stackoverflow.com/questions/6579723/whats-the-fastest-way-to-select-a-function-of-python-via-vim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!