Introduction#
GitHub shows basic thigns with vim
- vimrc without plugin
- vimrc with basic plugins
- vim basic commands
- nvim and lua also available here
This is my vim environment
Basic Vimrc#
" tab widthset tabstop=2set shiftwidth=2set softtabstop=2set expandtabset cindentset autoindentset smartindentset mouse=aset hlsearchset showcmdset titleset expandtabset incsearch" line numberset numberhi CursorLineNr cterm=None" highlight current lineset cursorlinehi CursorLine cterm=NONE ctermbg=23 guibg=Grey40" change cursor between modeslet &t_SI = "\e[6 q"let &t_EI = "\e[2 q"" netrw wsizelet g:netrw_liststyle=3let g:netrw_keepdir=0let g:netrw_winsize=30map <C-a> : Lexplore<CR>" per default, netrw leaves unmodified buffers open. This autocommand" deletes netrw's buffer once it's hidden (using ':q;, for example)autocmd FileType netrw setl bufhidden=delete " or use :qa!" these next three lines are for the fuzzy search:set nocompatible "Limit search to your projectset path+=** "Search all subdirectories and recursivelyset wildmenu "Shows multiple matches on one line" highlight syntaxset re=0syntax on
Basic Plugins#
install git
sudo yum install git
install vim plug
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
add plugin for vimrc
call plug#begin()Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }Plug 'junegunn/fzf.vim'call plug#end()" fuzzy search keymapmap ;f : Files<CR>
Coc-Vim#
coc highlight
:highlight CocHighlightText ctermfg='white':highlight CocFloating ctermbg='white' ctermfg='black':highlight CocMenuSel ctermbg=7:highlight Visual ctermbg=59let g:fzf_layout = { 'window': { 'width': 1, 'height': 0.5, 'yoffset': 1}}
coc install language server
:CocInstall coc-pyright
configure fix on save prettier
:CocConfig
and add to the coc-setting.json
{"coc.preferences.formatOnSaveFiletypes": ["css","markdown","typescript","javascript","json","python"],"python.pythonPath": "/usr/bin/python3"}
Basic Vim#
create a new file with netrw
%
create a new file with vim
:edit newfile
mark a target directory
mt
mark a file
mf
move the marked file
mm mc
find files in vime then tab to select the matches
find src/filename
setpath before find a file
set nocompatible "Limit search to your projectset path+=** "Search all subdirectories and recursivelyset wildmenu "Shows multiple matches on one line
find files with fuzzy finder
:Files
window split
<C-w> v # split vertically<C-w> s # spit horizontally<C-w> h # move to right<C-w> l # move to the left<C-w> c # close current window
tab navigation
:tabedit filename-1:tabedit filename-2
navigate between tab files
gt #: nextGt #: previous
search and replace words
Tmux and Vim Basic Commands#
hide and show status bar
:set -g status off:set -g status on
new session
:new-session
kill session
:kill-session(#session number)
vim show path of an openning file
1 and ctr+g
Tips#
- 256 color cheat sheet link
- use the command :hi to find the colors you want
- regular expression to find and replace empty lines
^\s*$
cursor and cursorline setting
set cursorlinehi CursorLineNr cterm=NONEhi CursorLine cterm=None ctermbg=254hi Search ctermbg=Black ctermfg=White