我想知道是否有可能在vim的命令行中写下我写的东西,以便稍后再粘贴它.
这将特别有用,因为我经常通过首先搜索它们来尝试搜索/替换模式 - 如果它们符合我的需要 - 我希望能够从命令行复制搜索到的表达式并在我的命令行中使用它搜索/替换功能.
我已经知道你可以通过使用粘贴到命令窗口<ctrl-r><buffer>,我只是想知道是否有一个类似于此的命令会拉动我的整个命令窗口.
当我尝试在对象上使用自动完成时,我在VIM中发现了一个奇怪的行为:
如果我在模块级别实例化对象,VIM自动完成将对我创建的实例起作用:

如果我在函数或类中尝试相同时它不再工作:

有谁知道如何解决这个问题,还是没有办法让omnicompletion处理非模块范围内的实例?
鉴于我有以下字符串:
This is a test {{ string.string.string }}.
Run Code Online (Sandbox Code Playgroud)
并尝试执行以下替换:
%s/{{ [\w\.]\+ }}/substitute/g
Run Code Online (Sandbox Code Playgroud)
它不适用于错误:找不到模式.
我用的时候:
%s/{{ [a-zA-Z\.]\+ }}/substitute/g
Run Code Online (Sandbox Code Playgroud)
有用.
有没有办法在VIM中使用范围中的元字符类?
我遇到了以下相当奇怪的问题:
我正在开发一个django应用程序,在我的模型类中,我定义了一个在验证失败时应该引发的异常:
class MissingValueException(Exception):
"""Raise when a required attribute is missing."""
def __init__(self, message):
super(MissingValueException, self).__init__()
self.message = message
def __str__(self):
return repr(self.message)
Run Code Online (Sandbox Code Playgroud)
此代码在验证方法中从发布类调用:
def validate_required_fields(self):
# Here is the validation code.
if all_fields_present:
return True
else:
raise MissingValueException(errors)
Run Code Online (Sandbox Code Playgroud)
在我的单元测试中,我创建了一个应该引发异常的情况:
def test_raise_exception_incomplete_publication(self):
publication = Publication(publication_type="book")
self.assertRaises(MissingValueException, publication.validate_required_fields)
Run Code Online (Sandbox Code Playgroud)
这会产生以下输出:
======================================================================
ERROR: test_raise_exception_incomplete_publication (core_knowledge_platform.core_web_service.tests.logic_tests.BusinessLogicTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/media/data/Dokumente/Code/master_project/core_knowledge_platform/../core_knowledge_platform/core_web_service/tests/logic_tests.py", line 45, in test_raise_exception_incomplete_publication
self.assertRaises(MissingValueException, method, )
File "/usr/lib/python2.7/unittest/case.py", line 465, in assertRaises
callableObj(*args, **kwargs)
File "/media/data/Dokumente/Code/master_project/core_knowledge_platform/../core_knowledge_platform/core_web_service/models.py", line 150, in …Run Code Online (Sandbox Code Playgroud) 是否可以通过EX模式命令将某些行添加到视觉选择中?
我有以下形式的文字:
+----------+-----------+
| Some text| other text|
+----------+-----------+
| More text||
| And even more ||
| - ...||
+----------+-----------+
Run Code Online (Sandbox Code Playgroud)
我希望文本显示如下:
+---------------+------------+
| Some text | other text |
+---------------+------------+
| More text | |
| And even more | |
| - ... | |
+---------------+------------+
Run Code Online (Sandbox Code Playgroud)
通过以下工作流程删除带有+的行时使用表格插件:
g!/+/d
// Visually select the remaining lines
Tab /|
// Manually insert the +----+----+ lines
Run Code Online (Sandbox Code Playgroud)
我想知道是否有办法保持分界线和视觉选择不包含+通过EX模式的行:g!/+/ add-line-to-visual-selection.
尝试使用7za
Powershell中的命令行实用程序解压缩文件时遇到一个小问题.
我将$zip_source变量设置为zip文件的路径和
$unzip_destination所需的输出文件夹.
但是,7za需要参数的命令行用法指定如下:
7za x -y <zip_file> -o<output_directory>
Run Code Online (Sandbox Code Playgroud)
所以我目前的电话看起来像这样:
& '7za' x -y "$zip_source" -o$unzip_destination
Run Code Online (Sandbox Code Playgroud)
由于-o目标之间不存在空间,因此PowerShell似乎不会扩展$unzip_destination变量,而是$zip_source扩展.
目前,程序只是将所有文件提取到C:\名为的文件夹的根目录中$unzip_destination.在变量周围设置不同类型的引号既不起作用:
-o"$unzip_destination" : still extracts to C:\$unzip_destination
-o'$unzip_destination' : still extracts to C:\$unzip_destination
-o $unzip_destination : Error: Incorrect command line
Run Code Online (Sandbox Code Playgroud)
在运行命令之前有没有办法强制扩展?
我只想用Python 3设置一个小型开发环境.
我没有问题安装pip和virtualenv,但virtualenvwrapper似乎不支持Python 3中,但(因为它在规定善变回购).
尝试使用pip安装它会产生以下错误:
Running setup.py install for virtualenvwrapper
changing mode of build/scripts-3.2/virtualenvwrapper.sh from 644 to 755
Skipping installation of /usr/local/lib/python3.2/dist-packages/virtualenvwrapper/__init__.py (namespace package)
Installing /usr/local/lib/python3.2/dist-packages/virtualenvwrapper-2.11.1-py3.2-nspkg.pth
changing mode of /usr/local/bin/virtualenvwrapper.sh to 755
File "/usr/local/lib/python3.2/dist-packages/virtualenvwrapper/hook_loader.py", line 137
print ' %-10s -- %s' % (ep.name, inspect.getdoc(plugin) or '')
^
SyntaxError: invalid syntax
File "/usr/local/lib/python3.2/dist-packages/virtualenvwrapper/user_scripts.py", line 40
except OSError, msg:
^
SyntaxError: invalid syntax
Successfully installed virtualenvwrapper
Cleaning up...
Run Code Online (Sandbox Code Playgroud)
即使最后一行状态成功安装,我也无法调用virtualenvwrapper命令.
有没有人知道它适用于Python 3的替代方案?
编辑:
对于回到这个问题的人来说 - …
我想知道是否有办法查看当我按下某个键时 vim 运行哪些命令。
特别是我面临着相当奇怪的行为,即 vim 不执行我重新定义的行为来在拆分之间切换。我的 .vimrc 中有以下几行重新映射移动键:
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
nnoremap j gj
nnoremap k gk
Run Code Online (Sandbox Code Playgroud)
根据这些重新映射,我希望能够通过简单地使用 ctrl + 移动键之一在分割之间切换。
它适用于除 之外的所有键j,我想查明该键是否已被我安装的插件之一重新映射。有什么方法可以检查吗?
在vim中搜索正则表达式时,我遇到了一种奇怪的行为:
我试图清理文件中多余的空格,并希望使用substitute命令.
当我对集合使用以下正则表达式时,vim也匹配单个空格:
\%[\s]\{2,}
Run Code Online (Sandbox Code Playgroud)
当我使用相同的正则表达式与模式而不是集合时,vim只能正确匹配2个或更多的空格:
\%(\s\)\{2,}
Run Code Online (Sandbox Code Playgroud)
我知道我不需要使用集合,但如果我在在线正则表达式解析器(例如Rubular)中尝试表达式,它也可以使用集合.
谁能解释为什么这些表达式不会以同样的方式评估?
vim ×6
python ×2
regex ×2
autocomplete ×1
django ×1
powershell ×1
python-3.x ×1
unit-testing ×1
vi ×1
virtualenv ×1