javier_domenech
javier_domenech

Reputation: 6263

How to get the tail of a path (or string) in vim

I'm tuning my vimrc and I'd like to show in my airline bar the folder where I started vim (usually my project folder).

As the vim airline help says, I use let g:airline_section_b = '%{getcwd()}' but then I get a complete path while I'd like to get the last folder.

I've tried with :t but doesn't work: let g:airline_section_b = '%{getcwd()}:t. It just shows /home/vivo/myproject:t (while I want just myproject)

Upvotes: 5

Views: 927

Answers (1)

Luc Hermitte
Luc Hermitte

Reputation: 32946

You're looking for fnamemodify() -> fnamemodify(getcwd(), ':t')

Upvotes: 9

Related Questions