Vim 使用笔记

1.查看帮助

1
:help

2.查看quickref

1
:help quickref

3.语法高亮

1
2
:syn-on      :syntax on              start using syntax highlighting
:syn-off      :syntax off             stop using syntax highlighting

4.Move cursor to its last position

The quickest way is to hit either:

1
2
3
4
5
''
(two apostrophes) or:

``
(two backticks).

5.Show line number

1
:set number

6.Auto indent

1
:set autoindent

7.Set background

1
2
:set background=dark
:set background=light

8.Common move command

1
2
3
4
0, ^ line head
$, g_ line foot
ctl + f forword page
ctl + b back page

9.用vim编辑一个文件,改动了很多内容;最终要保存时却发现没有权限

1
:w !sudo tee % > /dev/null

Reference:http://www.caiyiting.com/blog/2014/vim-sudo.html

10.替换文字时有特殊字符怎么办?

A:用 \ 转义。

1
%s/\/Users\/dongmeiliang\/Sites/\/home\/meiliang\/public_html/g

11.How to reload current file when it has been changed outside of Vim?

A::e , more info at :help :e

12.How to delete all lines of file in Vim?

A:

  1. Type gg to move the cursor to the first line of the file, if it is not already there.
  2. Type dG to delete all the lines.

Reference:How to delete all lines of file in Vim

13.How to select all lines of file in Vim?

A: ggVG

Reference:How do i select all text in Vi/Vim?

扩展阅读

MySQL 使用笔记

1.查看所有的用户

1
2
3
4
5
6
7
$ mysql -u user -p

As of MySQL 5.7.6, use this statement:
mysql> SELECT User, Host, HEX(authentication_string) FROM mysql.user;

Before MySQL 5.7.6, use this statement:
mysql> SELECT User, Host, Password FROM mysql.user;

2.查看用户的权限

1
mysql > SHOW GRANTS FOR 'username'@'localhost';

3.为用户添加操作某个数据库的权限

1
2
mysql > GRANT select, insert, update, delete, index, alter, create ON db2.* TO 'jeffrey'@'localhost';
mysql > GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER ON `xiao_chun`.* TO `xiaochun`@`localhost`;

4.Default options are read from the following files in the given order:

  1. /etc/my.cnf
  2. /etc/mysql/my.cnf
  3. /usr/local/mysql/etc/my.cnf
  4. ~/.my.cnf

5.

1
2
3
4
5
6
mysql > CREATE TABLE IF NOT EXISTS categories (
  id SMALLINT NOT NULL AUTO_INCREMENT,
  category VARCHAR(30) NOT NULL,
  PRIMARY KEY (id),
  UNIQUE KEY category (category)
)ENGINE = MyISAM DEFAULT CHARSET = utf8;
  • VARCHAR(30):can hold up to 30 characters.
  • A UNIQUE index creates a constraint such that all values in the index must be distinct. An error occurs if you try to add a new row with a key value that matches an existing row. For all engines, a UNIQUE index permits multiple NULL values for columns that can contain NULL.
  • DEFAULT CHARSET
继续阅读

iOS App 开发问题汇总(三)

1.Checking the Entitlements for an iOS app Submission to the App Store

Making an Inspectable .ipa file
In the Xcode Organizer, instead of Submit to the iOS App Store, do Save for Enterprise or Ad-Hoc Deployment. This will create a local copy of the .ipa file that would be submitted to the App Store.
When asked to choose the provisioning profile to sign with, select the same distribution profile you use when submitting to the App Store. Take a screenshot of your choice (command-shift-3) so you can verify this step later. During submission, this screenshot will be the only record you have identifying which profile was used to sign the app.
When asked to save the package, uncheck Save for Enterprise Distribution, then save the .ipa file.
Checking the Entitlements of an .ipa file
Find the .ipa file and change its the extension to .zip.
Expand the .zip file. This will produce a Payload folder containing your .app bundle.
Use the codesign tool to check the entitlements on the .app bundle like this: $ codesign -d –entitlements :- “Payload/YourApp.app” where YourApp.app is the actual name of your .app bundle.
Use the security tool to check the entitlements of the app’s embedded provisioning profile: // should add cms, Apple may be a typo $ security cms -D -i “Payload/YourApp.app/embedded.mobileprovision”

where YourApp.app is the actual name of your .app bundle.

继续阅读