如何在emacs中的换行符处自动引用长字符串
虽然我真的很喜欢PyCharm,但我真的想学习如何在emacs中做到这一点。当我清理pep8冲突,特别是长线冲突时,我非常欣赏PyCharm自动引用行尾或添加我通常在emacs中手动执行的任何其他操作的能力。在emacs中是否有一个插件可以实现同样的功能?例如: 发件人:如何在emacs中的换行符处自动引用长字符串,emacs,editor,emacs24,Emacs,Editor,Emacs24,虽然我真的很喜欢PyCharm,但我真的想学习如何在emacs中做到这一点。当我清理pep8冲突,特别是长线冲突时,我非常欣赏PyCharm自动引用行尾或添加我通常在emacs中手动执行的任何其他操作的能力。在emacs中是否有一个插件可以实现同样的功能?例如: 发件人: output_string+='Column Type Required' 当我将新行添加到以下位置时,它将自动添加所需的行尾: output_string += '<table border="1"><t
output_string+='Column Type Required'
当我将新行添加到以下位置时,它将自动添加所需的行尾:
output_string += '<table border="1"><tr><th>Column</th> <th>Type</th> ' \
88 '<th>Required</th></tr>'
output\u string+='Column Type'\
88“必需”
添加到您的设置中:
(defun python-newline ()
(interactive)
(let ((char (car (inside-string?))))
(if char
(progn
(insert (format "%c \\" char))
(newline-and-indent)
(insert (format "%c" char)))
(newline))))
(add-hook
'python-mode-hook
(lambda()
;; ...
(define-key python-mode-map (kbd "RET") 'python-newline)))
(defun inside-string? ()
(interactive)
(let ((p (nth 8 (syntax-ppss))))
(memq (char-after p) '(?\" ?\'))))
添加到您的设置中:
(defun python-newline ()
(interactive)
(let ((char (car (inside-string?))))
(if char
(progn
(insert (format "%c \\" char))
(newline-and-indent)
(insert (format "%c" char)))
(newline))))
(add-hook
'python-mode-hook
(lambda()
;; ...
(define-key python-mode-map (kbd "RET") 'python-newline)))
(defun inside-string? ()
(interactive)
(let ((p (nth 8 (syntax-ppss))))
(memq (char-after p) '(?\" ?\'))))
在BTW发出功能请求为什么要添加新行,为什么不让Emacs像文本模式下的
自动填充
那样-只在此处添加反斜杠?在BTW发出功能请求为什么要添加新行,为什么不让Emacs像文本模式下的自动填充
那样做呢?只是在这里添加了反斜杠?我已经尝试过了,它可以工作,只是现在如果它是上下文敏感的,就像在大括号或圆括号中一样,它将不会添加“\”字符,因为它不需要。请提供一个简单的示例。另外,python新行
绑定到C-m
。如果你什么都不想做,你可以只C-j
。我已经尝试过了,它可以工作,只是现在如果它是上下文敏感的,比如在大括号或括号中,它将不会添加“\”字符,因为它不需要。请提供一个最小的示例。另外,python新行
绑定到C-m
。如果你什么都不想做,你可以C-j
。