Skip to content

Instantly share code, notes, and snippets.

@fanfeilong
Last active April 3, 2022 15:28
Show Gist options
  • Save fanfeilong/10267878 to your computer and use it in GitHub Desktop.
Save fanfeilong/10267878 to your computer and use it in GitHub Desktop.
操作为王,关于操作的最佳实践、模式和案例

VIM 操作最佳实践


  • 字母、数字、控制键

    • hjkl四个方向键:h向左,j向下,k向上,l向右,这四个键让手不离盲打区域。
    • ggGgg是回到文本文件的第一行,G是定位到文本文件的最后一行。
    • gD 跳转到局部变量的定义处
    • % 跳转到配对的括号上
    • [[ 跳转到代码块的开头去
    • '' 跳转到光标上次停靠的地方
    • mx 设置书签
    • `x 跳转到书签处
    • w是跳到下一个单词的开头,W是跳到以空格分隔的下一个单词的开头,w表示word。
    • e 是跳到下一个单词的结尾,E是跳到以空格分隔的下一个单词的结尾,e表示end。
    • b是跳到前一个单词的开头,B是跳到以空格分隔的前一个单词的开头,b表示back。
    • Ctrl+f是向前翻页,Ctrl+b是向后翻页,f表示forward,b表示backward。
    • Ctrl+u是向前翻半页,Ctrl+d是向下翻半页,u表示up,d表示down。
    • f+字母:表示向前定位到第一个找到的字母,比如fa表示向前定位到第一个字母a。
    • F+字母:表示向后定位到第一个找到的字母。
    • n+f+字母:表示向前定位到第n个找到的字母。
    • n+F+字母:表示向后定位到第n个找到的字母。
    • 字符向前和向后定位都可以按分号;定位下一个,按逗号,定位前一个。
    • ^跳到行首,$跳到行末,0跳到行首第一个非空字符。 如果发生折行,上述与行有关的命令可以加上g前缀用于操作屏幕上的行。
    • o,O:向前向后新建编辑行
    • n>; 增加n个tab缩进
    • n<; 减少n个tab缩进
    • :!start{commmand} 异步调用外部命令
  • 单词

    • xp: cut a character and paste after current 交换字符
    • caw: change a word 修改一个单词
    • d3k: delete 3 lines upwards 向上删除3行,同理d3j向下删除3行
    • ddp: delete a line and paste after current line 交换两行
    • zt将当前行置顶,zb将当前行置底,zz将当前行居中,t表示top,b表示bottom,而前缀z表示zoom。 最好用的翻页组合:按zz将当前行居中,然后按ctrl+u或者ctrl+d半屏翻页。
  • 句子

    • V选中当前行,进入v模;按jk多行选择;><整体缩进;
  • 正则表达式

  • 多文件

    • :vimgrep /searchpattern/ [g][j] filepattern
    • :vim多文件替换
      • arg
      • arg *.h
      • arglist
      • argdo
      • argdo %s/pattern/replace/ge | update
  • 参考资料

    1. Vim Regular Expressions 101
    2. VIM IDE STEP BY STEP
    3. coming-home-to-vim
    4. VIM 练级攻略
    5. VimRepress 用VIM写WordPress博客
    6. 豆瓣HJKL小组
    7. 初学者简易.vimrc编写指南
    8. vim color schemes
    9. gvim+ctags in windows
    10. gvim+cscope in windows

Visual Studio


  • 快捷键

    • Ctrl+Enter 在上面打开新一行
    • Ctrl+Shift+Enter 在下面打开新一行
    • Ctrl+-,Ctrl++,切换前后两个编辑位置
    • Ctrl+K, Ctrl+C Ctrl+K, Ctrl+U 切换注释
    • Ctrl+u, Ctrl+U 切换选中文本大小写
    • Ctrl+w 选中单词
    • 当你在光标停留行使用快捷键Ctrl+CCtrl+XCtrl+L时,可以复制,剪切,删除整行内容。
  • 插件

  • Visual Studio 2008 多行批量替换

    1. Alt+F8
    2. Click Samples->Utilities
    3. Right Click FindLine,ClickEdit
    4. Modify the FindLine Macro
     '' Add the following code
     DTE.Find.ReplaceWith = textSelection.Text
    
    
    1. Save and close the macro edit window
    2. Select the multiline Find What code
      • Double Click FindLine Macro
      • Close the Find Dialog
    3. Select the multiline Replace With code
      • Double Click FindLine Macro
      • Click the Quick Replace Tab in the Find Dialog
      • Select Find What code from context menu
      • Select Replace With code from context menu
      • Click FindNext
      • Test click Replace
      • Now you can click Replace All
  • Visual Studio 2008禁用智能提示

    1. 打开目录C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages
    2. 重命名feacp.dll为feacp_disable.dll,或者删除之
    3. Visual Studio自带的智能提示总是会卡,而且会导致IDE经常死掉,还是禁用掉,用VA的
  • Visual Studio 2008设置代码导航线

    1. 打开注册表,找到HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Text Editor
    2. 新建项Guides
    3. 写入值RGB(128,128,128) 4,75,80
    4. 其中,RGB表示颜色,4,75,80表示导航线的列位置,用逗号隔开,可以加入任意多条线
  • Visual Studio 2008美观设置

    1. 字体Lucida Console或者Source Code Pro
    2. LineNumber,背景色淡绿色,字体深灰色
    3. VA,当前行高亮采用DottedBox
    4. 在Addin目录下安装插件WordLight,高亮文件内选中文本的匹配项
    5. VA或者其他插件设置右侧地图式滚动面板
  • Visusl Studio Debug变慢的原因
    You may need to delete all your breakpoints---note that you need to click the "delete all breakpoints" button (or use Ctrl-Shft-F9), NOT just delete them one by one. If Visual Studio has mangled your solution settings the latter will not work. You may need to add a breakpoint first, in order for this to work (clever, eh?).If worst comes to worst, you may need to delete your .suo file and let Visual Studio start a new one from scratch. Note that you will lose your personal solution configuration settings, however (only for this solution, not any others). However, you may want to move/rename the file temporarily until you determine whether or not this is the problem; that way, you can always move it back. I have seen some online resources recommend deleting (moving/renaming) the .ncb file as well.

Chrome


  • 快捷键
    • Ctrl+Shift+n:新建隐身窗口

Windows文件管理器


  • Win+e:打开新文件夹
  • Win+r:运行
  • Win+l:锁定屏幕
  • Win+i:Windows8右侧栏
  • 安装基于Chromium开发的Tab式文件管理器Clover

SVN


  • 如果本地进行了一堆复杂操作后,发现提交的时候很多missing之类的冲突,最简单的办法是:
    1. 将当前文件夹的文件和子文件夹都cut到某个空目录x
    2. 对当前文件夹做svn revert
    3. 将x文件夹下的备份内容copy回当前文件夹
    4. 重新执行svn commit

IM


  • 对于QQ群,如果不想浪费时间的话,一定要把人多水多的群设置为「只显示消息数目,不弹出消息」,切记切记

DOT & Graphviz


LaTeX


@fanfeilong
Copy link
Author

图片嵌入压缩包

环境:window+7zip
准备:a.jpg b.7z
制图命令:copy /b a.jpg+b.7z c.jpg
解压:重命名c.jpg 为c.7z,右键用7z解压。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment