Created
May 20, 2017 08:56
-
-
Save mikejakobsen/4a847eb3daf561f2f1a9f51d620c194b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| command! -nargs=? -bang Husk call <SID>Husk(<bang>0, "<args>") | |
| function! s:Husk(bang, comment) | |
| if a:comment != "" || a:bang | |
| call <SID>WriteHusk(a:comment) | |
| else | |
| call <SID>ViewHusk() | |
| endif | |
| endfunction | |
| function! s:WriteHusk(comment) | |
| let file_exists = filereadable(".todo") | |
| if a:comment == "" | |
| let comment = "(no comment)" | |
| else | |
| let comment = a:comment | |
| end | |
| let time = strftime("%F %H:%M:%S") | |
| let path_and_line = @% . ":" . line(".") | |
| let prev_lines = file_exists ? readfile(".todo") : [] | |
| call writefile([time, path_and_line, comment, ""] + prev_lines, ".todo") | |
| echo "Jeg husker " . comment | |
| endfunction | |
| function! s:ViewHusk() | |
| let file_exists = filereadable(".todo") | |
| if file_exists | |
| tabe .todo | |
| noremap <buffer> gf gF | |
| else | |
| echo "Ingen .todo fil fundet." | |
| end | |
| endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment