How do I use Vim tabs as separate workspaces with different working directories?
Answer
:tabnew | lcd /path/to/project
Explanation
Vim's :lcd (local change directory) sets the working directory per window. Combined with tabs, this lets you use each tab as an independent workspace with its own project root.
How it works
:cd /pathchanges the working directory globally (all windows):lcd /pathchanges the working directory for the current window only:tcd /path(Vim 8.1+) changes the directory for the current tab (all windows in it)
Setting up project tabs
" Tab 1: Frontend project
:tabnew
:tcd ~/projects/frontend
:edit src/App.tsx
" Tab 2: Backend project
:tabnew
:tcd ~/projects/backend
:edit main.go
" Tab 3: Documentation
:tabnew
:tcd ~/projects/docs
:edit README.md
Navigating tabs
gt " Next tab
gT " Previous tab
3gt " Go to tab 3
:tabs " List all tabs
:tabclose " Close current tab
Tips
- Use
:tcd(Vim 8.1+) instead of:lcd— it applies to the whole tab, not just one window :pwdshows the current working directory, useful for confirming which project you're in- File completion (
<C-x><C-f>) and:finduse the local directory, making them project-aware - Each tab can have its own splits, buffers, and working directory — a true multi-project setup
- Combine with
:mksessionto save and restore your entire multi-project layout