Chapter 4 Neovim Text Editor
4.1 Vim wraping lines
do not break lines
for specific file (help modeline)
4.2 Profiling
" begin profiling
:profile start vim-profiling.log
" profile files matching the pattern *
:profile file *
" profile all functions
:profile func *
" execute some commands
" quit
:q
4.3 File Explorer (Netrw)
Netrw is the native file explorer of Neovim.
Common ways to open a netrw
file explorer:
Explore
: explore directory of current file,Vexplore
: explore directory of current file on a vertical split,Sexplore
: explore directory of current file on a horizontal split,Lexplore
: explore directory of current file on left split (similar to NERDTree).
For an opened netrw
split, common commands that control the appearance are:
I
: toggle the banner (same aslet g:netrw_banner = 0/1
),i
: cycle between listing styles (same aslet g:netrw_liststyle = 0/1/2/3
),gh
: hide/unhide dotfiles.
Common file operations
:
d
: create a new directory,%
: create a new file and open it,D
: delete file/directory (it only delete empty directories),R
: rename file/directory.<ctrl-h>
: update netrw
Another alternative for files operations is to use shell commands using %
as the current
directory or file path. See examples below.
:!mkdir %/dir
: create a new directory calleddir
:!rm -r %/dir
: remove recursively thedir
directory:!touch %/file.md
: create a new file calledfile.md
:e %/newfile.md
: editnewfile.md
.
Navigation and paths (browsing and current directories):
cd
: make current directory the same as the browsing directory (related tolet g:netrw_keepdir = 0/1
),gn
: make browsing directory the same as the directory below the cursor,-
: go up one directory,u
: go back to previous directory,U
: go back to subsequent directory.
Browsing:
cr
: open files/directories in current windowo
: open file in a new horizontal splitv
: open file in a new vertical splitt
: preview file in a new tabp
: preview file without leavingnetrw
P
: preview file in previous window (does not work as expected)x
: preview file with the default application
4.4 Plugin fzf.vim
fzf is a fast command-line fuzzy finder usually used to
find files, and fzf.vim is a integration of fzf
with Vim
including additional features to do fuzzy search on files, buffers,
colorschemes, so on.
Some useful commands are:
Files
: List filesBuffers
: List buffersLines
: List lines in loaded buffersBlines
: List lines in current bufferWindows
: List windows to moveAg
: List of lines in all (not hidden) files usingag
(The Silver Searcher).