Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
VIM YOUR PYTHON
PYTHON YOUR VIM
Miroslav Šedivý
[ˈmɪrɔslaʋ ˈʃɛɟɪviː]
en
en, de
ä ö ü ß
en, de, sk
ä ö ü ß á č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž
en, de, sk, cs
ä ö ü ß á č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž ě ř ů
en, de, sk, cs, fr
ä ö ü ß á č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž ě ř ů à â æ ç è ë ê ï î œ ù û ÿ
en, de, sk, cs, fr, es
ä ö ü ß á č ď é í ľ ĺ
ň ó ô ŕ š ť ú ý ž ě
ř ů à â æ ç è ë ê ï î
œ ù û ÿ
ñ ¿ ¡
en, de, sk, cs, fr, es, it
ä ö ü ß á č ď é í ľ ĺ
ň ó ô ŕ š ť ú ý ž ě
ř ů à â æ ç è ë ê ï î
œ ù û ÿ
ñ ¿ ¡ ò
en, de, sk, cs, fr, es, it, pl
ä ö ü ß á č ď é í ľ ĺ
ň ó ô ŕ š ť ú ý ž ě
ř ů à â æ ç è ë ê ï î
œ ù û ÿ
ñ ¿ ¡ ò ą ć ę ł ń ś...
en, de, sk, cs, fr, es, it, pl, sv
ä ö ü ß á č ď é í ľ ĺ
ň ó ô ŕ š ť ú ý ž ě
ř ů à â æ ç è ë ê ï î
œ ù û ÿ
ñ ¿ ¡ ò ą ć ę ł...
en, de, sk, cs, fr, es, it, pl, sv, hu
ä ö ü ß á č ď é í ľ ĺ
ň ó ô ŕ š ť ú ý ž ě
ř ů à â æ ç è ë ê ï î
œ ù û ÿ
ñ ¿ ¡ ò ą ć...
en, de, sk, cs, fr, es, it, pl, sv, hu, eo
ä ö ü ß á č ď é í ľ ĺ
ň ó ô ŕ š ť ú ý ž ě
ř ů à â æ ç è ë ê ï î
œ ù û ÿ
ñ ¿ ¡ ò...
en, de, sk, cs, fr, es, it, pl, sv, hu, eo, tr
ä ö ü ß á č ď é í ľ ĺ
ň ó ô ŕ š ť ú ý ž ě
ř ů à â æ ç è ë ê ï î
œ ù û ÿ
ñ ¿...
en, de, sk, cs, fr, es, it, pl, sv, hu, eo, tr, …
ä ö ü ß á č ď é í ľ ĺ
ň ó ô ŕ š ť ú ý ž ě
ř ů à â æ ç è ë ê ï î
œ ù û ÿ
...
Switching keyboards? Searching charmaps?
Compose Key
/usr/share/X11/locale/en_US.UTF-8/Compose
<Multi_key> <period> <period> : "…" ellipsis # HORIZONTAL ELLIPSIS
<Multi_key> <...
/usr/share/X11/xkb/rules/base
compose:ralt = +compose(ralt)
compose:lwin = +compose(lwin)
compose:lwin-altgr = +compose(lw...
19:23:22 <C00LGUY> HELLO EVERYONE! WHAT’S GOING ON?
19:23:58 <me> Please hit that large key to the left from ‘A’.
19:24:10...
/usr/share/X11/xkb/rules/base
caps:ctrl_modifier = +capslock(ctrl_modifier)
setxkbmap us -option 'compose:menu,caps:ctrl_m...
if you can get two keys for the price of one
♞+[X] ⇨ Ctrl+[X]
♞ ⇨ Esc
Why just another plain Ctrl key?
xcape
“xcape allows you to use a modifier key as another key when pressed and released
on its own. Note that it is slightl...
READY TO ROCK^H^H^H^HVIM!
vi, vim, neovim
“Using a mouse is like pointing and grunting to get your point across.
Vim lets you speak in full sentences.”
@Dean, https...
vim-like software
● bash, zsh
● i3*, tmux
● qutebrowser, vimperator, vimium
● mutt, newsbeuter
● less, vifm, zathura
● feh...
xkcd.com/1205
Is it worth the time?
“If you use a (software) tool more than 1 hour a day: read at least one book on it.”
https://www.stevenvanbael.com/read-ab...
Drew Neil
● Practical Vim (2012)
● Modern Vim (2018)
● vimcasts.org
levels of vim
● core vim
● deactivate arrow keys
● remap keys
● shorten commands
● appearance
● behaviour
● plugins
@tednaleid
Don’t write too long lines that are difficult to read an
set textwidth=78
set colorcolumn=80
set scrolloff=3
set sidescrol...
Check your spellling
nmap <silent> <leader>s :set spell!<CR>
autocmd FileType python setlocal spell spelllang=en
autocmd F...
lightline
plugins
itchyny/lightline.vim
bling/vim-bufferline
altercation/vim-colors-solarized
benekastah/neomake
Shougo/deoplete.nvi...
vim or neovim?
Neovim
● works on modern systems only
● async (lint, tests!)
● python-neovim
● :terminal
● XDG directories:...
.dotfiles
~/.dotfiles/.zshrc → ~/.zshrc
~/.dotfiles/config/nvim/init.vim → ~/.config/nvim/init.vim
python-neovim
from neovim import attach
nvim = attach('socket', path='/tmp/nvim') NVIM_LISTEN_ADDRESS=/tmp/nvim nvim
nvim ...
~/.config/nvim/rplugin/python3/hello.py
import email
from email.parser import Parser
import neovim
@neovim.plugin
class He...
“The enjoyment of one's tools is an essential ingredient of successful work.”
Donald E. Knuth
Miroslav Šedivý
[ˈmɪrɔslaʋ ˈ...
Vim your Python, Python your Vim
Vim your Python, Python your Vim
Vim your Python, Python your Vim
Vim your Python, Python your Vim
Vim your Python, Python your Vim
Vim your Python, Python your Vim
Nächste SlideShare
Wird geladen in …5
×

Vim your Python, Python your Vim

703 Aufrufe

Veröffentlicht am

(PyCon.DE 2017, Karlsruhe Germany, 2017-10-25)

What do you use to write source code, docs, books or e-mails? Single brain, single pair of hands, single keyboard, but a different keyboard layout for each language and a different text editor for each purpose?

Veröffentlicht in: Technologie
  • Als Erste(r) kommentieren

  • Gehören Sie zu den Ersten, denen das gefällt!

Vim your Python, Python your Vim

  1. 1. VIM YOUR PYTHON PYTHON YOUR VIM Miroslav Šedivý [ˈmɪrɔslaʋ ˈʃɛɟɪviː]
  2. 2. en
  3. 3. en, de ä ö ü ß
  4. 4. en, de, sk ä ö ü ß á č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž
  5. 5. en, de, sk, cs ä ö ü ß á č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž ě ř ů
  6. 6. en, de, sk, cs, fr ä ö ü ß á č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž ě ř ů à â æ ç è ë ê ï î œ ù û ÿ
  7. 7. en, de, sk, cs, fr, es ä ö ü ß á č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž ě ř ů à â æ ç è ë ê ï î œ ù û ÿ ñ ¿ ¡
  8. 8. en, de, sk, cs, fr, es, it ä ö ü ß á č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž ě ř ů à â æ ç è ë ê ï î œ ù û ÿ ñ ¿ ¡ ò
  9. 9. en, de, sk, cs, fr, es, it, pl ä ö ü ß á č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž ě ř ů à â æ ç è ë ê ï î œ ù û ÿ ñ ¿ ¡ ò ą ć ę ł ń ś ź ż
  10. 10. en, de, sk, cs, fr, es, it, pl, sv ä ö ü ß á č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž ě ř ů à â æ ç è ë ê ï î œ ù û ÿ ñ ¿ ¡ ò ą ć ę ł ń ś ź ż å
  11. 11. en, de, sk, cs, fr, es, it, pl, sv, hu ä ö ü ß á č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž ě ř ů à â æ ç è ë ê ï î œ ù û ÿ ñ ¿ ¡ ò ą ć ę ł ń ś ź ż å ő ű
  12. 12. en, de, sk, cs, fr, es, it, pl, sv, hu, eo ä ö ü ß á č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž ě ř ů à â æ ç è ë ê ï î œ ù û ÿ ñ ¿ ¡ ò ą ć ę ł ń ś ź ż å ő ű ĉ ĝ ĥ ĵ ŝ ŭ
  13. 13. en, de, sk, cs, fr, es, it, pl, sv, hu, eo, tr ä ö ü ß á č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž ě ř ů à â æ ç è ë ê ï î œ ù û ÿ ñ ¿ ¡ ò ą ć ę ł ń ś ź ż å ő ű ĉ ĝ ĥ ĵ ŝ ŭ ı İ
  14. 14. en, de, sk, cs, fr, es, it, pl, sv, hu, eo, tr, … ä ö ü ß á č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž ě ř ů à â æ ç è ë ê ï î œ ù û ÿ ñ ¿ ¡ ò ą ć ę ł ń ś ź ż å ő ű ĉ ĝ ĥ ĵ ŝ ŭ ı İ þ ð fi fl ij ø ĸ ə ® © ™ µ § · • ¦ € £ ¥ ¢ … ‹ › « » ‘ ’ “ ” – — ¶ ‰ ∅ √ ± ≤ ≥ ≠ ° ¬ ⓪ ① ② ㊷ Ⓜ ⓘ ⓡ ⓞ ♯ ♫ ♥ ☺ ☹ ← → ⇒ № ⁽¹⁺²⁾ ³ ⁴ ª º ½ ⅓ ⅔ ¼ ¾ ⅕ ⅖ ⅙ ⅚ ⅛ ∞
  15. 15. Switching keyboards? Searching charmaps?
  16. 16. Compose Key
  17. 17. /usr/share/X11/locale/en_US.UTF-8/Compose <Multi_key> <period> <period> : "…" ellipsis # HORIZONTAL ELLIPSIS <Multi_key> <plus> <minus> : "±" plusminus # PLUS-MINUS SIGN <Multi_key> <apostrophe> <a> : "á" aacute # LATIN SMALL LETTER A WITH ACUTE <Multi_key> <s> <s> : "ß" ssharp # LATIN SMALL LETTER SHARP S <Multi_key> <comma> <c> : "ç" ccedilla # LATIN SMALL LETTER C WITH CEDILLA <Multi_key> <c> <S> : "Š" U0160 # LATIN CAPITAL LETTER S WITH CARON +6k more lines ~/.XCompose
  18. 18. /usr/share/X11/xkb/rules/base compose:ralt = +compose(ralt) compose:lwin = +compose(lwin) compose:lwin-altgr = +compose(lwin-altgr) compose:rwin = +compose(rwin) compose:rwin-altgr = +compose(rwin-altgr) compose:menu = +compose(menu) compose:menu-altgr = +compose(menu-altgr) compose:lctrl = +compose(lctrl) compose:lctrl-altgr = +compose(lctrl-altgr) compose:rctrl = +compose(rctrl) compose:rctrl-altgr = +compose(rctrl-altgr) compose:caps = +compose(caps) compose:caps-altgr = +compose(caps-altgr) compose:102 = +compose(102) compose:102-altgr = +compose(102-altgr) compose:paus = +compose(paus) compose:prsc = +compose(prsc) compose:sclk = +compose(sclk) setxkbmap us -option 'compose:menu'
  19. 19. 19:23:22 <C00LGUY> HELLO EVERYONE! WHAT’S GOING ON? 19:23:58 <me> Please hit that large key to the left from ‘A’. 19:24:10 <C00LGUY> why? 19:25:11 <C00LGUY> COOL, I DON'T HAVE TO HOLD THE SHIFT KEY ANY MORE! Any other key we could hack?
  20. 20. /usr/share/X11/xkb/rules/base caps:ctrl_modifier = +capslock(ctrl_modifier) setxkbmap us -option 'compose:menu,caps:ctrl_modifier'
  21. 21. if you can get two keys for the price of one ♞+[X] ⇨ Ctrl+[X] ♞ ⇨ Esc Why just another plain Ctrl key?
  22. 22. xcape “xcape allows you to use a modifier key as another key when pressed and released on its own. Note that it is slightly slower than pressing the original key, because the pressed event does not occur until the key is released. The default behaviour is to generate the Escape key when Left Control is pressed and released on its own. (If you don't understand why anybody would want this, I'm guessing that Vim is not your favourite text editor ;)” github.com/alols/xcape
  23. 23. READY TO ROCK^H^H^H^HVIM!
  24. 24. vi, vim, neovim
  25. 25. “Using a mouse is like pointing and grunting to get your point across. Vim lets you speak in full sentences.” @Dean, https://superuser.com/questions/599150/why-arrow-keys-are-not-recommended-in-vim
  26. 26. vim-like software ● bash, zsh ● i3*, tmux ● qutebrowser, vimperator, vimium ● mutt, newsbeuter ● less, vifm, zathura ● feh, ViPaint ● and more: https://xaizek.github.io/2016-08-13/big-list-of-vim-like-software/ ● plenty of text editors in “vi-mode”*
  27. 27. xkcd.com/1205 Is it worth the time?
  28. 28. “If you use a (software) tool more than 1 hour a day: read at least one book on it.” https://www.stevenvanbael.com/read-about-the-software-you-use
  29. 29. Drew Neil ● Practical Vim (2012) ● Modern Vim (2018) ● vimcasts.org
  30. 30. levels of vim ● core vim ● deactivate arrow keys ● remap keys ● shorten commands ● appearance ● behaviour ● plugins
  31. 31. @tednaleid
  32. 32. Don’t write too long lines that are difficult to read an set textwidth=78 set colorcolumn=80 set scrolloff=3 set sidescrolloff=5 set sidescroll=10
  33. 33. Check your spellling nmap <silent> <leader>s :set spell!<CR> autocmd FileType python setlocal spell spelllang=en autocmd FileType mail setlocal spell spelllang=de,en
  34. 34. lightline
  35. 35. plugins itchyny/lightline.vim bling/vim-bufferline altercation/vim-colors-solarized benekastah/neomake Shougo/deoplete.nvim Shougo/context_filetype.vim Shougo/neopairs.vim Shougo/neosnippet.vim Shougo/neosnippet-snippets zchee/deoplete-jedi rking/ag.vim ctrlpvim/ctrlp.vim tpope/vim-speeddating tpope/vim-surround nathanaelkane/vim-indent-guides tpope/vim-characterize tpope/vim-abolish tpope/vim-unimpaired tpope/vim-commentary tpope/vim-fugitive airblade/vim-gitgutter chrisbra/csv.vim elzr/vim-json tpope/vim-markdown ntpeters/vim-better-whitespace vim-scripts/vim-creole bfredl/nvim-ipy terryma/vim-multiple-cursors
  36. 36. vim or neovim? Neovim ● works on modern systems only ● async (lint, tests!) ● python-neovim ● :terminal ● XDG directories: ~/.config/nvim/init.vim instead of ~/.vimrc ● modern defaults
  37. 37. .dotfiles ~/.dotfiles/.zshrc → ~/.zshrc ~/.dotfiles/config/nvim/init.vim → ~/.config/nvim/init.vim
  38. 38. python-neovim from neovim import attach nvim = attach('socket', path='/tmp/nvim') NVIM_LISTEN_ADDRESS=/tmp/nvim nvim nvim = attach('child', argv=["/bin/env", "nvim", "--embed"]) nvim.current.buffer[0] # first line nvim.command('vsplit') # :vsplit
  39. 39. ~/.config/nvim/rplugin/python3/hello.py import email from email.parser import Parser import neovim @neovim.plugin class HelloPlugin: def __init__(self, nvim): self.nvim = nvim @neovim.autocmd('BufEnter', pattern='mutt-pad-*', sync=True) def on_bufenter(self): msg = Parser().parsestr('n'.join(self.nvim.current.buffer)) addresses = email.utils.getaddresses(msg.get_all('To')) hello_line = black_magic(addresses) first_empty = next((i for i, line in enumerate(self.nvim.current.buffer) if not line), -1) self.nvim.current.buffer.append(['', hello_line], first_empty) :UpdateRemotePlugins
  40. 40. “The enjoyment of one's tools is an essential ingredient of successful work.” Donald E. Knuth Miroslav Šedivý [ˈmɪrɔslaʋ ˈʃɛɟɪviː] linkedin.com/in/šedivý twitter.com/eumiro github.com/eumiro

×