Skip to content

Commit

Permalink
Add FILED placeholder
Browse files Browse the repository at this point in the history
{{FILED}} expands to the absolute path of a file's parent directory.
Useful for things like automatically filling in the working directory
field in systemd units.
  • Loading branch information
barrowsys committed Sep 3, 2020
1 parent 137bbda commit 26bed70
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ The Following placeholders are currently supported by this plugin
- `FILEE` : Filename with extension `filename.ext -> filename.ext`
- `FILEF` : Absolute path of the file `/path/to/directory/filename.ext`
- `FILER` : Filepath relative to the current directory (pwd)`/relative/to/filename.ext`
- `FILED` : Absolute path of the file's parent directory `/path/to/directory`

#### License and Copyright

Expand Down
3 changes: 2 additions & 1 deletion plugin/templates.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ endif
" TIMESTAMP: DAY, DAY_FULL, DATE, MONTH, MONTH_SHORT, MONTH_FULL,
" YEAR, TODAY, TIME, TIME_12, TIMESTAMP
" AUTHOR: NAME, HOSTNAME, EMAIL
" FILE: FILE, FILEE, FILEF, FILER
" FILE: FILE, FILEE, FILEF, FILER, FILED
" PROJECT: PROJECT
" COMPANY: COMAPNY
" CURSOR: CURSOR
Expand Down Expand Up @@ -83,6 +83,7 @@ function <SID>ExpandFilePathTemplates()
call <SID>ExpandTemplate('FILEE', expand('%:t'))
call <SID>ExpandTemplate('FILEF', expand('%:p'))
call <SID>ExpandTemplate('FILER', @%)
call <SID>ExpandTemplate('FILED', expand('%:p:h'))
endfunction

function <SID>ExpandOtherTemplates()
Expand Down
1 change: 1 addition & 0 deletions test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{{FILEE}}
{{FILEF}}
{{FILER}}
{{FILED}}
{{HOSTNAME}}
{{LICENSE}}
{{CURSOR}}
Expand Down

0 comments on commit 26bed70

Please sign in to comment.