【大数据】Spark优化经验&案例--数据倾斜 《Mysql必知必会》读书笔记 jar包名中自动添加git commit id PyCharm教学视频学习笔记 《SQL基础教程》简要总结 《设计师要懂心理学》读书笔记 MySQL与MariaDB学习笔记 WDT (Folly) 安装指南 -- CentOS 7 [solved]Page build failed(Jekyll) 数据包过滤及分析实例 tshark tcpdump Scala Tour 学习总结 “Docker容器和容器云”读书笔记(1) “Docker Practice”读书笔记 “图解基础设施设计模式”小结 “图解服务器端网络架构”小结 Python网络安全编程 数据包解析笔记 华为挑战赛(1) DDoS攻击防御与云服务 基于网络回溯分析技术的异常行为分析 “Linux程序设计”小结(进程间通信) C语言编程规范(华为软件精英挑战赛) 2017阿里在线编程题--单源最短路径问题 2017年阿里在线编程题-- 数串分组 Uinx/Linux上的帮助查询命令 你懂C,所以C++不在话下 一篇特别长的总结(C专家编程) 程序员面试金典--笔记(精华篇) C陷阱与缺陷--笔记 半小时搭建电子商务网站--opencart linux网络知识和工具(持续更新) 网卡参数查询及设置工具ethtool 高性能流量生成工具trafgen(DDoS模拟) Linux流量控制工具TC 流量控制工具TC详细说明 tcpdump过滤数据包,结果不对? Lecture 网络攻击与防御技术笔记 gotgit-git权威指南 高效使用MacOS所要知道的 shell内置字符串处理 配置ntp(知其所以然) 360黑客攻防技术分享会--记录 中毒U盘恢复--快捷键病毒 Tor--anonymity network介绍(PPT) IBM bluemix 再读《Linux Shell脚本攻略》 linux shell 学习摘记(9) linux shell 学习摘记(8) linux shell 学习摘记(7) linux shell 学习摘记(6) linux shell 学习摘记(5) linux shell 学习摘记(4) linux shell 学习摘记(3) linux shell 学习摘记(2) linux shell 学习摘记(1) firefox vim 插件 vimperator A Byte of Vim 笔记 windows注册表小知识 安全测试工具篇(开源&商业) 安全及性能测试工具(网站收集) 性能测试工具 屡试不爽的“3个”iPad使用技巧 Shell Shortcuts(和Tab键一样实用) vim--自动添加jekyll post信息头 vim 自动给文件添加头部信息 GitHub Tips (很实用,值得收藏) Linux路由、防火墙、NAT命令

A Byte of Vim 笔记

2016年09月22日

作为一名vim深度用户,A Byte of Vim 一直是自己最喜欢的读物。我会向任何想学习vi/vim的朋友推荐它。
务必读英文原版! 英语简单,书也简明!在此感谢swaroopch大神。

下面是自己整理的“A Byete of Vim”笔记,用于回忆和自测。更可作为检测自己是否是一名合格的vim用户!!

1.Perface

“There is no great writing, only great rewriting.” – Louis Brandeis
“Vim if one of the few pieces of software that I use for nearly 10 hours a day.” – Authors
The mantra is Concepts. Examples. Pithy
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.

2.Introduction

Powerful means following the paradigm of “Minimal effort. Maximal effect.”

Press * Run :sp Run :50 Run :,100s/old/new/g Press gf

Run :colorscheme desert Run :nmap <c-s> :w<CR>

Run :mksession ~/latest_session.vim -> vim -S ~/latest_session.vim

Run :syntax on -> :set filetype=Wikipedia

Run :set foldmethod=indent Run :tabedit <file>

Press ctrl-n(自动补全) Run :0,10s/form/to/gc Run :%s/from/to/g

Run :help vim-modes-intro Run :edit hello.txt<–>:e hello.txt

Run :help notation(帮助理解命令的含义) Run :help keycodes(特殊按键的表示方法)

Press :ab swf shiwenfeng

Press vab(选定括号内的全部内容help ab) Press dw Press 2d3w

3.Modes

There are three basic modes in Vim - normal, insert and visual

Run :echo "hello world" Run :help usr_toc:help user-manual

Run :help index(可寻找感兴趣的内容)

Run :help vim-modes-intro Run :help mode-switching

Important –> a,A i,I o,O r,R s,S v,V(这个很重要)

+---------+ i,I,a,A,o,O,r,R,s,S +----------+
| Normal  +---------->------------+ Insert |
| mode    |                       | mode   |
|         +----------<------------+        |
+-+---+---+         <Esc>         +--------+
    | |
    | |
    | |
v,V V ^ <Esc>
    | |
    | |
+---+---+----+
| Visual     |
| mode       |
+------------+

4.Typing Skills

vi/vim graphical cheat sheet:

image_1at8j2ohpfprnvl148oi93rb39.png-159.6kB

image_1at8j38d7c7e76cd8u3mgivsm.png-78kB

Press } { ( )

Press ctrl-o(the previous location) Press ctrl-i

Press ^ $ ctrl-f crtl-b

Press G H(highg) M(middle) L(low) Press : help word-motions

Press :help cursor-motions

Press :help text-objects Press :help object-motions

Press :help motion

press :help various-motions

5.Help

“The true delight is in the finding out rather than in the knowing”

Run :help Run :help user-manual

Run :help abbreviate Press ctrl-]

Run :helpgrep gt(这个很有用,模糊查询)

Run :cnext Run :cprev Run :clist (这类用的少)

Press ma -> Press 'a Press ~

Run :let &keywordprg=':help' –> K(快捷帮助)

6.Editing Basics

“If I had eight hours to chop down a tree, I’d spent six hours sharpening my axe” – Abraham Lincoln

Run :swapname Run :help swap-file

nmap <c-s> :w<CR>

imap <c-s> <Esc>:w<CR>a

Run :e ../tmp/test.txt :cd :pwd

Run :e C:\\shopping\\monday.txt

y -> yank

1G and | -> moves to the first line and the first column respectively

Run dl dw

yy -> operation name twice, it will operate on the

yap -> yank the current paragraph

xp -> swap two characters

dwwP -> swap two words

m{a-zA-z} -> '{a-zA-Z}({}内是可选字母范围)

u/U <-> ctrl-r –> undolevels :earlier 4m(比较有用,回到4分钟之前) :later 45s

:undolist Run :help :undolist/undo-redo/usr_32.txt

set incsearch/ignorecase/smartcase(设置搜索配置) –> /step /Step

Run :help vimrc-intro :help pattern

Run :/\<step\> /\d\+(匹配数字)

7.Multiplicity

:set foldmethod=indent –> zc zo za

:nnoremap <space> za –> noremap

Run :help buffer-list :buffers(查看当前的buffers) :b 1:e XX.txt(切换到对应的buffer) :ls

:sp or ctrl-w s :vsp or ctrl-w v

ctrl-w r –> rotate the windows

ctrl-w K –> move the current windows to the topmost position

ctrl-w _ –> make the cutternt windows as big as possible

ctrl-w = –> make the windows ‘equal’ in height again

:resize 10

:help windows

:tabnew :tabc :help tabpage

:tabmove 0 :tabdo(在每个标签中执行命令)

`:help setting-guitablabel:

8.Personal Information Management

9.Scripting

gUl –> to switch the first letter to upper case

g#(匹配的是word) #(匹配的是\<word\>单个词) g* *

qa –> to start recording the macro named as a (register)
q –> stop recording the macro
@a –> apply this to other lines

. –> repeat the last action

:colorscheme desert –> to cycle through the available schemes

:echo strlen(getline('.'))

:let len = strlen(getline('.'))

:echo "We have 'len' characters in this line."

:echo $HOME :echo &filetype :echo @a

:help function-list

:source capitalize.vim :call Capitalize()

:echo has("python")

:help eval :help python-commands :help perl-using

:help ruby-commands

10.Plugins

the colon is optional when writing scripts in files

There are various kinds of plugins that can be written

  1. vimrc –> for general customizations
  2. global plugin
  3. filetype plugin
  4. syntax highlighting plugin
  5. compiler plugin

gvimrc –> for GUI specific customizations

:help vimrc

vim -u NONE -> start up Vim without any initialization scripts being run

:hlep -u :help starting

11.Programmers Editor

“Let’s me reiterate that typing skills is critical for a programmer”
“We are typists first, programmers second”

:set filetype=vim $VIMRUNTIME/syntax –> the list of language types available

svn diff | vim -R -(这个还比较实用)

:set autoindent :set smartindent

% -> bounce(curly bracket)

! -> shell commands :sh -> a full-fledged shell :%!sort

gf -> open the file gd -> move to the local definition of the variable name (实用)

gD -> the global declaration ]]

:help object-motions [I -> display all lines that contain they keyword under the cursor

:Vex:Sex (在新窗口中打开当前目录)

ctags cscope :make

omnicompletion -> pythoncomplete.vim -> ftplugin/complete.vim

:runtime! autoload/pythoncomplete.vim

~/.vimrc -> autocmd FiltType python runtime! autoload/pythoncomplete.vim

ctrl-n ctrl-p

:help new-omni-completion

imap <c-space> <c-x><c-o> -> omnicompletion

snippet -> SnippetsEmu

:source % :runtime! ftplugin/python_snippets.vim

12.More

Modeline -> vim: noexpandtab

Portable Vim -> GVimPortable.exe

Upgrade plugins -> :GLVS(which stands for ‘G’et ‘L’atest ‘V’im ‘S’cripts) -> :help getscript

Dr.Chip’s plugins -> drawit.vim

Blog from Vim -> Vimpress plugin

Make Firefox work like Vim -> Vimperator add-on

Contribute to Vim -> :help development

Bram’s talk on the seven habits -> “Seven habit of effective text editing”

Community -> hang out at the vim@vim.org

13.What Next

The other important resources -> “Best of Vim Tips” :help user-manual -> the all-important

:help new-7


知识共享许可协议
SWF's Hacking Dreamonephone 创作,采用 知识共享 署名-非商业性使用 4.0 国际 许可协议进行许可。
© 2011-2024. All rights reserved by onephone. Powerd by Jekyll.