vim

" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now vim acts like a specialized application for learning vim

" type ,c (that's comma c)
" You don't really know the command at all and want to see it again soon.
" ,c moves the current command down a several positions in the 'Study' stack
" so you'll see it again soon.
nmap ,c ^v/^$<cr>dma/^$<cr>/^$<cr>/^$<cr>/^$<cr>jP'azt<c-y><c-l>

" type ,, (that's comma comma)
" You know the command pretty well, but not enough to move it to 'Known'.
" ,, moves the current command to the bottom of the 'Study' stack.
nmap ,, ^v/^$<cr>dma/^= Known<cr>P'azt<c-y><c-l>

" type ,k (that's comma k)
" You have the command down cold.  Move it to the 'Known' stack.
" ,k moves the current command into the 'Known' stack.
nmap ,k ^v/^$<cr>dma/^= Known<cr>jjP'azt<c-y><c-l>

" type ,h (that's comma h)
" or
" type ,j (that's comma j)
" Hide or show the commands by changing their background color.  If you hide
" the command it's much harder to cheat by looking ;)
highlight CommandsHidden guifg=white guibg=white
nmap ,h :match CommandsHidden /^\n.*$/<cr>:highlight Cursor guifg=white guibg=white<cr>
nmap ,j :match CommandsHidden //<cr>:highlight Cursor guifg=white guibg=black<cr>

" Ok, it's time to get this party started.  Move to the top of the study stack
" and go for it!
/^= Study
normal jztj
nohls

" Note: this line keeps the rest of the file from being treated as vimscript
finish

-----------------------------------------------------------------------------

= Study

g?
reverse the characters in a visual selection

<c-w>x
exchange the window with the next window (like if you split a new buffer into the wrong window location)

:echo line('.')
in command mode, echo the current line number

va(
visually select *around* a set of parentheses.  Try it by moving the cursor (somewhere in here) and trying it

rm /tmp/clip.txt ; vim -c "normal \"+p" -c "wq" /tmp/clip.txt
Save the contents of the clipboard to a file by opening, pasting into, and closing vim.

Tx
move the cursor backward to right before the previous occurrence of the character x on the current line.

Fx
move the cursor backward to the previous occurrence of the character x on the current line.

<c-b>
scroll back one page

fx
move the cursor forward to the next occurrence of the character x on the current line

zt
move current line to top of page

tx
same as fx, but moves the cursor to right before the character, not all the way to it.

<c-f>
scroll forward one page

zz
move current line to middle of page

;
repeat the last f command you gave

zb
move current line to bottom of page

yy@"
execute the vim code in the current line.  To execute it in the shell, type :! at the beginning of the line

mA
mark: set a mark in the 'A' register (globally)

gu
make the selected text lower case

gU
make the selected text upper case

<c-r>"
paste yanked text into the vim command line

'A
mark: return to a globally set mark, even if in another buffer

<c-x><c-l>
line completion

<c-i>
move forward in the jump list

<c-o>
move backward in the jump list

gf
open file under the cursor

:%s/\r//g
remove all those nasty ^M characters from the end of each line in a file

=
autoindent lines already selected in visual mode

==
autoindent current line

<c-o>
in insert mode switch to normal mode for one command

gqap
format the current paragraph

'.
jumps to last modified line

`.
jumps to exact position of last modification

:h slash< CTRL-d >
list all help topics containing the word "slash"

g;
go backward in the change list in a file

g,
go forward in the change list in a file

"ayy
yank the current line into register "a"

zj
fold: moves the cursor to the next fold

zk
fold: moves the cursor to the previous fold

:map <f6>
show what is currently mapped to <f6>

:map
show all the mappings

:reg
show the content of all registers

zr
fold: decrease the fold level by one

zm
fold: increase the fold level by one

<c-6>
toggle between last two buffers

<c-r>=5*5
in the vim command line, insert the result of a 5*5 calculation

qQ ... added commands ... q
append more commands to a pre-existing @q register macro

:Rextract _partial_name.erb
rails.vim: extract some functionality into a partial

:Rintegrationtest
open the cucumber feature with that name [tag:setup_specific:gem]

<c-p>
(while searching or ex mode) do previous search or command

<c-n>
(while searching or ex mode) do next search or command

<c-f>
(while searching or ex mode) see previous searches or commands

:%s/forward//gn
count the number of occurrences of "forward" in a file

q:
see previous commands

q/
see previous searches

{
back a paragraph

}
forward a paragraph

(
back a sentence

)
forward a sentence

%
find matching parenthesis

J
join two lines

gq
reformat the selected text

xp
transpose two letters (delete and paste, technically)

e
move to the end of the word

ea
append at end of word

w
move the cursor forward by a word

b
move the cursor backward by a word

<c-v>
in insert or command-line mode this turns the next thing typed into a literal

:set spell
Switch on spell checking

<c-x><c-s>
in insert mode correct the spelling of the current word

<c-v>jjjI//<esc>
block comment the next three JavaScript lines

"+y
copy the current selection to a clipboard where other programs can use it

ci"
change all the words in between two quotes

/<c-r><c-w>
switch to search command mode, then copy in the word under the cursor

:cn
Go to the next item in the quickfix list

:cp
Go to the previous item in the quickfix list

i<c-r>:
insert last command line command

i<c-r>/
insert last search command

:w !sudo tee %
save the current file as root (in case you opened it up without sudo accidentally and made changes to it)

<c-r>:
in Ex mode, insert the last command

<c-y>
In insert mode, insert the character right above the cursor

<c-u>
In insert mode, delete the current line from the cursor position to the beginning of the line. [tag:learn:gem]

<c-a>
In insert mode, re-insert the text inserted in the previous insert session.

<c-r>/
in Ex mode, insert the last search

<c-f>
When typing something into the command line, switch to the editable command-line mode where the command line becomes a fully vim-compatible text area. [tag:learn:gem]

o
when in a visual selection, which key will toggle to the other end of the selection?

:h i_CTRL-R
get help for how control r is used in insert mode

:h c_CTRL-R
get help for how control r is used in command mode

:s/\%V //g
remove all the spaces from the current visual selection, which is only a partial line, not a full line

:retab
if expandtab is set, this will change all the tabs to spaces, expanding them as appropriate

<c-w>_
maximize size of window split

I
insert at the beginning of the line

gv
remark area that was just marked

ZZ
same as :wq

<c-l>
redraw the screen

<c-x><c-f>
completes using filenames from the current directory.

<c-v>
block selection (column editing)

zo
fold: open a fold at the cursor

D
delete to the end of the line

C
change to the end of the line

:so $MYVIMRC
reload the vimrc file (or ":so %" if you happen to be editing the file)

A
append at the end of the line

<c-x>
decrement a number when in normal mode

<c-a>
increment a number when in normal mode

m
NERDTree: opens the filesystem menu for a file, allowing you to remove, rename, etc

ma
mark: set a mark in the 'a' register in the current buffer

`a
mark: return to the 'a' mark in the current buffer

<c-i>
next

<c-o>
old

~
uppercase or lowercase the character under the cursor

.
repeat the last command

<c-w><c-w>
switch between windows

[I
show lines containing the word under the cursor

redir @a
redirect the output of an Ex command into buffer a

= Known

:wq
write the file and quit.  This is basically here just so that there's something in the "Known" stack

你可能感兴趣的:(vim)