Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timstott/practical-vim
https://github.com/timstott/practical-vim
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/timstott/practical-vim
- Owner: timstott
- Created: 2015-01-18T23:01:04.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-23T09:16:05.000Z (almost 10 years ago)
- Last Synced: 2023-08-05T02:25:55.535Z (over 1 year ago)
- Size: 203 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Practical Vim - Tips and Exercises
## Tip 35 - Run commands in shell
Send buffer content to stdin and use stdout to populate our buffer.
:[range] ! sh
## Tip 34 - Recall commands from history
Use `` or `` instead of arrow keys (also works in terminal).
Historical Ex commands command line window `q:`.
Historical search command line window `q/`.
Use `C-f` while in command line to enter command line window (both Ex and search)## Tip 33 - Insert the current word at the command prompt
`:%s//something/g`
## Tip 30 - Run normal mode commands across range
Do command on line (e.g. `A;`) and the repeat on visual selection or range
`:'<,'>normal .`Or in a single command
`:%normal A;`With macros
`:%normal @a;`var foo = 1
var ok = true
var hello = 'world'
var foobar = 'barbaz'## Tip 29 - Duplicate and move lines using `:t` and `:m` commands
Copy the end of the document to below current cursor
:$copy.
:$t.Copy current line to below line 6
:t6Move the end of document to below current cursor
:$m.## Tip X
Exit inset and visual mode with
## Tip 28 - Execute a command on one more consecutive lines
Line numbers as address
:2,6p
Echo lines 2 to 6:{start},{end}
Symbols
| description
-------|------------
number | line number
. | current line (where the cursor is placed)
$ | end of file
% | all lines in current fileOffset from current line
:.,.+3p
Echo current line + 3 lines## Tip 26 - Append afer a ragged visual block
var hello = 'world';
var ok = true;
var foo = 1;## Tip 21 - Visual modes
In visual mode you can switch between visual modes the same way as normal mode.
| description
------|------------
v | visual char
V | visual line
| visual block## Tip 15 - Past from a register without leaving normal mode
In insert mode, paste content from register
registers | description
----------|-----------------
+ | system clipboard
" | text of last deleted or yanked linekeys | description
----------------|-----------------------
{register} | paste content from register
{register} | paste from register and fix indent## Tip 13 - Move in insert mode
| description
--------|--------------------------
`` | Delete back one character
`` | Delete back one word
`` | Delete back to start of line`` Switch to Insert Normal mode
## Tip 11 - Combine and conquer
Sample of operator commands
|
---|---------------
c | change
g~ | swap case
gu | make lowercase
gU | make uppercasehello HELLO HeLlO
When operator command is invoked twice it acts on the current line (e.g. cc)
Text objects from plugin:
---|-----------
ae | entire file=ae autoindent entire file
gUae make entire file uppercase## Tip 10 - Simple math
perform addition (enter twice because tmux prefix)
perform substraction100
Add/Substract count with 10
110