(Remove html character entities) |
(→Copy: merge in "Paste that line" tip) |
||
Line 20: | Line 20: | ||
<pre> |
<pre> |
||
nnoremap Y y$ |
nnoremap Y y$ |
||
+ | </pre> |
||
+ | ---- |
||
+ | To copy an entire line, and paste it before the current line: |
||
+ | <pre> |
||
+ | nnoremap _ ggY``P |
||
</pre> |
</pre> |
||
+ | |||
+ | Use a count to specify the line number (default is line 1). For example, <tt>12_</tt> would copy line 12 to before the current line. |
||
==Search== |
==Search== |
Revision as of 21:32, 1 February 2009
created 2005 · complexity basic · author Anon · version 7.0
This tip presents suggestions for useful mappings. To qualify, each mapping should be short and should be useful for a common task. Other mappings belong in another tip.
This is a collection of unrelated mappings. You probably can't use all of them "as-is" at the same time. Assign your own left-hand-side as you see fit.
Copy
To copy text to the end-of-line, you can press y$ or you can use the following and press Y instead (consistent with the C and D operators, although you may prefer to have the default Y behavior of yanking the whole line):
nnoremap Y y$
To copy an entire line, and paste it before the current line:
nnoremap _ ggY``P
Use a count to specify the line number (default is line 1). For example, 12_ would copy line 12 to before the current line.
Search
It's easier to press Space than / for searching:
nmap <Space> / nmap <C-Space> ?
Highlight text on the screen matching that under the cursor: Press Ctrl-k to start; each subsequent Ctrl-l matches one more character. Uses marks "x" and "y", and register "z".
map <C-k> mx map <C-l> lmy"zy`x/<C-r>z<CR>`y
Search for word under cursor with * or # in new window:
nmap <C-W>* <C-W>s* nmap <C-W># <C-W>s#
Quickfix
" map <F3> and <S-F3> to jump between locations in a quickfix list, or " differences if in window in diff mode nnoremap <expr> <silent> <F3> (&diff ? "]c" : ":cnext\<CR>") nnoremap <expr> <silent> <S-F3> (&diff ? "[c" : ":cprev\<CR>")
Movement
" remap j and k to scroll by visual lines nnoremap j gj nnoremap k gk
Miscellaneous
nnoremap <Space> :