Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (3)
master
mac
linux
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
The license selected for the repository is subject to the license used by the main branch of the repository.
master
Branches (3)
master
mac
linux
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (3)
master
mac
linux
myvim
/
function.vimrc
myvim
/
function.vimrc
function.vimrc 12.39 KB
Copy Edit Raw Blame History
bgm authored 2021年11月23日 16:33 +08:00 . delete c.vim and add c/c++ support in function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
" Base Settings 基本设置
" all function by myself
"==========================================
function! RunShell(Msg, Shell)
echo a:Msg . '...'
call system(a:Shell)
echon 'done'
endfunction
function! ReName()
let old_name = expand("<cword>")
let old_name = input("old name:",old_name)
let new_name = input("new name:",old_name)
let exec = input("are sure to refactor(y/n|Y/N):")
if 'y' == exec || 'Y' == exec
let cmd = printf("/opt/sys/settings/bin/vim/shell/ref.sh %s %s",old_name,new_name)
echo cmd
:call RunShell("refactoring",cmd)
endif
endfunction
let g:spx_begin = 0
function! GetCurrentCursor()
let g:spx_begin = line('.')
let g:spx_begin = g:spx_begin + 0
echo "get current line idx:".g:spx_begin
endfunction
function! ClearCurrentCursor()
let g:spx_begin = 0
echo "clear current cursor is success"
endfunction
function! CopyLinesToSystem()
let begin_idx = 0
if 0 != g:spx_begin
let begin_idx = g:spx_begin
let g:spx_cpy_begin = 0
else
let begin_idx = line(".")
let begin_idx = input("begin line idx:",begin_idx)
endif
let end_idx = line(".")
let end_idx = input("end line idx:",end_idx)
let begin_idx = begin_idx + 0
let end_idx = end_idx + 0
if begin_idx > end_idx
let tmp = begin_idx
let begin_idx = end_idx
let end_idx = tmp
endif
let list = getline(begin_idx,end_idx)
let lines = join(list,"\n")
if "xterm" == &term
call setreg("",lines)
else
call setreg("+",lines)
endif
echo "copy lines to system begin:" . begin_idx . " end:" . end_idx
endfunction
function! DeleteLines()
let begin_idx = 0
if 0 != g:spx_begin
let begin_idx = g:spx_begin
let g:spx_cpy_begin = 0
else
let begin_idx = line('.')
let begin_idx = input("begin line idx:",begin_idx)
endif
let end_idx = line('.')
let end_idx = input("end line idx:",end_idx)
let begin_idx = begin_idx + 0
let end_idx = end_idx + 0
if begin_idx > end_idx
let tmp = begin_idx
let begin_idx = end_idx
let end_idx = tmp
endif
let cur = getpos('.')
let cur[1] = begin_idx + 0
let result = setpos('.',cur)
if(0 != result)
echo "delete lines begin:" . begin_idx . " end:" . end_idx ." is fail"
return
endif
let lines = abs(begin_idx - end_idx) + 1 "add the line self
"for fold
execute ":". begin_idx . "," . end_idx . "de"
echo "delete lines begin:" . begin_idx . " end:" . end_idx
endfunction
noremap <leader>fg :call GetCurrentCursor()<cr>
noremap <leader>fc :cal ClearCurrentCursor()<cr>
noremap <leader>fy :call CopyLinesToSystem()<cr>
noremap <leader>fd :call DeleteLines()<cr>
noremap <leader>fr :call ReName()<cr>
nmap <M-g> :call GetCurrentCursor()<cr>
nmap <M-c> :call ClearCurrentCursor()<cr>
nmap <M-y> :call CopyLinesToSystem()<cr>
nmap <M-d> :call DeleteLines()<cr>
nmap <M-r> :call ReName()<cr>
function! DeleteShiftLines()
let lines = input("input above lines count:")
if 0 == lines
return
endif
exec "normal ".lines."k"
exec "normal ".lines."dd"
endfunction
noremap <leader>sd :call DeleteShiftLines()<cr>
"设定当前列高亮
function! SetColorColumn(cnum)
let col_num = 0
if 0 < a:cnum
let col_num = a:cnum
echo col_num
else
let col_num = virtcol(".")
endif
let cc_list = split(&cc, ',')
if count(cc_list, string(col_num)) <= 0
execute "set cc+=".col_num
else
execute "set cc-=".col_num
endif
endfunction
map <leader>ch :call SetColorColumn(0)<CR>
autocmd BufNewFile *.c,*.py,*.md exec ":call SetColorColumn(80)"
" 定义函数AutoSetFileHead,自动插入文件头
autocmd BufNewFile *.sh,*.py,*.md exec ":call AutoSetFileHead()"
function! AutoSetFileHead()
"如果文件类型为.sh文件
if &filetype == 'sh'
call setline(1, "\#!/bin/bash")
endif
"如果文件类型为python
if &filetype == 'python'
call setline(1, "\#!/usr/bin/env python")
call append(1, "\# -*- encoding: utf-8 -*-")
endif
if &filetype == 'mkd' || &filetype == 'md'
call setline('.',"---")
normal ==o
call setline('.',"layout: post")
normal ==o
call setline('.',"categories: []")
normal ==o
call setline('.',"title: \" \"")
normal ==o
call setline('.',"tags: []")
normal ==o
call setline('.',"---")
normal ==o
endif
normal G
normal o
normal o
endfunc
" 保存文件时删除多余空格
" Delete trailing white space on save, useful for Python and CoffeeScript ;)
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()
autocmd BufWrite *.c :call DeleteTrailingWS()
autocmd BufWrite *.h :call DeleteTrailingWS()
autocmd BufWrite *.vimrc :call DeleteTrailingWS()
" 相对行号 行号变成相对,可以用 nj nk 进行跳转 5j 5k 上下跳5行
set relativenumber number
au FocusLost * :set norelativenumber number
au FocusGained * :set relativenumber
" 插入模式下用绝对行号, 普通模式下用相对
autocmd InsertEnter * :set norelativenumber number
autocmd InsertLeave * :set relativenumber
function! NumberToggle()
if(&relativenumber == 1)
set norelativenumber number
else
set relativenumber
endif
endfunc
nnoremap <C-t> :call NumberToggle()<cr>
function! SpxFormat()
python << endpython
import vim
import sys
spx_linecount = 40
newlines = [ ]
b = vim.current.buffer
for line in b :
sline = line.decode("utf8")
llen = len(sline)
times = llen / spx_linecount
if 0 != (llen % spx_linecount) :
times = times + 1
for i in range(times) :
begin = i * spx_linecount
end = (i + 1) * spx_linecount
if end > llen :
end = llen
newline = sline[begin : end]
newlines.append(newline.encode("utf8"))
del b[ : ]
b.append(newlines)
endpython
endfunction
let g:rnd = localtime() % 0x10000
function! Random(n) abort
"let i = 0
"let al = []
"while i < 100
let g:rnd = (g:rnd * 31421 + 6927) % 0x10000
let r = g:rnd * a:n/0x10000
"call add(al,r)
"let i = i + 1
"endwhile
"echo al
return r
endfunction
function! RandomHex() abort
return Random(0x7FFFFFFF)
endfunction
function! GenFileRandom()
let currLine = line('.')
let sourcefilename=expand("%:t")
let definename=substitute(sourcefilename,' ','','g')
let definename=substitute(definename,'\.','_','g')
let definename = toupper(definename)
exe 'normal '.currLine.'GO'
let randFF = RandomHex()
call setline('.', '/* random integer for file generate by automatic ')
normal o
call setline('.', '* it use for memory allocator and debug ')
normal o
call setline('.', '* so do not delete and keep name start with current filename */')
normal o
call setline('.', 'static int '.definename.'_RANDOMS = '.randFF.';')
normal o
endfunction
nmap la :call GenFileRandom()<CR>
"替换命令
fun! SetupCommandAlias(from, to)
exec 'cnoreabbrev <expr> '.a:from
\ .' ((getcmdtype() is# ":" && getcmdline() is# "'.a:from.'")'
\ .'? ("'.a:to.'") : ("'.a:from.'"))'
endfun
function! IndentIgnoringComments()
let in_comment = 0
for i in range(1, line('$'))
if !in_comment
" Check if this line starts a comment
if getline(i) =~# '^\s*/\*'
"if getline(i) =~# '^\s*/\*\*'
let in_comment = 1
else
" Indent line 'i'
execute i . "normal =="
endif
else
" Check if this line ends the comment
if getline(i) =~# '\*\/\s*$'
let in_comment = 0
endif
endif
endfor
endfunction
nnoremap <leader>= :call IndentIgnoringComments()<CR>
" -- New file .h .C .cpp, add file header --
autocmd BufNeWFile *.[ch] exec ":call CFileHeader( )"
autocmd BufNeWFile *.hpp,*.cc exec ":call CPPFileHeader( )"
func CFileHeader()
call setline(1,"/*************************************************************")
normal o
call setline(("."),"*")
normal o
call setline(("."),"* You can copy the software or lib under the terms of the gnu")
normal o
call setline(("."),"* general public license v3,which may be found in the source")
normal o
call setline(("."),"* kit.")
normal o
call setline(("."),"*")
normal o
call setline(("."),"* Warning:")
normal o
call setline(("."),"* If use the code for bussiness or any act of gain, you must")
normal o
call setline(("."),"* get my green light with mail or any documentary evidence.")
normal o
call setline(("."),"*")
normal o
call setline(("."),"*")
normal o
call setline((".") ,"* Author: Seapeak.Xu (www.94geek.com)")
normal o
call setline((".") ,"* Mail: xvhfeng@gmail.com")
normal o
call setline((".") , "* Date: " .strftime ("%Y/%m/%d %H:%M:%S"))
normal o
call setline((".") ,"*")
normal o
call setline((".") ,"*")
normal o
call setline((".") , "* File: ".strftime( expand( '%d')))
normal o
call setline((".") ,"* -- ")
normal o
call setline(("."),"***************************************************************/")
normal o
call setline((".") , "")
normal o
exec "$"
endfunc
func CPPFileHeader()
call setline(1,"/*************************************************************")
normal o
call setline(("."),"*")
normal o
call setline(("."),"* You can copy the software or lib under the terms of the gnu")
normal o
call setline(("."),"* general public license v3,which may be found in the source")
normal o
call setline(("."),"* kit.")
normal o
call setline(("."),"*")
normal o
call setline(("."),"* Warning:")
normal o
call setline(("."),"* If use the code for bussiness or any act of gain, you must")
normal o
call setline(("."),"* get my green light with mail or any documentary evidence.")
normal o
call setline(("."),"*")
normal o
call setline(("."),"*")
normal o
call setline((".") ,"* Author: Seapeak.Xu (www.94geek.com)")
normal o
call setline((".") ,"* Mail: xvhfeng@gmail.com")
normal o
call setline((".") , "* Date: " .strftime ("%Y/%m/%d %H:%M:%S"))
normal o
call setline((".") ,"*")
normal o
call setline((".") ,"*")
normal o
call setline((".") , "* File: ".strftime( expand( '%d')))
normal o
call setline((".") ,"* -- ")
normal o
call setline(("."),"***************************************************************/")
normal o
call setline((".") , "")
normal o
exec "$"
endfunc
function! SpxInsertHeadDef(firstLine, lastLine)
if a:firstLine <1 || a:lastLine> line('$')
echoerr 'InsertHeadDef : Range overflow !(FirstLine:'.a:firstLine.';LastLine:'.a:lastLine.';ValidRange:1~'.line('$').')'
return ''
endif
let sourcefilename=expand("%:t")
let definename=substitute(sourcefilename,' ','','g')
let definename=substitute(definename,'\.','_','g')
let definename = toupper(definename)
exe 'normal '.a:firstLine.'GO'
call setline('.', '#ifndef _'.definename."_")
normal o
call setline('.', '#define _'.definename."_")
normal o
call setline('.', '#ifdef __cplusplus')
normal o
call setline('.', 'extern "C" {')
normal o
call setline('.', '#endif')
normal o
exe 'normal =='.(a:lastLine-a:firstLine+1).'jo'
call setline('.', '#ifdef __cplusplus')
normal o
call setline('.', '}')
normal o
call setline('.', '#endif')
normal o
call setline('.', '#endif')
let goLn = a:firstLine+2
exe 'normal =='.goLn.'G'
endfunction
function! SpxInsertHeadDefN()
let firstLine = 21
let lastLine = line('$')
let n=21
"50 is the magic number
"if you file init context size is more than 50,
"plesae set larger again.
while n < 80
let line = getline(n)
if n==21
if line =~ '^\/\*.*$'
let n = n + 1
continue
else
break
endif
endif
if line =~ '^.*\*\/$'
let firstLine = n+1
break
endif
let n = n + 1
endwhile
call SpxInsertHeadDef(firstLine, lastLine)
endfunction
nmap ha :call SpxInsertHeadDefN()<CR>
autocmd BufNewFile *.h,*.hpp :call SpxInsertHeadDefN()
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

Releases

No release

Contributors

All

Language(Optional)

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
VimL
1
https://gitee.com/spkx/myvim.git
git@gitee.com:spkx/myvim.git
spkx
myvim
myvim
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /