diff options
author | Max Christian Pohle | 2020-08-02 00:28:44 +0200 |
---|---|---|
committer | Max Christian Pohle | 2020-08-02 00:28:44 +0200 |
commit | d8a86a92ae825bb2863dc25f02a267f240588140 (patch) | |
tree | df3590de0bc1f8f0dd506793038e956cea21bf5b | |
download | vim-karlmarks-d8a86a92ae825bb2863dc25f02a267f240588140.tar.bz2 vim-karlmarks-d8a86a92ae825bb2863dc25f02a267f240588140.zip |
First release
-rw-r--r-- | README.md | 49 | ||||
-rw-r--r-- | doc/tags | 2 | ||||
-rw-r--r-- | doc/vim-karlmarks.txt | 22 | ||||
-rw-r--r-- | plugin/vim-karlmarks.vim | 29 |
4 files changed, 102 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..e3eedcf --- /dev/null +++ b/README.md | |||
@@ -0,0 +1,49 @@ | |||
1 | # karlmarks | ||
2 | |||
3 | A teaching plugin for Vim. It uses the `signcolumn` to display currently active | ||
4 | `marks`. These are mostly used as jump locations and some are set by Vim | ||
5 | automatically during the edit sessions. Also user defined marks are shown. | ||
6 | These can be set with `m[a-z]`, e.g. `ma` sets mark `a` and this plugin would | ||
7 | display its line and you can jump to that line with ```a``. Captital letters | ||
8 | even allow jumps between files and session persistent marks. | ||
9 | |||
10 | Chances are that you have learned only some of the marks Vim has to offer. This | ||
11 | plugin will remember you to use more and once you have that on disk you can | ||
12 | always deinstall it again. | ||
13 | |||
14 | |||
15 | ## Prerequirements | ||
16 | |||
17 | I recommend you use this in your `~/.vim/vimrc` | ||
18 | |||
19 | set signcolumn=yes | ||
20 | |||
21 | because if you set it to `signcolumn=auto` it will flicker when you change | ||
22 | the window. | ||
23 | |||
24 | |||
25 | ## Installation | ||
26 | |||
27 | Download the [zip file](https://git.entwicklerseite.de/vim-recently-used/snapshot/vim-recently-used-master.zip) | ||
28 | and extract it inside `~/.vim/pack/coderonline/start/`. | ||
29 | |||
30 | ### Example | ||
31 | |||
32 | mkdir ~/.vim/pack/coderonline/start/ | ||
33 | cd ~/.vim/pack/coderonline/start/ | ||
34 | # download plugin in that directory: | ||
35 | curl -o vim-recently-used.zip https://git.entwicklerseite.de/vim-recently-used/snapshot/vim-recently-used-master.zip | ||
36 | # unzip the zip file | ||
37 | unzip vim-recently-used.zip | ||
38 | # remove zip file (not needed any more) | ||
39 | rm vim-recently-used.zip | ||
40 | |||
41 | |||
42 | ## Deinstallation | ||
43 | |||
44 | Remove the folder `~/.vim/pack/coderonline/start/vim-karlmarks` (if you named | ||
45 | it as suggested in the Installation section) | ||
46 | |||
47 | ### Exmaple | ||
48 | rm -irv ~/.vim/pack/coderonline/start/vim-karlmarks | ||
49 | |||
diff --git a/doc/tags b/doc/tags new file mode 100644 index 0000000..9ff07ee --- /dev/null +++ b/doc/tags | |||
@@ -0,0 +1,2 @@ | |||
1 | karlmarks vim-karlmarks.txt /*karlmarks* | ||
2 | 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 @@ | |||
1 | *vim-karlmarks* A Vim teaching plugin to show common marks in signcolumn | ||
2 | |||
3 | ============================================================================== | ||
4 | USAGE INSTRUCTIONS *karlmarks* | ||
5 | |||
6 | Install the plugin and have `signcolumn=yes` in your vimrc. The plugin uses | ||
7 | a CursorHold autocmd to dynamically display signs int he signcolumn. If | ||
8 | you ever want to remove this plugin, find this text file in your vim | ||
9 | configuration folder with | ||
10 | |||
11 | :echo expand("%:p:h:h") | ||
12 | |||
13 | and delete the folder. If you want to copy its name to the clipboard you | ||
14 | can use: | ||
15 | |||
16 | :let @+=expand("%:p:h:h") | ||
17 | |||
18 | I hope this plugin helped you to memorize more of the default marks which Vim | ||
19 | has to offer. | ||
20 | |||
21 | |||
22 | 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 @@ | |||
1 | let g:markerbar_additional = '"' " position in buffer when left | ||
2 | let g:markerbar_additional .= '<>' " start/end last selection | ||
3 | let g:markerbar_additional .= '{}' " start/end paragraph | ||
4 | let g:markerbar_additional .= '()' " start/end sentence | ||
5 | let g:markerbar_additional .= '[]' " start/end sentence | ||
6 | let g:markerbar_additional .= '.' " last change | ||
7 | let g:markerbar_additional .= "^" " insert mode stopped | ||
8 | let g:markerbar_additional .= "'`" | ||
9 | |||
10 | function! KarlMarks() | ||
11 | for c in map(split(g:markerbar_additional, '\zs'), "char2nr(v:val)") + | ||
12 | \ range(char2nr('a'), char2nr('z')) + | ||
13 | \ range(char2nr('A'), char2nr('Z')) + | ||
14 | \ range(char2nr('0'), char2nr('9')) | ||
15 | |||
16 | let p = getpos("'".nr2char(c)) | ||
17 | |||
18 | if (p[0] == 0 || p[0] == winbufnr(0)) && p[1] > 0 | ||
19 | exec "sign unplace ".c | ||
20 | exec "sign define mark_".c." text=".nr2char(c)." texthl=SignColumn" | ||
21 | exec "sign place ".c." name=mark_".c." line=".p[1]." buffer=".winbufnr(0) | ||
22 | endif | ||
23 | endfor | ||
24 | endfunction | ||
25 | |||
26 | autocmd CursorHold * call KarlMarks() | ||
27 | |||
28 | " important for distraction free reading while changing windows | ||
29 | " setlocal signcolumn=yes | ||