From d8a86a92ae825bb2863dc25f02a267f240588140 Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Sun, 2 Aug 2020 00:28:44 +0200 Subject: First release --- README.md | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ doc/tags | 2 ++ doc/vim-karlmarks.txt | 22 ++++++++++++++++++++++ plugin/vim-karlmarks.vim | 29 ++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 README.md create mode 100644 doc/tags create mode 100644 doc/vim-karlmarks.txt create mode 100644 plugin/vim-karlmarks.vim diff --git a/README.md b/README.md new file mode 100644 index 0000000..e3eedcf --- /dev/null +++ b/README.md @@ -0,0 +1,49 @@ +# karlmarks + +A teaching plugin for Vim. It uses the `signcolumn` to display currently active +`marks`. These are mostly used as jump locations and some are set by Vim +automatically during the edit sessions. Also user defined marks are shown. +These can be set with `m[a-z]`, e.g. `ma` sets mark `a` and this plugin would +display its line and you can jump to that line with ```a``. Captital letters +even allow jumps between files and session persistent marks. + +Chances are that you have learned only some of the marks Vim has to offer. This +plugin will remember you to use more and once you have that on disk you can +always deinstall it again. + + +## Prerequirements + +I recommend you use this in your `~/.vim/vimrc` + + set signcolumn=yes + +because if you set it to `signcolumn=auto` it will flicker when you change +the window. + + +## Installation + +Download the [zip file](https://git.entwicklerseite.de/vim-recently-used/snapshot/vim-recently-used-master.zip) +and extract it inside `~/.vim/pack/coderonline/start/`. + +### Example + + mkdir ~/.vim/pack/coderonline/start/ + cd ~/.vim/pack/coderonline/start/ + # download plugin in that directory: + curl -o vim-recently-used.zip https://git.entwicklerseite.de/vim-recently-used/snapshot/vim-recently-used-master.zip + # unzip the zip file + unzip vim-recently-used.zip + # remove zip file (not needed any more) + rm vim-recently-used.zip + + +## Deinstallation + +Remove the folder `~/.vim/pack/coderonline/start/vim-karlmarks` (if you named +it as suggested in the Installation section) + +### Exmaple + rm -irv ~/.vim/pack/coderonline/start/vim-karlmarks + diff --git a/doc/tags b/doc/tags new file mode 100644 index 0000000..9ff07ee --- /dev/null +++ b/doc/tags @@ -0,0 +1,2 @@ +karlmarks vim-karlmarks.txt /*karlmarks* +vim-karlmarks vim-karlmarks.txt /*vim-karlmarks* diff --git a/doc/vim-karlmarks.txt b/doc/vim-karlmarks.txt new file mode 100644 index 0000000..7867b67 --- /dev/null +++ b/doc/vim-karlmarks.txt @@ -0,0 +1,22 @@ +*vim-karlmarks* A Vim teaching plugin to show common marks in signcolumn + +============================================================================== +USAGE INSTRUCTIONS *karlmarks* + +Install the plugin and have `signcolumn=yes` in your vimrc. The plugin uses +a CursorHold autocmd to dynamically display signs int he signcolumn. If +you ever want to remove this plugin, find this text file in your vim +configuration folder with + + :echo expand("%:p:h:h") + +and delete the folder. If you want to copy its name to the clipboard you +can use: + + :let @+=expand("%:p:h:h") + +I hope this plugin helped you to memorize more of the default marks which Vim +has to offer. + + +vim:tw=78:ts=8:ft=help:norl: diff --git a/plugin/vim-karlmarks.vim b/plugin/vim-karlmarks.vim new file mode 100644 index 0000000..f0699e1 --- /dev/null +++ b/plugin/vim-karlmarks.vim @@ -0,0 +1,29 @@ +let g:markerbar_additional = '"' " position in buffer when left +let g:markerbar_additional .= '<>' " start/end last selection +let g:markerbar_additional .= '{}' " start/end paragraph +let g:markerbar_additional .= '()' " start/end sentence +let g:markerbar_additional .= '[]' " start/end sentence +let g:markerbar_additional .= '.' " last change +let g:markerbar_additional .= "^" " insert mode stopped +let g:markerbar_additional .= "'`" + +function! KarlMarks() + for c in map(split(g:markerbar_additional, '\zs'), "char2nr(v:val)") + + \ range(char2nr('a'), char2nr('z')) + + \ range(char2nr('A'), char2nr('Z')) + + \ range(char2nr('0'), char2nr('9')) + + let p = getpos("'".nr2char(c)) + + if (p[0] == 0 || p[0] == winbufnr(0)) && p[1] > 0 + exec "sign unplace ".c + exec "sign define mark_".c." text=".nr2char(c)." texthl=SignColumn" + exec "sign place ".c." name=mark_".c." line=".p[1]." buffer=".winbufnr(0) + endif + endfor +endfunction + +autocmd CursorHold * call KarlMarks() + +" important for distraction free reading while changing windows +" setlocal signcolumn=yes -- cgit v1.2.3