sublime使用总结

上周忙呀忙~    周一到五在忙项目,周六日搬家    在帝都平均一年就要换一次房子,从开始找房子到成功住进去前前后后大约花了半个多月的时间    什么时候就有自己的小窝了……

之前开发一直用的都是WebStorm,用了一段时间后发现很卡顿,内存占用很大,故而准备选择轻量级的Sublime。

以下是使用过程中的一些总结,持续更新~

1、安装Sublime Text3,傻瓜式安装,这里就不多说了~

2、安装Package Control(一个用来管理插件的插件)

  ctrl + `打开控制台;将以下代码粘贴到控制台

import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

  等待安装完成,ctrl + shift + p 打开命令板,输入PC出现  选择即可安装sublime text 的各种插件

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

  出现问题:Package Control:There are no packages available for installation

  解决方法:① 网上查资料说是IPV6的问题, 打开win+R  cmd命令提示符中输入ping sublime.wbond.net  得到IP,在C:\Windows\system32\drivers\etc\hosts文件,增加如下对应关系:{IPv4 address}sublime.wbond.Net

         ② 另一种说法是install package那个安装代码太旧,在官网上找到新的重新安装

         ③上述两种方法都没能解决我的问题,故在官网重新下载了安装文件(之前的是在网页上搜出的百度软件中心下载的汉化版),重新安装,成功!

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

3、js校验插件

  ① 确保安装了nodeJs ;命令行进入npm目录,输入’npm install -g jshint’ 

  ② 插件安装输入JSHint Gutter

  ③ package settings > JSHint Gutter > Set Plugin Options > 设置NodeJS执行文件所在的路径(node_path),并将lint_on_save(文件保存时检查)选项打开

  ④ package settings > JSHint Gutter > set Linting Preferences  打开.jshintrc文件

  定制自己的校验规则:

  參考:’http://jshint.com/docs/options/’ 

//
// 强制选项
//
    // When set to true, these options will make JSHint produce more warnings about your code.

    /**
     * 是否阻止位运算符的使用
     *
     * 有时候为了快速取整或判断,会使用一些位运算符,所以此项设置为 false
     */
    "bitwise": false,
    /**
     * 是否要求变量都使用驼峰命名
     *
     * 默认开启
     * 弃用,见jscs项目
     */
    "camelcase": false,
    /**
     * 是否要求 for/while/if 等循环和条件语句中总是使用花括号
     *
     *
     */
    "curly": false,
    /**
     * 是否强制使用严格等号
     *
     * 有时候需要判断 null,所以默认不严格要求
     */
    "eqeqeq": false,
    /**
     * true: 默认要求所有函数运行在ES5
     * 弃用
     */
    "es3": true,
    "es5": true,
    "esnext": true,
    /**
     * 选择ES版本,3,5,6
     */
    "esversion": 5,
    /**
     * for-in 语句是否要求过滤原型链上的对象
     *
     * 默认打开
     */
    "forin": true, /**
     * 是否阻止修改或拓展基本对象(Array、Date 等)的原型链
     *
     * 原型链污染比较危险,默认打开
     */
    "freeze": true,
    /**
     * 变量只能在函数域上定义,在代码块上定义的变量给出警告
     */
    "funcscope": true,
    /**
     * 当使用JS保留字时,显示警告
     */
    "futurehostile": true,
    /**
    *这个选项可以用来指定一个没有正式定义的全局变量的白名单。配置 globals在单个文件,看看内联配置.
    */
    "globals": {
        "define": false,
        "module": true,
        "export": true,
        "console": false
    },
    /**
     * 是否要求自执行的方法使用括号括起  (function () { } ());
     * 默认打开
     * 弃用,见jscs项目
     */
    "immed": true,
    /**
     * 指定tab缩进宽度为 2 个空格
     *
     * 弃用,见jscs项目
     */
    "indent": 2,
    /**
     * 要求变量在使用前声明,
     */
    "latedef": true,
    /**
     * 代码块嵌套深度
     */
    "maxdepth": 2,
    /**
     * 最大错误提示数量,默认50
     */
    "maxerr": 50,
/**
     * 单行最大长度
     *
     * 弃用,见jscs项目
     */
    "maxlen": 50,
    /**
     * 设置函数正式参数的最大数量
     *
     */
    "maxparams": 4,
    /**
     * 一个函数内声明语句的最大数量
     *
     */
    "maxstatements": 4,
    /**
     * 要求构造函数大写
     *
     * 弃用,见jscs项目
     */
    "newcap": true,
    /**
     * 不允许使用 arguments.callee 和 arguments.caller
     */
    "noarg": true,
    /**
     * 不允许使用逗号
     */
    "nocomma": true,
    /**
     * 不允许空的代码快,默认关闭
     *
     * 弃用,见jscs项目
     */
    "noempty": false,
    /**
     * 不允许使用 "non-breaking whitespace"。
     *
     * 这些字符在非 UTF8 页面会导致代码失效
     */
    "nonbsp": true,
    /**
     * 阻止直接使用 new 调用构造函数的语句(不赋值对象)
     *
     * // OK
     * var a = new Animal();
     *
     * // Warn
     * new Animal();
     */
    "nonew": true,
/**
     * 阻止直接使用 typeof 操作符
     *
     * 慎用
     */
    "notypeof": true,
    /**
    * 字符串引号
    *
    * 默认要求使用单引号
    true-- 代码字符串禁止单引号双引号混用,
    "single"--只允许单引号
    "double"--只允许双引号。
    * 弃用,见jscs项目
    */
    "quotmark": "single",
    /**
    * 隐藏式声明
    *
    "inner" - check for variables defined in the same scope only
    "outer" - check for variables defined in outer scopes as well
    false - same as inner
    true - allow variable shadowing
    */
    "shadow": "inner",
    /**
     *  禁止在不必要的时候使用分组运算符
     */
    "singleGroups": true,
    /**
     * 是要求否以 strict 模式检查
     *
     * 该选项要求文件有 "use strict;"不全局要求,需要的模块自行开启
     */
    "strict": false,
    /**
     * 提示未定义的变量
     *
     * 未定义的变量会容易造成全局变量,该项开启
     */
    "undef": true,
    /**
     * 提示未使用的变量
     * vars - to only check for variables, not function parameters
     * strict - to check all variables and parameters.
     * 默认开启
     */
    "unused": true,
    /**
     * 是否禁止使用var
     * Use `let` or `const` instead.
     */
    "varstmt": true,
//
//Relaxing options
//
    //When set to true, these options will make JSHint produce fewer warnings about your code.

    /**
     * 不显示缺少分号警告
     */
    "asi": true,
    /**
     *  不显示在 比较处使用了赋值 的警告信息。
     */
    "boss": true,
    /**
     * 不显示代码中使用的 debugger 语句默认给出的警告
     */
    "debug": true,
    /**
     * This option tells JSHint that your code uses ES3 array elision elements, or empty elements (for example, [1, , , 4, , , 7]).
     */
    "elision": true,
    /**
     * 不显示关于 == null的警告
     * 当您想要检查变量是否为空或未定义时,这种比较往往很有用。
     */
    "eqnull": true,
    /**
     * 不显示关于 eval 的警告
     *
     */
    "evil": true,
    /**
     * 不显示 在应该使用复制或函数调用的地方使用了表达式 的警告。
     */
    "expr": true,
    /**
     * 不显示缺少分号的警告
     */
    "lastsemic": true,
 /**
     * 不显示不安全的折行的警告
     *
     * 弃用,见jscs项目
     */
    "laxbreak": true,
    /**
     * 不显示逗号放前面的警告,例如:
     *
     * 弃用,见jscs项目
     */
    "laxcomma": true,
    /**
     * 不显示 在循环语句中定义函数 的警告
     */
    "loopfunc": true,
    /**
     * 不显示 多行字符串 的警告
     */
    "multistr": true,
    /**
     * 不允许使用 ++ 和 -- 运算符
     *
     * 默认关闭
     */
    "plusplus": false,
    /**
     * 禁止关于__proto__属性的警告
     */
    "proto": true,
    /**
     *  true: Prohibit use of empty blocks
     *  该选项控制形如 person['name'] vs. person.name的警告信息的显示
     *  弃用,见jscs项目
     */
    "sub": true,
//
// Environments
//
    // These options let JSHint know about some pre-defined global variables.
    /**
     * 暴露浏览器属性的全局变量,列如 window,document;
    注意:这个选项不暴露变量 alert或 console。
     */
    "browser": true,
    /**
     * 这个选项定义全局暴露的jQuery库。
     */
    "jquery": true

  常见的提示错误:

“Missing semicolon.” : “缺少分号.”,  
“Use the function form of \”use strict\”.” : “使用标准化定义function.”,  
“Unexpected space after ‘-’.” : “在’-'后面不应出现空格.”,  
“Expected a JSON value.” : “请传入一个json的值.”,  
“Mixed spaces and tabs.”: “空格和TAB重复.”,  
“Unsafe character.” : “不安全的字符.”,  
“Line too long.”: “本行中的字符超过设定的最大长度.”,  
“Trailing whitespace.”: “本行末尾有过多无用空格.”,  
“Script URL.” : “脚本URL.”,  
“Unexpected {a} in ‘{b}’.” : “在 ‘{b}’ 中不该出现 {a}.”,  
“Unexpected ‘{a}’.” : “不该在此出现’{a}’.”,  
“Strings must use doublequote.” : “字符串需要用双引号”,  
“Unnecessary escapement.” : “不需要转义”,  
“Control character in string: {a}.” : “在字符串中出现了Control的字符”,  
“Avoid \\’.” : “避免 \\”,  
“Avoid \\v.” : “避免 \\v”,  
“Avoid \\x-.” : “避免 \\x-”,  
“Bad escapement.” : “错误的转义字符”,  
“Bad number ‘{a}’.” : “错误的数字 ‘{a}’”,  
“Missing space after ‘{a}’.” : “在’{a}’之后缺少空格”,  
“Don’t use extra leading zeros ‘{a}’.” : “不要再’{a}’的前面用多余的0″,  
“Avoid 0x-. ‘{a}’.” : “避免使用 0x-. ‘{a}’.”,  
“A trailing decimal point can be confused with a dot ‘{a}’.” : “在’{a}’中使用点尾随小数点”,  
“Unexpected comment.” : “不该在此处出现注释”,  
“Unescaped ‘{a}’.” : “没有转义 ‘{a}’”,  
“Unexpected control character in regular expression.” : “在正则表达式中出现了control字符”,  
“Unexpected escaped character ‘{a}’ in regular expression.” : “在正则表达式中出现了没有转义的字符 ‘{a}’”,  
“Expected ‘{a}’ and instead saw ‘{b}’.” : “应该用 ‘{a}’代替’{b}’”,  
“Spaces are hard to count. Use {{a}}.” : “空格难以统计,请使用 {{a}}”,  
“Insecure ‘{a}’.” : “不安全的 ‘{a}’”,  
“Empty class.” : “空的class”,  
“Expected a number and instead saw ‘{a}’.”:“应该用数字代替’{a}’”,  
“‘{a}’ should not be greater than ‘{b}’.”:“‘{a}’不应该比’{b}’大”,  
“‘hasOwnProperty’ is a really bad name.”: “‘hasOwnProperty’是关键字”,  
“‘{a}’ was used before it was defined.”:“‘{a}’未定义就已经使用了.”,  
“‘{a}’ is already defined.”:“‘{a}’被重复定义”,  
“A dot following a number can be confused with a decimal point.”:“数字后面的一个点会被误认为是十进制的小数点”,  
“Confusing minusses” : “容易混淆的负数表达-”,  
“Confusing plusses.” : “容易混淆的正数表达+”,  
“Unmatched ‘{a}’.” : “无法匹配的’{a}’”,  
“Expected ‘{a}’ to match ‘{b}’ from line {c} and instead saw ‘{d}’.”:“在行{c}中需要用’{a}’和’{b}’匹配,用来代替’{d}’”,  
“Unexpected early end of program.”:“程序不可预期的提前终止”,  
“A leading decimal point can be confused with a dot: ‘.{a}’.”:“‘{a}’前的点容易混淆成小数点”,  
“Use the array literal notation [].”:“使用数组的符号 []“,  
“Expected an operator and instead saw ‘{a}’.”:“需要用一个符号来代替’{a}’”,  
“Unexpected space after ‘{a}’.”:“在’{a}’之后不能出现空格”,  
“Unexpected space before ‘{a}’.”:“在’{a}’之前不能出现空格”,  
“Bad line breaking before ‘{a}’.”:“在’{a}’之前错误的换行”,  
“Expected ‘{a}’ to have an indentation at {b} instead at {c}.”:“‘{a}’需要在{c}而不是{b}处缩进”,  
“Line breaking error ‘{a}’.”:“换行错误 ‘{a}’”,  
“Unexpected use of ‘{a}’.”:“此处不能用’{a}’”,  
“Bad operand.”:“错误的操作数”,  
“Use the isNaN function to compare with NaN.”:“使用isNaN来与NaN比较”,  
“Confusing use of ‘{a}’.”:“容易混淆的’{a}’的使用”,  
“Read only.”:“只读的属性”,  
“‘{a}’ is a function.”:“‘{a}’是一个函数”,  
‘Bad assignment.’:“错误的赋值”,  
“Do not assign to the exception parameter.”:“不要给额外的参数赋值”,  
“Expected an identifier in an assignment and instead saw a function invocation.”:“在赋值的语句中需要有一个标识符,而不是一个方法的调用”,  
“Expected an identifier and instead saw ‘{a}’ (a reserved word).”:“需要有一个标识符,而不是’{a}’(保留字符)”,  
“Missing name in function declaration.”:“在方法声明中缺少名称”,  
“Expected an identifier and instead saw ‘{a}’.”:“需要有一个标识符,而不是’{a}’”,  
“Inner functions should be listed at the top of the outer function.”:“内部函数的声明应该放在此函数的顶部。”,  
“Unreachable ‘{a}’ after ‘{b}’.”:“在’{b}’之后无法获取’{a}’”,  
“Unnecessary semicolon.”:“不必要的分号”,  
“Label ‘{a}’ on {b} statement.”:“将’{a}’放在{b}的声明中”,  
“Label ‘{a}’ looks like a javascript url.”:“‘{a}’看上去像一个js的链接”,  
“Expected an assignment or function call and instead saw an expression”:“需要一个赋值或者一个函数调用,而不是一个表达式.”,  
“Do not use ‘new’ for side effects.”:“不要用’new’语句.”,  
“Unnecessary \”use strict\”.”:“不必要的\”use strict\”.”,  
“Missing \”use strict\” statement.”:“缺少\”use strict\”的声明”,  
“Empty block.”:“空的模块”,  
“Unexpected /*member ‘{a}’.”:“不应出现 /*元素 ‘{a}’.”,  
“‘{a}’ is a statement label.”:“‘{a}’是一个声明”,  
“‘{a}’ used out of scope.”:“‘{a}’使用超出范围”,  
“‘{a}’ is not allowed.”:“不允许使用’{a}’”,  
“‘{a}’ is not defined.”:“‘{a}’没有被定义”,  
“Use ‘{a}’ to compare with ‘{b}’.”:“使用’{a}’与’{b}’相比”,  
“Variables should not be deleted.”:“变量需要被删除”,  
“Use the object literal notation {}.”:“使用对象的文字符号 {}”,  
“Do not use {a} as a constructor.”:“不要使用{a}作为一个构造对象”,  
“The Function constructor is eval.”:“The Function constructor is eval.”,  
“A constructor name should start with an uppercase letter.”:“一个构造对象的名称必须用大写字母开头.”,  
“Bad constructor.”:“错误的构造对象”,  
“Weird construction. Delete ‘new’.”:“构造对象有误,请删除’new’”,  
“Missing ‘()’ invoking a constructor.”:“缺少括号()”,  
“Avoid arguments.{a}.”:“避免参数.{a}.”,  
“document.write can be a form of eval.”:“document.write是eval的一种形式”,  
‘eval is evil.’:“尽量不要使用eval”,  
“Math is not a function.”:“Math不是一个函数”,  
“Missing ‘new’ prefix when invoking a constructor.”:“此处缺少了’new’”,  
“Missing radix parameter.”:“缺少参数”,  
“Implied eval is evil. Pass a function instead of a string.”:“传递一个函数,而不是一个字符串”,  
“Bad invocation.”:“错误的调用”,  
“['{a}'] is better written in dot notation.”:“['{a}']最好用点.的方式”,  
“Extra comma.”:“多余的逗号”,  
“Don’t make functions within a loop.”:“不要用循环的方式创建函数”,  
“Unexpected parameter ‘{a}’ in get {b} function.”:“在{b}方法中不该用到参数’{a}’”,  
“Duplicate member ‘{a}’.”:“重复的’{a}’”,  
“Expected to see a statement and instead saw a block.”:“此处应该是语句声明.”,  
“Too many var statements.”:“过多var的声明”,  
“Redefinition of ‘{a}’.”:“‘{a}’被重复定义”,  
“It is not necessary to initialize ‘{a}’ to ‘undefined’.”:“无需将’{a}’初始化为’undefined’”,  
“Expected a conditional expression and instead saw an assignment.”:“此处需要一个表达式,而不是赋值语句”,  
“Expected a ‘break’ statement before ‘case’.”:“在’case’之前需要有’break’.”,  
“Expected a ‘break’ statement before ‘default’.”:“在’default’之前需要有’break’.”,  
“This ‘switch’ should be an ‘if’.”:“此处’switch’应该是’if’.”,  
“All ‘debugger’ statements should be removed.”:“请删除’debugger’的语句”,  
“‘{a}’ is not a statement label.”:“‘{a}’不是一个声明标签.”,  
“Expected an assignment or function call and instead saw an expression.”:“需要一个语句或者一个函数调用,而不是一个表达式”,  
“Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.”:
“函数的声明不能放在类似if的块中,需要放在外部函数的顶部.” “Use '===' to compare with ...”:“这个错误是说,我们要是用全等来代替等于,如果表达式两边的数据类型是一致的话,建议使用全等来判断”

 

4、快捷键

 
  
------------  基本编辑  -------------

  ctrl + `    //打开控制台

  ctrl + p   //通过文件名搜索

  ctrl + shift + p //调出命令板(Command Palette)
  ctrl +  ←/→  //进行逐词移动         ctrl + shift + ←/→  //进行逐词选择  

  ctrl + ↑/↓  //移动当前显示区域   Ctrl + Shift + ↑/↓  //移动当前行

  ctrl + [ //向左缩进 ctrl + ] //向右缩进

  ctrl + shift + V //可以以当前缩进粘贴代码
   ------------  选择 -------------

  ctrl + D   //选择当前光标所在的词并高亮该词所有出现的位置,再次Ctrl + D选择该词出现的下一个位置,在多重选词的过程中,使用Ctrl + K进行跳过,使用Ctrl + U进行回退,使用Esc退出多重编辑。

  ctrl + shift + L     //将当前选中区域打散,然后进行同时编辑      

  ctrl + J     //把当前选中区域合并为一行
  ctrl + M     //在起始括号和结尾括号之间切换

  ctrl + shift + M //快速选择括号间的内容

  ctrl + shift + J //快速选择同缩进的内容
  ctrl + shift + J   //快速选择当前作用域(Scope)的内容
  ------------ 查找&替换 -------------

  F3 //跳至当前关键字下一个位置

  shift + F3 //跳到当前关键字上一个位置

  Alt + F3 //选中当前关键字出现的所有位置

  ctrl + F/H //进行标准查找/替换

  ctrl + shift + F //进行标准查找/替换
  ------------ 跳转 -------------

  ctrl + P //跳转到指定文件,输入文件名后可以:

    @ 符号跳转:输入@symbol跳转到symbol符号所在的位置

    # 关键字跳转:输入#keyword跳转到keyword所在的位置

    :
 行号跳转:输入:12跳转到文件的第12行

  ctrl + R  //跳转到指定符号
  ctrl + G  //跳转到指定行号
  ------------ 窗口 -------------

  ctrl + shift + N //创建一个新窗口
  ctrl  + N   //在当前窗口创建一个新标签
  ctrl + W   //关闭当前标签,当窗口内没有标签时会关闭该窗口
  ctrl + shift + T   //恢复刚刚关闭的标签
  ------------ 屏幕 -------------
  
  F11 //切换普通全屏

  shift + F11 //切换无干扰全屏

  Alt + shift + 2 //进行左右分屏
  Alt + shift + 8   //进行上下分屏
  Alt + shift + 5   //进行上下左右分屏
  Alt + shift + 1   //取消分屏

   分屏之后,使用Ctrl + 数字键跳转到指定屏,使用Ctrl + Shift + 数字键将当前屏移动到指定屏

 

 
 

5、定制个性化主题

  // 使光标闪动更加柔和 "caret_style": "phase",

  // 高亮当前行 "highlight_line": true,

  // 高亮有修改的标签 "highlight_modified_tabs": true,

  // 设置tab的大小为2 "tab_size": 2,

  // 使用空格代替tab "translate_tabs_to_spaces": true,

  // 添加行宽标尺 "rulers": [80, 100],

  // 显示空白字符 "draw_white_space": "all",

  // 保存时自动去除行末空白 "trim_trailing_white_space_on_save": true,

  // 保存时自动增加文件末尾换行 "ensure_newline_at_eof_on_save": true,

 6、常用功能

  定位该文件在文件夹中的位置:  在代码区域右击 > Reveal in Side Bar

  按Tab自动补全

7、后续补充

  全局搜索:ctrl + shift + F

 

 

转载于:https://www.cnblogs.com/merryZhang/p/7091201.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值