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:
0for 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 wordinsert 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 0to 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.