diff options
-rw-r--r-- | README.rst | 52 | ||||
-rw-r--r-- | ftplugin/uuid_anchor.vim | 29 |
2 files changed, 81 insertions, 0 deletions
diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..c406e2e --- /dev/null +++ b/README.rst @@ -0,0 +1,52 @@ +vim-uuid-anchor +############### + +Installation with vundle +======================== + +Just put ``Bundle 'git://git.devys.org/vim-uuid-anchor'`` in your +*~/.vim/vimrc*. + +Manual Installation +=================== + +1. Clone the git repository:: + + git clone git://git.devys.org/vim-uuid-anchor + cd vim-uuid-anchor + +3. Copy the file ``ftplugin/uuid_anchor.vim`` to your ``~/.vim/ftplugin`` + directory + +Usage +===== + +Table of content to real content example: + +1. Place yourself at the line of the item you want be jumpable:: + + 1. item 1 + 2. item 2 <-- You want to add a further description but keeping this list + simple. Place your cursor here. + 3. item 3 + +2. Place yourself in insert mode at the end of line, add a space and call the + uuid function, with default vim configuration, press ``A ``, then + ``,,uuid`` (assuming your leader is ','):: + + 1. item 1 + 2. item 2 DCE564FB + 3. item 3 + +3. At the other place in the text file, at the place of the description in our + example, you can paste the last generated uuid by pressing ``"up``:: + + DCE564FB: + Description with lot of text lines of the item 2. + Another line of description. + Last line of description. + +4. Later, when you want to jump from the item list to the description, or jump + back, simply place your cursor on the uuid and press ``*``. + +5. Be pleased by your new plugin and possibility. diff --git a/ftplugin/uuid_anchor.vim b/ftplugin/uuid_anchor.vim new file mode 100644 index 0000000..1e5dfdd --- /dev/null +++ b/ftplugin/uuid_anchor.vim @@ -0,0 +1,29 @@ +" UUID Anchor vim plugin +" Language: Python (ft=python) +" Maintainer: VG <vg@devys.org> +" Version: Vim 7 (may work with lower Vim versions, but not tested) +" URL: http://git.devys.org/vim-uuid-anchor + +" Only do this when not done yet for this buffer +if exists("g:loaded_uuid_anchor_ftplugin") + finish +endif +let loaded_uuid_anchor_ftplugin = 1 + +function! CreateAnchorUUID() +python << EOF +import vim +import random +generated_uuid = '{:08X}'.format(random.randint(0,256**4)) +vim.current.line += generated_uuid +vim.command(''' normal l"uye ''') +EOF +endfunction + +" Add mappings, unless the user didn't want this. +" The default mapping is registered, unless the user remapped it already. +if !exists("no_plugin_maps") && !exists("no_uuid_anchor_maps") + if !hasmapto(' CreateAnchorUUID(') + imap <leader><leader>uuid <C-o>:call CreateAnchorUUID()<CR> + endif +endif |