TOOL » NEOVIM » VIMSCRIPT
File
Functions 
| Function | Description | 
|---|---|
| executable(fname) | Check if fnameis executable. | 
| filereadable(fname) | Returns trueif the file is readable. | 
| filewritable(fname) | Returns trueif the file is writable. | 
| readfile(fname) | Returns a list, which each entry is a file line. | 
| writefile(list, fname, flags) | Save list of text into file. | 
Filenames 
| Function | Description | 
|---|---|
| expand() | Expand a file or path. | 
| fnamemodify() | Modify a file or path. | 
| tempname() | Generate temporary filenames. | 
To deal with filenames and its paths we use expand() and fnamemodify().
vim
let curfile = expand('%:~:.')
let arbitrary = fnamemodify('myfile', ':p:~')TIP
For more see help filename-modifiers.
| Modifier | Description | 
|---|---|
| :p | Expand to full path. | 
| :h | Head (last path component removed). | 
| :t | Tail (last path component only). | 
| :r | Root (one extension removed). | 
| :e | Extension only. | 
| :~ | Replaces $HOMEwith~. | 
| :. | Path becomes relative to $PWD. |