首页 > 代码库 > vim

vim

" =============================================================================
let Tlist_Exit_OnlyWindow=1                 "如果Taglist窗口是最后一个窗口则退出Vim
"        << 判断操作系统是 Windows 还是 Linux 和判断是终端还是 Gvim >>
" =============================================================================

" -----------------------------------------------------------------------------
"  < 判断操作系统是否是 Windows 还是 Linux >
" -----------------------------------------------------------------------------
let g:iswindows = 0
let g:islinux = 0
if(has("win32") || has("win64") || has("win95") || has("win16"))
    let g:iswindows = 1
else
    let g:islinux = 1
endif

" -----------------------------------------------------------------------------
"  < 判断是终端还是 Gvim >
" -----------------------------------------------------------------------------
if has("gui_running")
    let g:isGUI = 1
else
    let g:isGUI = 0
endif

 

 

" -----------------------------------------------------------------------------
"  < 个人偏好快捷键设置 >
" -----------------------------------------------------------------------------

"修改映射<ESC>键为jk退出INSERT模式
inoremap jk <ESC>

"以新的页签打开当前光标处的文件,而非原本的覆盖打开
nmap gf :tab vsp <cfile><CR>

"将一行文本从光标处进行换行
"nmap K a<CR><ESC>

"快捷新建shell解释器头
nmap bi ggdG<ESC>0i#!/bin/bash<ESC>

"全局代码对齐,四个空格为缩进单位
nmap fm <ESC>mzgg<S-v><S-g>=<ESC>‘z

"快捷新建c语言常用头文件
nmap ci ggdG<ESC>0i#include <stdio.h><CR>#include <string.h><CR>#include <stdlib.h><CR>#include <unistd.h> <CR>#include <signal.h><CR>#include <time.h><CR>#include <sys/types.h><CR>#include <sys/stat.h><CR>#include <fcntl.h><CR>#include <signal.h><CR>#include <sys/wait.h><CR>#include <sys/ipc.h><CR>#include <sys/socket.h><CR>#include <netinet/in.h><CR>#include <arpa/inet.h><CR><CR><CR><CR><CR>int main(void)<CR>{<CR><CR><CR><CR><CR><Space>return 0;}<CR><ESC>22gg
" -----------------------------------------------------------------------------

 

本文出自 “习惯记忆” 博客,转载请与作者联系!

vim