Files and working with Multiple Files
In day-to-day use I use plugins (such as Telescope) to make working within a project much quicker and easier but I think its still important to know the base commands as they are always there to use.
Recent files
:ol — (old files) open list of recently edited files
File Explorer
:e . — open file explorer
:Sex — split window and open file explorer
gf — open file name that is under cursor
Searching (mutiple files)
quickfix list
:vimgrep /pattern {file} — search for patern in multiple files
:vimgrep /foo/ **/*
:cl — list all entires
:cn — next match
:cp — previous match
:copen — open window with list of matches
:cclose — close window with list of matches
location list
:lvimgrep /pattern {file} — search for patern in multiple files
:lli — Display all entires
:l<num> — move to num entry
lne — move to next entry
Working with Files
buffers in vim are files, or temp storage areas of vim they can be inside of a window or tab
:e <file> — edit file in new buffer
:bn — next buffer
:bp — previous buffer
:bd — delete buffer (close file)
:ls — list open buffers
:b <substring search> — opens the buffer that matches the substing
:sp file — open file in new buffer and split window
:vsp file — open file in new buffer and vertically split window
Windows (these are panes that can be viewed simutansily)
all window commands start with CTL-w.
{CTL-ws} — split window (horizontal)
{CTL-wv} — split window vert
{CTL-ww} — switch window
{CTL-wq} — quit window
{CTL-wv} — split window vertically
{CTL-wh} — move to left window
{CTL-wl} — move to right window
{CTL-wj} — move to below window
{CTL-wk} — move to above window
`{CTL-wH}` — move to left window
{CTL-wL} — move to right window
:hide — close currernt window
:only — close all windows except current
Tabs (seprate areas that are not viewed simutansly)
:tabnew {file} — open file in new tab
{CTL-wT} — move current split window to new tab
gt / :tabn — move to next tab
gT / :tabp — move to previous tab
#gt — move to tab number #
:tabs — list all open tabs
:tab ball — puts all open files in tabs
:tabc — close current tab and all its windows
:tabo /tabonly — close all tabs except this one
Interact with filesystem
:!cmd — execute cmd and return to vim
!!pwd — execute cmd and instert output into file
r !pwd — functionally the same as above but it 'reads' the output of the command into the buffer at current point
