Paths in Vim

Paths in Vim

Content #

Displays the relative path of current file.

:echom expand('%')

Displays the full, absolute path of current file.

:echom expand('%:p')

Display an absolute path to the file foo.txt in the current dicrectory, regardless of whether that file actually exists.

:fnamemodify('foot.txt', ':p')

Listing of files in a specific directory.

:echo globpath('.', '*')

Displays a vimscript list containing each path.

:echo split(globpath('.', '*'), '\n')

Displays a list of all .txt files in the current directory.

:echo split(globpath('.', '*.txt'), '\n')

List all files and directories under the current directory.

:echo split(globpath('.', '**'), '\n')

From #

:help wildcards
:help filename-modifiers
:help resolve()
:help simplify()