Skip to content

Instantly share code, notes, and snippets.

@JeOam
Last active March 15, 2016 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeOam/914cf400bd96c8d28455 to your computer and use it in GitHub Desktop.
Save JeOam/914cf400bd96c8d28455 to your computer and use it in GitHub Desktop.
Vim 写 C、Lua 配置
" place at: ~/.vimrc
" Enable syntax highlighting
syntax on
" show line number
set nu
" Set to auto read when a file is changed from the outside
set autoread
" 1 tab == 4 spaces
set tabstop=4
" Use spaces instead of tabs
set expandtab
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" Use spaces instead of tabs
set expandtab
" Put this in your .vimrc to use Vundle.
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/.vim/bundle/plugins')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" Install YouCompleteMe
Bundle 'Valloric/YouCompleteMe'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
let g:ycm_global_ycm_extra_conf = "~/.vim/.ycm_extra_conf.py"
@JeOam
Copy link
Author

JeOam commented Dec 19, 2015

Vundle (缩写自 Vim bundle) 是一个很方便的 Vim 插件管理器。

Set up Vundle:

$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

编译 YouCompleteMe 需要 CMake

brew install CMake
cd ~/.vim/bundle/
git clone https://github.com/Valloric/YouCompleteMe
git submodule update --init --recursive
./install.py --clang-completer

然后把文件 下载至 ~/.vim/ 目录下,命名为:.ycm_extra_conf.py

然后 vim 中:let g:ycm_global_ycm_extra_conf = "~/.vim/.ycm_extra_conf.py"

@JeOam
Copy link
Author

JeOam commented Dec 19, 2015

Delete all lines of file in Vim:

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

@JeOam
Copy link
Author

JeOam commented Dec 19, 2015

Insert mode at beginning of line: I (the capital of i)
Insert mode at the end of the line: A

@JeOam
Copy link
Author

JeOam commented Mar 9, 2016

Mac OS/Vim 7.4 下,遇到错误:

Fatal Python error: PyThreadState_Get: no current thread.

可通过:

brew unlink python

解决。

@JeOam
Copy link
Author

JeOam commented Mar 10, 2016

复制粘贴:

# .vimrc 
# use  system clipboard
set clipboard=unnamed

Vim command:

# copy 1 to 2 line to clipboard
:1,2y<Enter>   

Copy all lines:

  • ggyG
  • :%y+
  • gg"*yG

@JeOam
Copy link
Author

JeOam commented Mar 10, 2016

@JeOam
Copy link
Author

JeOam commented Mar 15, 2016

  • Shift + o: 在上一行插入一个新行
  • o: 在下一行插入一个新行
  • I: 行首输入
  • A: 行尾插入

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