Vim uses :help 'path'
to define the root directories from where to search non-recursively for files.
It is used for:
gf
,gF
,<C-w>f
,<C-w>F
,<C-w>gf
,<C-w>gF
,:find
,:sfind
,:tabfind
,
#!/bin/sh | |
usage() { | |
cat <<\EOF | |
usage: git jump <mode> [<args>] | |
Jump to interesting elements in an editor. | |
The <mode> parameter is one of: | |
diff: elements are diff hunks. Arguments are given to diff. |
:help :global
is an incredibly cool command.
One thing I like to do with :global
is to list lines matching a given pattern in the current file and use that to move around. It looks like this:
:g/let/#
7 let &path .= 'src/**,public/**,static/**'
31 unlet b:gqview
33 nmap GQ :let b:gqview = winsaveview():set opfunc=Formatg@
function! Sort(type, ...) | |
'[,']sort | |
endfunction | |
nmap <silent> <key> :set opfunc=Sort<CR>g@ | |
" usage: | |
" <key>ip | |
" <key>G |
#!/usr/bin/env bash | |
set -u | |
set -e | |
set -o pipefail | |
GCP_PROJECT="$(gcloud config list --format 'value(core.project)')" | |
GCP_SERVICES=( | |
"storage-api.googleapis.com" |
Searching can be an efficient way to navigate the current buffer.
The first search commands we learn are usually /
and ?
. These are seriously cool, especially with the incsearch
option enabled which lets us keep typing to refine our search pattern. /
and ?
really shine when all we want is to jump to something we already have our eyeballs on but they are not fit for every situation:
Answer by Jim Dennis on Stack Overflow question http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118
Your problem with Vim is that you don't grok vi.
You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).
The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:
0 go to the beginning of this line. y yank from here (up to where?)