brew install neovim
Then add the following to your ~/.bashrc
alias vi=neovim
alias vim=neovim
vi file.rb
:e file.rb
vi dir
:e dir
Or better yet, use the NERD Tree plugin: https://github.com/scrooloose/nerdtree
:NERDTree
Use :NERDTree
to show the directory. You can also configure vim to open NERD
Tree automatically when you open a directory.
Use :q
in the NERD Tree window to hide the directory structure.
I use command +/- (provided by iTerm)
:e app/models/user.rb
The ctrlp plugin provides an awesome fuzzy file search. https://github.com/kien/ctrlp.vim
To open app/models/user.rb
, you can type control-P
, followed by modusr
then hit enter.
I use :Ggrep pattern
, which is an incredibly convenient integration of the git grep
command
provided by the fugitive.vim plugin https://github.com/tpope/vim-fugitive
One handy thing about :Ggrep
is it saves your search results in the quickfixlist, which you can
open via :copen
and then very quickly navigate through all of the search results.
When combined with the vim-qargs plugin, you can use :Qdo %s/search/replace/ge | update
to perform
a search and replace on the files matched by :Ggrep
. https://github.com/nelstrom/vim-qargs
- Navigate to line in file:
123 gg
- Navigate to start of line:
0
for column 0 or_
for first non-whitespace column in line - Navigate to end of line:
$
- Delete line:
dd
- Delete word:
dw
- Insert line:
o
(insert below) orO
(insert above) - Insert word:
i word
(insert before) ora word
insert after - Save changes:
:w
- Close file and save changes:
:wq
- Close file and ignore changes:
:q!
This gets a little weird because you don't really highlight text in vim, but you can select it in visual mode.
- "yank" the highlighted text,
y
- Start a new search
/
- Use
ctrl-R 0
to add the yanked test to the search and press Enter
Once you've performed a search, you can enable :set hlsearch
or disable :set nohlsearch
search term highlighting.