- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我最近从 vim 转换为 emacs (spacemacs)。 Spacemacs 自带 yapf
作为python的标准代码重新格式化工具。当代码被破坏时,我发现 autopep8 在 python 代码上工作得更好。我不知道如何使 autopep8 重新格式化选定区域,而不是整个缓冲区。在 vim 中这相当于运行 gq
对选择或对象起作用。我们如何在 emacs/spacemacs 中做到这一点?
最佳答案
我不知道你是如何调用 autopep8 的,但是这个特定的包装器已经在该区域中工作或标记了当前函数:https://gist.github.com/whirm/6122031
将要点保存在您保留个人 elisp 代码的任何位置,例如 ~/elisp/autopep8.el
.
在 .emacs
确保您的 lisp 目录位于加载路径上,加载文件并覆盖键绑定(bind):
(add-to-list 'load-path "~/elisp") ; or wherever you saved the elisp file
(require 'autopep8)
(define-key evil-normal-state-map "gq" 'autopep8)
(defun autopep8 (begin end)
"Beautify a region of python using autopep8"
(interactive
(if mark-active
(list (region-beginning) (region-end))
(list (point-min) (point-max))))
(save-excursion
(shell-command-on-region begin end
(concat "python "
autopep8-path
autopep8-args)
nil t))))
C-h f autopep8
查看现有功能的帮助。
(define-key evil-normal-state-map "gq" 'autopep8-x)
(defun autopep8-x (begin end)
"Wraps autopep8 from ??? to format the region or the whole buffer."
(interactive
(if mark-active
(list (region-beginning) (region-end))
(list (point-min) (point-max))))
(autopep8 begin end)) ; assuming an existing autopep8 function taking
; region arguments but not defaulting to the
; whole buffer itself
关于emacs - autopep8 重新格式化 emacs/spacemacs 中的区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34002435/
我正在设置(setq split-width-threshold 100)在我的 dotspacemacs/user-config ,以便在窗口足够宽的情况下使各种缓冲区水平拆分。这适用于 magit
我正在尝试在 Spacemacs 中进行项目范围的查找/替换。我试过这个: SPC s a p 输入要替换的文本。 C-c C-e 此时 Spacemacs 告诉我 text is read-only
我想删除该图像,因为它不必要地占用空间。我尝试过 fancy-splash-image nil 但没有成功。 我应该在 .spacemacs(或任何地方)中放置什么以及在哪个部分。 最佳答案 有一个名
目前,我知道可以通过以下方式创建新文件: Neotree 中的 c 键 SPC '位于shell层,并使用touch xxx命令 我想知道是否有一种简单的方法(例如SPC f xxx)。 谢谢。 最佳
我知道一些使用 neotree 或 SPC f f 重命名文件的方法,但它们涉及重命名它们。有没有办法以图形方式选择它们并将它们移动到其他目录中? 最佳答案 有人刚刚在聊天室告诉我我可以使用 dire
我在尝试安装 spacemacs 时遇到以下错误。我目前使用的是 ubuntu 17.04。 Warning (initialization): An error occurred while loa
我必须进入自定义模式来尝试一些东西,但我陷入了神圣模式,没有办法摆脱它。进入神圣模式后有办法回到 evil-mode 吗? M-m t E-h 似乎可以,但是有更好的方法吗? 最佳答案 在 Space
不知道去哪里问这个问题,所以在这里问。 我在 spacemacs 中配置组织模式(特别是组织捕获)时遇到问题。 在我的 .spacemacs 文件中(在函数 dotspacemacs/user-ini
我正在使用 spacemacs:https://github.com/syl20bnr/spacemacs 我已经尝试了将 cmd-k 覆盖为 kill-buffer 的两个用户 Hook 位置而不是
当我第一次安装 spacemacs 时,它提示我决定要配置哪种模式。我选择 vim 是因为我已经习惯了。但现在我想了解更多关于 emacs 快捷方式和键绑定(bind)的信息。所以我想回到 space
在 spacemacs 中,我经常通过 SPC-* 或 SPC-/ 在项目中搜索模式。这些命令允许我输入要搜索的模式,例如我想要跳转到其定义的函数的名称。 有时,我想将搜索限制为仅特定类型的文件,例如
我做了 , g g 跳转到该点下相同符号的定义。现在我想要 返回到我以前的文件/位置。 有约束力吗? 默认 spacemacs 安装中的绑定(bind)是什么? 最佳答案 您可以使用 '' (两个单引
是否可以在 Spacemacs 中启动 shell,就像我的主窗口旁边的一个单独的窗口一样? 我想将它用于各种任务,例如运行测试、工具和应用程序等 我主要计划将它用于 Python 编码,因此也非常欢
我正在尝试使用 flycheck使用我的 spacemacs 设置。 spacemacs documentation ,在“12.4.0.6 次要模式”下列出了 flycheck 作为可以使用 SPC
我经常使用鼠标突出显示文本,然后按cmd-c(Osx)复制突出显示的文本。但是,似乎在执行此操作时不会更新光标,因此与其将突出显示的文本复制到寄存器中,它没有将其从当前光标位置复制到突出显示的位置的末
每次我用 Spacemacs 打开 .js 文件时,默认模式是 web-mode。但我想要的是 react-mode。 有什么办法可以实现这一点吗?谢谢。 最佳答案 我从#4751找到了一些信息. 我
我刚刚从 VIM 迁移到 Spacemacs,想将制表符宽度从默认值 (\t?) 更改为仅 2 个空格。我发现像这样的命令 (setq-default indent-tabs-mode nil) 和
我知道我可以使用“SPC p f”来搜索当前项目中的文件,这对我来说意味着 git 存储库。现在,在我当前的项目中,我们有多个 git 存储库,我想在所有这些存储库中搜索文件。幸运的是,它们都位于同一
我正在尝试为 Spacemacs 自定义电力线分隔符样式。我将以下代码添加到我的 .spacemacs 文件中,作为 docs 的 11.1.5.5 部分说到做到。 (setq powerline-d
我有 spacemacs 的全新安装.当我按退出进入正常模式然后立即按 u它将大写一个单词。如果我等待一秒钟,它将撤消上一个操作。 我假设这是 evil-mode或 emacs关键和弦功能在起作用。我
我是一名优秀的程序员,十分优秀!