Introduction#

GitHub shows basic thigns with vim

  • vimrc without plugin
  • vimrc with basic plugins
  • vim basic commands
  • nvim and lua also available here
Remote EC2 via SSM

This is my vim environment

Remote EC2 via SSM

Basic Vimrc#

" tab width
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set cindent
set autoindent
set smartindent
set mouse=a
set hlsearch
set showcmd
set title
set expandtab
set incsearch
" line number
set number
hi CursorLineNr cterm=None
" highlight current line
set cursorline
hi CursorLine cterm=NONE ctermbg=23 guibg=Grey40
" change cursor between modes
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"
" netrw wsize
let g:netrw_liststyle=3
let g:netrw_keepdir=0
let g:netrw_winsize=30
map <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 project
set path+=** "Search all subdirectories and recursively
set wildmenu "Shows multiple matches on one line
" highlight syntax
set re=0
syntax 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 keymap
map ;f : Files<CR>

Coc-Vim#

coc highlight

:highlight CocHighlightText ctermfg='white'
:highlight CocFloating ctermbg='white' ctermfg='black'
:highlight CocMenuSel ctermbg=7
:highlight Visual ctermbg=59
let 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 project
set path+=** "Search all subdirectories and recursively
set 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 #: next
Gt #: 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 cursorline
hi CursorLineNr cterm=NONE
hi CursorLine cterm=None ctermbg=254
hi Search ctermbg=Black ctermfg=White