Learning powerful vim commands
markdown
1. open file/close file/open terminal
`:e` file_location\filename.txt
`:clo` or `:close` close current pane/file
`:ter` or `:terminal` open a terminal
2. copy and paste file
`v+y` for copy
`p` for paste
3. split window
`ctrl-w, ctrl-s`: as shown below in gvim9.0 window toolmenu.
`ctrl-w, ctrl-v`: split vertical
![image-20221129084912049](https://raw.githubusercontent.com/GalaxyGroot/imag4typora/main/2022/1129_08_49_19.png)
4. delete content and paragraphs
d for deletion
d$: delete to the end of the line
d motion: motion could be w, e, $
d#motion: i.e. d2w for deleting two words
dd: delete the line
2dd: delete two lines
x: delete the current character
5. move to different location
line number + G: move the specific line
6. type the same words for multiple lines
The example below explains how to comment multiple lines:
- Place the cursor on the first line that you’d like to edit
- Press `Ctrl+v`
- User the arrow keys to go down until the last line
- Press `Shift+i` to go into insert mode
- Press `#`
- Press `Esc` and wait a second
7. search
/ or ? can be search the phrase: first is for forward, ? is for backward
n is to find the next occurrence
N is to find the previous occurrence
CTRL-O takes to you back to the older positions
CTRL-I to newer positions
`/[keyword]` - Searches for text in the document where keyword is whatever keyword, phrase or string of characters you're looking for
`?[keyword]` - Searches previous text for your keyword, phrase or character string
`n` - Searches your text again in whatever direction your last search was
`N` - Searches your text again in the opposite direction
`:%s/[pattern]/[replacement]/g` - This replaces all occurrences of a pattern without confirming each one
`:%s/[pattern]/[replacement]/gc` - Replaces all occurrences of a pattern and confirms each one
8. move the cursor location
w, e, $, 0: move the cursor by word, by character, end and start of the line
number + w, e: can be used moving the cursor by multiple words or characters
gt: move to the next tab
gT: move to the previous tab
G move to the end
gg move to the first line
#num G moves to the specific line number
9. match the bracket
% used for matching
10. create new file
ctrl-w, ctrl-n: create new file with new window
11. undo and redo
u for undo, U for redo
12. operator+number+motion:
13. common commands:
`d` - delete marked text
`y` - yank or copy marked text
`\ ` - shift text right
`\<` - shift text lfet
`\~` - swap case upper or lower
`:bn` - Switch to next buffer
`:bp` - Switch to previous buffer
`:bd` - Close a buffer
`:sp [filename]` - Opens a new file and splits your screen horizontally to show more than one buffer
`:vsp [filename]` - Opens a new file and splits your screen vertically to show more than one buffer
`:ls` - Lists all open buffers
`Ctrl` + `ws` - Split windows horizontally
`Ctrl` + `wv` - Split windows vertically
`Ctrl` + `ww` - Switch between windows
`Ctrl` + `wq` - Quit a window
`Ctrl` + `wh` - Moves your cursor to the window to the left
`Ctrl` + `wl` - Moves your cursor to the window to the right
`Ctrl` + `wj` - Moves your cursor to the window below the one you're in
`Ctrl` + `wk` - Moves your cursor to the window above the one you're in
14. replace with search for all occurrence
```
- Open the file in Vim
- Press slash (/) key along with the search term like “/ search_term” and press Enter. It will highlight the selected word.
- Then hit the keystroke cgn to replace the highlighted word and enter the replace_term
- Go back to normal mode. Next, hit “n” to move to the next occurrence of the search term.
- sThen press the dot (.) if you want to replace the next occurrence with the same replace_term otherwise again press the “n” key to move to the next occurrence.
```
```
$ :s///option
Note that you have to enter this command in normal mode.
Where
S: stands for substitute
search_term: the word you want to search and replace
replace_term: the word with which you want to replace it with
Option: c (for confirmation), g (replace all occurrence in one line), i (for ignoring the case)
```
Vim installation in Windows 10/11
markdown
download the following zip file from official vim download page: https://www.vim.org/download.php
**Runtime files** vim##rt.zip
> For all the following binary versions you need this runtime archive, which includes the documentation, syntax files, etc. Always get this, unless you use the self-installing executable.
create a Vim folder and extract the vim## from the zip into the Vim folder
create a _vimrc in Vim folder and copy the following into it
```python
" vim -u test/vimrc
set nocompatible
set nowrap
let bundle_dir = './bundles/'
" let src = 'http://github.com/gmarik/vundle.git'
" Vundle Options
" let g:vundle_default_git_proto = 'git'
" silent execute '!mkdir -p 'bundle_dir
" silent execute '!ln -f -s ../.vim/bundle/Vundle.vim 'bundle_dir
filetype off
syntax on
runtime macros/matchit.vim
" This test should be executed in "test" directory
exec 'set rtp^='.bundle_dir.'Vundle.vim/'
call vundle#rc(bundle_dir)
"Plugin 'jcherven/jummidark.vim'
Plugin 'tpope/vim-vividchalk'
Plugin 'frazrepo/vim-rainbow'
"call vundle#begin()
Plugin 'preservim/nerdtree'
"call vundle#end()
Plugin 'preservim/nerdcommenter'
Plugin 'molokai' " vim-scripts name
" github username with dashes
Bundle 'vim-scripts/ragtag.vim'
" original repo
Bundle 'altercation/vim-colors-solarized'
" with extension
Bundle 'nelstrom/vim-mac-classic-theme.git'
"
" invalid uri
"Bundle 'nonexistinguser/yupppierepo.git'
" full uri
Bundle 'https://github.com/vim-scripts/vim-game-of-life'
" full uri
"Bundle 'https://github.com/gmarik/ingretu'
" short uri
Bundle 'gh:gmarik/snipmate.vim.git'
Bundle 'github:mattn/gist-vim.git'
" local uri stuff
"Bundle '~/Dropbox/.gitrepos/utilz.vim.git'
" Bundle 'file://Dropbox/.gitrepos/utilz.vim.git'
" with options
Bundle 'rstacruz/sparkup.git', {'rtp': 'vim/'}
Bundle 'matchit.zip', {'name': 'matchit'}
" Camel case
Bundle 'vim-scripts/RubySinatra'
" syntax issue #203
Bundle 'jimenezrick/vimerl'
" Static bundle: Same name as a valid vim-scripts bundle
Bundle 'latte', {'pinned' : 1}
if !isdirectory(expand(bundle_dir) . '/latte')
call mkdir(expand(bundle_dir) . '/latte', 'p')
endif
"""" Basic Behavior
set number " show line numbers
set wrap " wrap lines
set encoding=utf-8 " set encoding to UTF-8 (default was "latin1")
set mouse=a " enable mouse support (might not work well on Mac OS X)
set wildmenu " visual autocomplete for command menu
set lazyredraw " redraw screen only when we need to
set showmatch " highlight matching parentheses / brackets [{()}]
set laststatus=2 " always show statusline (even with only single window)
set ruler " show line and column number of the cursor on right side of statusline
set visualbell " blink cursor on error, instead of beeping
"""" Vim Appearance
syntax enable
"colorscheme jummidark
colorscheme vividchalk
" put colorscheme files in ~/.vim/colors/
"colorscheme desert " good colorschemes: murphy, slate, molokai, badwolf, solarized
filetype plugin indent on " Automatically detect file types.
set wildignore+=doc " should not break helptags
set wildignore+=.git " should not break clone
set wildignore+=.git/* " should not break clone
set wildignore+=*/.git/*
" TODO: helptags fails with this
" set wildignore+=doc/* " should not break clone
" set wildignore+=*/doc/*
set guioptions+=T
"au VimEnter * BundleInstall
" e test/files/erlang.erl
" vim: set expandtab sts=2 ts=2 sw=2 tw=78:
"""" Miscellaneous settings that might be worth enabling
set cursorline " highlight current line
set background=dark " configure Vim to use brighter colors
set autoread " autoreload the file in Vim if it has been changed outside of Vim
""NERDTree startup
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
map :NERDTreeToggle
```
Subscribe to:
Posts (Atom)
-
This following list summarized some common used Emacs commands: 1. open file/close file - `C-x C-w`: save as to a new file - `C-x...
-
## What is the cycle slip? PLL feedback clock normally will be increased or decreased the frequency to catch up with the reference clock....
-
Same PDK to confirm the cppsim tool can be used for fast simulation in gmoverid verification. - cadence used PDK spectre model with spectre...