Skip to content

Commit cb89ae8

Browse files
Add clip copy (#3)
* Add clip copy * Fix command * Fix clip command * Remove leftover line, oops * Add more docs
1 parent 9f1ea09 commit cb89ae8

2 files changed

Lines changed: 54 additions & 13 deletions

File tree

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,25 @@ nnoremap <Leader>z :call OpenDrafts()<CR>
3737
```
3838

3939
## Use
40-
- Open vim and run `:Draft` or `:Draft "<Title>"` to auto name with the date and time
41-
- Edit the file extension `:DraftExt .md` to change the file to markdown
40+
41+
42+
### Commands
43+
44+
|-------------------------|-------------------------------------------------|
45+
| Command | Description |
46+
| `:Draft` | Open a blanck new draft |
47+
| `:Draft <title>` | Open a draft with a title |
48+
| `:DraftExt <extension>` | Change the file extension of a draft |
49+
| `:Drafts` | Open the draft directory in a buffer |
50+
| `:DraftCopy` | Copy the contents of the draft to the clipboard |
51+
|-------------------------|-------------------------------------------------|
52+
53+
### More info
54+
55+
- New draft: run `:Draft` or `:Draft "<Title>"` to auto name with the date and time
56+
- Edit the file extension: run `:DraftExt .md` to change the file to markdown
57+
- Open the drafts directory: run `:Drafts`
58+
- Copy the contents of the current draft `:DraftCopy`
4259
- Draft will open a new file in a specific directory, with a unique name
4360
- The file will be based on a template with stuff like the title and datetime
4461

@@ -49,9 +66,25 @@ nnoremap <Leader>z :call OpenDrafts()<CR>
4966
#### Vundle
5067
`Plugin 'jakeroggenbuck/draft.vim'`
5168

69+
## Versions
70+
71+
#### 0.1 draft.vim - not fully functional, just a concept
72+
73+
- Open a new draft with a name
74+
- List the draft but no reopening them
75+
76+
#### 0.2 draft.vim - first complete version
77+
78+
- Add `OpenDrafts()`
79+
- Add new command aliases `Draft`, `DraftExt`
80+
81+
#### 0.3 draft.vim - more features
82+
83+
- Add `ClipDraft()` or `DraftCopy`
84+
- Add `Buffer reload for DraftExt`
5285

5386
## TODO
54-
- Keybind or function call to copy contents with and without header to file
87+
- Keybind or function call to copy contents without header to file
5588
- Make a convert to pdf for markdown
5689

5790
## Maybe TODO

plugin/draft.vim

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" draft.vim - Quickly writeup and save drafts for messaging apps in your favorite editor
22
" Authors: Jake Roggenbuck
3-
" Version: 0.2
3+
" Version: 0.3
44
" License: MIT
55

66
if exists('g:loaded_draft_plugin') || &compatible || v:version < 700
@@ -11,10 +11,25 @@ let g:loaded_draft_plugin = 1
1111

1212
let s:plugin_root_dir = fnamemodify(resolve(expand('<sfile>:p')), ':h')
1313

14+
1415
func! g:OpenDrafts()
1516
execute ":edit" . g:drafts_directory
1617
endfunc
1718

19+
func! g:ChangeFileExt(ext)
20+
execute "file " . expand('%:p') . a:ext
21+
" Reload buffer
22+
:w
23+
:e!
24+
endfunc
25+
26+
func! g:ClipDraft()
27+
" Copy the contents of the file to clipboard
28+
:w
29+
execute ':silent !command xclip -sel clip ' . expand('%:p')
30+
endfunc
31+
32+
1833
func! s:SourcePython()
1934
py3 << EOF
2035
import sys
@@ -58,14 +73,7 @@ for file in list_drafts(drafts_directory):
5873
EOF
5974
endfunc
6075

61-
func! g:ChangeFileExt(ext)
62-
let s:filename = expand('%:p')
63-
execute "file " . s:filename . a:ext
64-
" Reload buffer
65-
:w
66-
:e!
67-
endfunc
68-
6976
command! -bar -bang -nargs=? Draft call NewDraft(<q-args>)
7077
command! -bar -bang -nargs=? DraftExt call ChangeFileExt(<q-args>)
71-
command! -bar -bang OpenDrafts call OpenDrafts()
78+
command! -bar -bang DraftCopy call ClipDraft()
79+
command! -bar -bang Drafts call OpenDrafts()

0 commit comments

Comments
 (0)