Vim
You mean emacs?
Plugins
Ctrl-y in insert mode to insert text from above and Ctrl-e to insert from below
Map movement to meta keys
Vim build options

Working with CSV files in Vim
Copy pasting from and to system clipboard in Vim
Normal Mode / Visual Mode:
Pasting from system clipboard: "+p
Copy to system clipboard: "+y
Insert Mode:
Pasting from system clipboard: <C-r>+
More info here: https://vim.fandom.com/wiki/Copy,_cut_and_paste
cscope
http://cscope.sourceforge.net/cscope_vim_tutorial.html
cscope -R .
cscope -b
Vim Bookmarks (marks)
Vim has a built-in concept called “marks” (see :help mark) which allows bookmarking of locations within files. The easiest way to use marks is by pressing m followed by any letter. You can jump back to the mark you made by pressing ’ followed by the letter. A few points you should be aware of: • The a-z lowercase letter mark locations are local to each file. • The A-Z capital letter mark locations work across files. • Use ' followed by the letter to jump to the line you marked. This goes to the first non-blank character of the line. • Use ` followed by the letter to jump to the specific column on the specific line that you marked. A useful case for marks is creating simple bookmarks to jump to frequently edited locations. With capital letter mark locations, these bookmarks can transcend files and even projects, allowing you to create mappings that jump to frequently edited locations. For example — your .vimrc. Here’s a useful example I use. If you’re using a plugin manager such as vim-plug, you likely have a section of your .vimrc dedicated to listing out plugins. With your cursor positioned at the start of the plugin section, press mP. This creates a mark, P, at this location. Now, when you’re editing any file in any location, you can press ‘P to return to your plugin list. Bonus tip: Use :source % to source changes to your .vimrc file after you edit it.
https://vimtricks.com/wp-content/uploads/2021/06/marks.mp4
Print line numbers of each line at the beginning
:%s/^/\=printf('%-4d', line('.'))
ASSIGN envoronment variables on the fly
let $RUN_PATH=$PWD
Diff
To filter out matching lines and show only the lines that are
different in vimdiff
set diffopt=filler,context:0
To move lines containing a specific character - g command
:g/^+/m$
This moves all the lines containing + as the first character in their
line to end of the file.
Find matching brackets
"In normal mode"
]} " Find the matching close brackets"
[{ " Find the matching open brackets"
"Similarly for paranthesis and others"
])
[)
Vertical and Horizontal lines on cursor
set cursorline
set cursorcolumn
Vim reference card
<vimrefcard.pdf>
Resize splits / windows
https://vim.fandom.com/wiki/Resize_splits_more_quickly
" In command mode "
:resize 60
:res +5
:res -5
:vertical resize 80
:vertical resize +5
:vertical resize -5
"In normal mode"
Ctrl-w +
Ctrl-w -
Ctrl-w >
Ctrl-w <
Ctrl-w 10 +
Ctrl-w =
Ctrl-w _
Ctrl-w |
"Mappings"
nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) \* 3/2)<CR>
nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) \* 2/3)<CR>
Splitting to a specific size
Vim supports two kinds of splits: vertical (:vsplit) and horizontal (:split). You can open any file in a split by calling :split path/to/file or :vsplit path/to/file. By default, the full width or height of the current buffer will be divided in two. The new split will take up 50% of the available real estate, and the existing will be reduced to 50% of its original size. But! Vim has a way to open splits to a specific size: By prepending a number to a split command, that split will be opened to the exact character width or height you specify. For example: :20 vsplit path/to/file will open a split that is exactly 20 characters wide, instead of 50% of the current width. Note that the number includes the line numbers, gutter, and bar between buffers. For a vertical split, 4 characters will typically be lost to that space. You can enter this with or without the space between the number. For example: :30split path/to/file and :30 split path/to/file will do the same thing. We have written a ton about splits, so be sure to check the archives. Our post about resizing slits will come in handy paired with this tip.
Run vim command on all windows
:windo set scrollbind
This will run set scrollbind on all windows opened. Similar to
:windo diffthis
Vim abbreviations
:ab rtfm read the fine manual
Whenever you type ‘rtfm’ followed by punctuation such as a space or comma, the ‘rtfm’ will be expanded to ‘read the fine manual’. This also happens if you type ‘rtfm’ then press Esc or Enter.
:ab teh the
Whenever you type the word ’teh’, it will be replaced with ’the’.
:ab
List all abbreviations. A flag is shown in the first column: ‘i’ means the abbreviation will be used in insert mode, ‘c’ for command-line mode, and ‘!’ for both modes.
:una rtfm
:unabbreviate – remove ‘rtfm’ from the list of abbreviations.
:abc
:abclear – remove all abbreviations.
Note: To avoid expansion in insert mode, type Ctrl-V after the last character of the abbreviation (on Windows, type Ctrl-Q instead of Ctrl-V).
https://vim.fandom.com/wiki/Using_abbreviations
View recently opened files
https://stackoverflow.com/questions/309723/view-a-list-of-recent-documents-in-vim
:ol[dfiles] "Then to open one of the listed files, use: `'0, '1, '2, ... '9`; This is not sure to work properly
:bro ol "Browse old files and prompt for a number to switch to that file
Auto complete file names in insert mode
Ctrl-x-f
Yank to a specific register
"ayiw
This will yank into register a
Paste to a specific register
"ap
Undo in insert mode
Ctrl-u
Travel back and forth in time
:earlier 3 "Undo the last 3 changes
:earlier 5m "Go back to the state of the file 5 minutes ago
:later 2 "After undoing something, redo the next 2 changes
:later 1h "Travel forward through the change history 1 hour
As expected, you can use s, m, h, d for seconds, minutes, hours, and days, respectively.

Set a vim option from command line
vim -c 'set ai'
https://vi.stackexchange.com/questions/2973/setting-a-vim-option-from-the-command-line
Edit current shell command in vim
Ctrl-x Ctrl-e (or) Ctrl-x-e
Using Vim as calculator
Basic calculations using integers and float numbers can done within Vim easily by typing (insert-mode)
CTRL-R followed by = then, for example, 2+2 and press Enter. The
result 4 will be inserted into the document.
To find files with specific string and go to it
:vim grep /pattern/ path/**
:vim grep /pattern/gj path/**
j to no automatically jump to first match
Basic Commands
“+p: Paste from system clipboard”+y: Copy from vim to system clipboard Shift-Insert: Paste from system clipboard :term - run shell inside vim Ex - File Explorer Vexplore - Sidebar file explorer
^a - increment number in line ^x - decrement number in line ga - increment a column sequentially gx - decrement a column sequentially
CTAGS : Enable jump to definition feature using Ctags
You can jump to definition using Ctrl+] and Ctrl+t, etc. This works
for RTL files already but system verilog testbench files need to be
tagged.
LINKS
https://superuser.com/questions/429917/repeat-last-normal-mode-command-including-moves-in-vim
:echo winwidth(0) - returns current window width
Vim
Jumps
Ctrl-o
Ctrl-i
Vim filters
:.!bash " executes bash code on current line or region
:.!cmd.exe " executes cmd.exe on current line or region
:.!cal " executes cal cmd on current line or region
To execute this bash code,
#+begin_src bash
for i in {1..10}; do echo $i line; done
#+end_src
run this command on line
#+begin_src vim :.!bash #+end_src
#+BEGIN_VIM :.!bash " executes bash code on current line or region :.!cmd.exe " executes cmd.exe on current line or region :.!cal " executes cal cmd on current line or region #+END_VIM
** To find files with specific string and go to it
#+BEGIN_VIM :vim grep /pattern/ path/**
:vim grep /pattern/gj path/** j to no automatically jump to first match #+END_VIM
** To increment or decrement alphabets #+BEGIN_VIM set nrformats+=alpha
C-a C-x #+END_VIM
** Type control characters https://vi.stackexchange.com/questions/24474/vim-how-to-write-control-characters-in-file
#+BEGIN_EXAMPLE You can use CTRL-V in Insert mode as a prefix to insert the next key as a literal expression.
So if you enter CTRL-V followed by Backslash, you’ll get a ^? character inserted.
Another option, if you want to enter a character by its number, is to use CTRL-V followed by a set of digits. (See :help i_CTRL-V_digit.) A backspace character has code 127, so you can enter it with CTRL-V followed by 127, resulting on the same ^? character.
(You can inspect the ^? character with the ga command, which will show <^?> 127, Hex 7f, Oct 177, Digr DT, including the character code in decimal, hexadecimal and octal.)
In fact, one more way to enter this character is using Vim’s digraph support. In this case, you can use CTRL-K followed by D, then T, both uppercase, to enter the same ^? character. You can use the :digraphs command to get a table with all available digraphs. #+END_EXAMPLE ** Netrw *** Create a new file in current netrw directory =%= ** Abbreviations *** Create Abbreviations =ab abb abbreviations= *** Cancel Abbreviations =C-v=