Skip to content

Commit

Permalink
feat: allow ".md" extension when creating new files
Browse files Browse the repository at this point in the history
Just say you want to create a file "foo.md" but you already have one
called "food.md"; you can't just type "foo" and hit enter because that
will just open the existing file. If we weren't in the terminal, and we
could actually distinguish between enter and, say, control-enter, then
we could use that as a cue to create the file. But we are in the
terminal, so we instead allow you to type "foo.md". That won't match
"food.md" unless you happen to have that string inside it (unlikely), so
in this way you can add an extension, optionally, as a way of forcing a
unique match and thus creating a new file. Subtle, but useful.
  • Loading branch information
wincent committed Jul 21, 2020
1 parent dd53157 commit 887e3f9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion autoload/corpus.vim
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,10 @@ function! corpus#choose(selection) abort
execute 'cd ' . fnameescape(l:directory)
echomsg 'Changed to: ' . l:directory
if !empty(l:file)
execute 'edit '. fnameescape(l:file . '.md')
if l:file !~? '\v\.md$'
let l:file=l:file . '.md'
endif
execute 'edit '. fnameescape(l:file)
endif
endif
endfunction
Expand Down

0 comments on commit 887e3f9

Please sign in to comment.