I am using Python but some pre-defineted snippets are acting not as I wanted, hence I want to remove some, if possible.
In most cases, I am using TAB
for indent alignment, hence yasnippets
apply themselve, which is pretty annoying.
For example:
In a Python file writing log
and press TAB
, emacs
write followings code piece, which I want to disable:
logger = logging.getLogger("name")
logger.setLevel(logging.level)
my setup:
(add-hook 'python-mode-hook 'lsp)
(add-hook 'python-mode-hook #'lsp-deferred)
# taken from: https://github.com/joaotavora/yasnippet
(add-to-list 'load-path
"~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)
Hide Yas Snippet Dirs: [Value Menu] List of directories:
[INS] [DEL] Choice: [Value Menu] Directory: ~/.emacs.d/snippets
[INS] [DEL] Choice: [Value Menu] Variable: yasnippet-snippets-dir
[INS] [DEL] Choice: [Value Menu] Variable: yasnippet-classic-snippets-dir
Please note that when I try to create a new snippet it generates it under /home/user/etc/yasnippet/snippets/python-mode/
instead of ~/.emacs.d/snippets
.
Default snippets are located under /usr/share/yasnippet-snippets/python-mode
; but since they require permission would it be a good idea to remove the ones that I don't want to use?
For example I want to remove following snippet keys for:
__str__
, str
, size
, def
, self
, __
Basically,I just want to remove all key
snippets for the given key. For example, when I type str
and press TAB
emacs says:
Possible completions are:
__str__ str
. Choose a snippet:
where I don't want to see neither of it and completely remove all keys for the str
key.
# key: ...
;# binding: ...
See the tutorial: joaotavora.github.io/yasnippet/snippet-development.html If you don't like the key that triggers the snippet, then remove the entire line, or simply change the key to something you like better ... I'm sure there is a way to reload the snippets on the fly after manually modifying them, but it is probably easier to just turn on/off the minor-mode, or restart Emacs. Keep in mind that snippets can be inherited from another major-mode snippet folder.# key: str
but I couldn't where the main file for it to change @lawlist