robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
98694c3675
master
1" Test shifting lines with :> and :< 2 3source check.vim 4 5func Test_ex_shift_right () 6set shiftwidth = 2 7 8" shift right current line. 9call setline ( 1 , range ( 1 , 5 )) 102 11 > 123 13 >> 14call assert_equal ([ '1' , 15 \' 2' , 16 \' 3' , 17 \'4' , 18 \'5' ], getline ( 1 , '$' )) 19 20" shift right with range. 21call setline ( 1 , range ( 1 , 4 )) 222 , 3 > > 23call assert_equal ([ '1' , 24 \' 2' , 25 \' 3' , 26 \'4' , 27 \'5' ], getline ( 1 , '$' )) 28 29" shift right with range and count. 30call setline ( 1 , range ( 1 , 4 )) 312 > 3 32call assert_equal ([ '1' , 33 \' 2' , 34 \' 3' , 35 \' 4' , 36 \'5' ], getline ( 1 , '$' )) 37 38bw ! 39set shiftwidth & 40endfunc 41 42func Test_ex_shift_left () 43set shiftwidth = 2 44 45call setline ( 1 , range ( 1 , 5 )) 46 %> >> 47 48" left shift current line. 492 < 503 << 514 <<<<< 52call assert_equal ([ ' 1' , 53 \' 2' , 54 \' 3' , 55 \'4' , 56 \' 5' ], getline ( 1 , '$' )) 57 58" shift right with range. 59call setline ( 1 , range ( 1 , 5 )) 60 %> >> 612 , 3 << 62call assert_equal ([ ' 1' , 63 \' 2' , 64 \' 3' , 65 \' 4' , 66 \' 5' ], getline ( 1 , '$' )) 67 68" shift right with range and count. 69call setline ( 1 , range ( 1 , 5 )) 70 %> >> 712 <<3 72call assert_equal ([ ' 1' , 73 \' 2' , 74 \' 3' , 75 \' 4' , 76 \' 5' ], getline ( 1 , '$' )) 77 78bw ! 79set shiftwidth & 80endfunc 81 82func Test_ex_shift_rightleft () 83CheckFeature rightleft 84 85set shiftwidth = 2 rightleft 86 87call setline ( 1 , range ( 1 , 4 )) 882 , 3 << 89call assert_equal ([ '1' , 90 \' 2' , 91 \' 3' , 92 \'4' ], getline ( 1 , '$' )) 93 943 , 4 > 95call assert_equal ([ '1' , 96 \' 2' , 97 \' 3' , 98 \'4' ], getline ( 1 , '$' )) 99 100bw ! 101set rightleft & shiftwidth & 102endfunc 103 104func Test_ex_shift_errors () 105call assert_fails ( '><' , 'E488:' ) 106call assert_fails ( '<>' , 'E488:' ) 107 108call assert_fails ( '>!' , 'E477:' ) 109call assert_fails ( '<!' , 'E477:' ) 110 111call assert_fails ( '2,1>' , 'E493:' ) 112call assert_fails ( '2,1<' , 'E493:' ) 113endfunc 114 115" Test inserting a backspace at the start of a line. 116" 117" This is to verify the proper behavior of tabstop_start() as called from 118" ins_bs(). 119" 120func Test_shift_ins_bs () 121set backspace = indent,start 122set softtabstop = 11 123 124call setline ( 1 , repeat ( " " , 33 ) . "word" ) 125exe "norm! I\<BS>" 126call assert_equal ( repeat ( " " , 22 ) . "word" , getline ( 1 )) 127call setline ( 1 , repeat ( " " , 23 ) . "word" ) 128exe "norm! I\<BS>" 129call assert_equal ( repeat ( " " , 22 ) . "word" , getline ( 1 )) 130exe "norm! I\<BS>" 131call assert_equal ( repeat ( " " , 11 ) . "word" , getline ( 1 )) 132 133set backspace & softtabstop & 134bw ! 135endfunc 136 137" Test inserting a backspace at the start of a line, with 'varsofttabstop'. 138" 139func Test_shift_ins_bs_vartabs () 140CheckFeature vartabs 141set backspace = indent,start 142set varsofttabstop = 13,11,7 143 144call setline ( 1 , repeat ( " " , 44 ) . "word" ) 145exe "norm! I\<BS>" 146call assert_equal ( repeat ( " " , 38 ) . "word" , getline ( 1 )) 147call setline ( 1 , repeat ( " " , 39 ) . "word" ) 148exe "norm! I\<BS>" 149call assert_equal ( repeat ( " " , 38 ) . "word" , getline ( 1 )) 150exe "norm! I\<BS>" 151call assert_equal ( repeat ( " " , 31 ) . "word" , getline ( 1 )) 152exe "norm! I\<BS>" 153call assert_equal ( repeat ( " " , 24 ) . "word" , getline ( 1 )) 154exe "norm! I\<BS>" 155call assert_equal ( repeat ( " " , 13 ) . "word" , getline ( 1 )) 156exe "norm! I\<BS>" 157call assert_equal ( "word" , getline ( 1 )) 158exe "norm! I\<BS>" 159call assert_equal ( "word" , getline ( 1 )) 160 161set backspace & varsofttabstop & 162bw ! 163endfunc 164 165" Test the >> and << normal-mode commands. 166" 167func Test_shift_norm () 168set expandtab " Don't want to worry about tabs vs. spaces in 169" results. 170 171set shiftwidth = 5 172set tabstop = 7 173 174call setline ( 1 , " word" ) 175 176" Shift by 'shiftwidth' right and left. 177 178norm ! >> 179call assert_equal ( repeat ( " " , 7 ) . "word" , getline ( 1 )) 180norm ! >> 181call assert_equal ( repeat ( " " , 12 ) . "word" , getline ( 1 )) 182norm ! >> 183call assert_equal ( repeat ( " " , 17 ) . "word" , getline ( 1 )) 184 185norm ! << 186call assert_equal ( repeat ( " " , 12 ) . "word" , getline ( 1 )) 187norm ! << 188call assert_equal ( repeat ( " " , 7 ) . "word" , getline ( 1 )) 189norm ! << 190call assert_equal ( repeat ( " " , 2 ) . "word" , getline ( 1 )) 191norm ! << 192call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 193 194" Shift by 'tabstop' right and left. 195 196set shiftwidth = 0 197call setline ( 1 , " word" ) 198 199norm ! >> 200call assert_equal ( repeat ( " " , 9 ) . "word" , getline ( 1 )) 201norm ! >> 202call assert_equal ( repeat ( " " , 16 ) . "word" , getline ( 1 )) 203norm ! >> 204call assert_equal ( repeat ( " " , 23 ) . "word" , getline ( 1 )) 205 206norm ! << 207call assert_equal ( repeat ( " " , 16 ) . "word" , getline ( 1 )) 208norm ! << 209call assert_equal ( repeat ( " " , 9 ) . "word" , getline ( 1 )) 210norm ! << 211call assert_equal ( repeat ( " " , 2 ) . "word" , getline ( 1 )) 212norm ! << 213call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 214 215set expandtab & shiftwidth & tabstop & 216bw ! 217endfunc 218 219" Test the >> and << normal-mode commands, with 'vartabstop'. 220" 221func Test_shift_norm_vartabs () 222CheckFeature vartabs 223set expandtab " Don't want to worry about tabs vs. spaces in 224" results. 225 226set shiftwidth = 0 227set vartabstop = 19,17,11 228 229" Shift by 'vartabstop' right and left. 230 231call setline ( 1 , " word" ) 232 233norm ! >> 234call assert_equal ( repeat ( " " , 21 ) . "word" , getline ( 1 )) 235norm ! >> 236call assert_equal ( repeat ( " " , 38 ) . "word" , getline ( 1 )) 237norm ! >> 238call assert_equal ( repeat ( " " , 49 ) . "word" , getline ( 1 )) 239norm ! >> 240call assert_equal ( repeat ( " " , 60 ) . "word" , getline ( 1 )) 241 242norm ! << 243call assert_equal ( repeat ( " " , 49 ) . "word" , getline ( 1 )) 244norm ! << 245call assert_equal ( repeat ( " " , 38 ) . "word" , getline ( 1 )) 246norm ! << 247call assert_equal ( repeat ( " " , 21 ) . "word" , getline ( 1 )) 248norm ! << 249call assert_equal ( repeat ( " " , 2 ) . "word" , getline ( 1 )) 250norm ! << 251call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 252 253set expandtab & shiftwidth & vartabstop & 254bw ! 255endfunc 256 257" Test the >> and << normal-mode commands with 'shiftround'. 258" 259func Test_shift_norm_round () 260set expandtab " Don't want to worry about tabs vs. spaces in 261" results. 262 263set shiftround 264set shiftwidth = 5 265set tabstop = 7 266 267call setline ( 1 , "word" ) 268 269" Shift by 'shiftwidth' right and left. 270 271exe "norm! I " 272norm ! >> 273call assert_equal ( repeat ( " " , 5 ) . "word" , getline ( 1 )) 274exe "norm! I " 275norm ! >> 276call assert_equal ( repeat ( " " , 10 ) . "word" , getline ( 1 )) 277exe "norm! I " 278norm ! >> 279call assert_equal ( repeat ( " " , 15 ) . "word" , getline ( 1 )) 280norm ! >> 281call assert_equal ( repeat ( " " , 20 ) . "word" , getline ( 1 )) 282norm ! >> 283call assert_equal ( repeat ( " " , 25 ) . "word" , getline ( 1 )) 284 285norm ! << 286call assert_equal ( repeat ( " " , 20 ) . "word" , getline ( 1 )) 287norm ! << 288call assert_equal ( repeat ( " " , 15 ) . "word" , getline ( 1 )) 289norm ! << 290call assert_equal ( repeat ( " " , 10 ) . "word" , getline ( 1 )) 291exe "norm! I " 292norm ! << 293call assert_equal ( repeat ( " " , 10 ) . "word" , getline ( 1 )) 294 295call setline ( 1 , repeat ( " " , 7 ) . "word" ) 296norm ! << 297call assert_equal ( repeat ( " " , 5 ) . "word" , getline ( 1 )) 298norm ! << 299call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 300norm ! << 301call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 302call setline ( 1 , repeat ( " " , 2 ) . "word" ) 303norm ! << 304call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 305 306" Shift by 'tabstop' right and left. 307 308set shiftwidth = 0 309call setline ( 1 , "word" ) 310 311exe "norm! I " 312norm ! >> 313call assert_equal ( repeat ( " " , 7 ) . "word" , getline ( 1 )) 314exe "norm! I " 315norm ! >> 316call assert_equal ( repeat ( " " , 14 ) . "word" , getline ( 1 )) 317exe "norm! I " 318norm ! >> 319call assert_equal ( repeat ( " " , 21 ) . "word" , getline ( 1 )) 320norm ! >> 321call assert_equal ( repeat ( " " , 28 ) . "word" , getline ( 1 )) 322norm ! >> 323call assert_equal ( repeat ( " " , 35 ) . "word" , getline ( 1 )) 324 325norm ! << 326call assert_equal ( repeat ( " " , 28 ) . "word" , getline ( 1 )) 327norm ! << 328call assert_equal ( repeat ( " " , 21 ) . "word" , getline ( 1 )) 329norm ! << 330call assert_equal ( repeat ( " " , 14 ) . "word" , getline ( 1 )) 331exe "norm! I " 332norm ! << 333call assert_equal ( repeat ( " " , 14 ) . "word" , getline ( 1 )) 334 335call setline ( 1 , repeat ( " " , 9 ) . "word" ) 336norm ! << 337call assert_equal ( repeat ( " " , 7 ) . "word" , getline ( 1 )) 338norm ! << 339call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 340norm ! << 341call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 342call setline ( 1 , repeat ( " " , 2 ) . "word" ) 343norm ! << 344call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 345 346set expandtab & shiftround & shiftwidth & tabstop & 347bw ! 348endfunc 349 350" Test the >> and << normal-mode commands with 'shiftround' and 'vartabstop'. 351" 352func Test_shift_norm_round_vartabs () 353CheckFeature vartabs 354set expandtab " Don't want to worry about tabs vs. spaces in 355" results. 356 357set shiftround 358set shiftwidth = 0 359set vartabstop = 19,17,11 360 361" Shift by 'vartabstop' right and left. 362 363call setline ( 1 , "word" ) 364 365exe "norm! I " 366norm ! >> 367call assert_equal ( repeat ( " " , 19 ) . "word" , getline ( 1 )) 368exe "norm! I " 369norm ! >> 370call assert_equal ( repeat ( " " , 36 ) . "word" , getline ( 1 )) 371exe "norm! I " 372norm ! >> 373call assert_equal ( repeat ( " " , 47 ) . "word" , getline ( 1 )) 374exe "norm! I " 375norm ! >> 376call assert_equal ( repeat ( " " , 58 ) . "word" , getline ( 1 )) 377 378exe "norm! I " 379norm ! << 380call assert_equal ( repeat ( " " , 58 ) . "word" , getline ( 1 )) 381norm ! << 382call assert_equal ( repeat ( " " , 47 ) . "word" , getline ( 1 )) 383norm ! << 384call assert_equal ( repeat ( " " , 36 ) . "word" , getline ( 1 )) 385norm ! << 386call assert_equal ( repeat ( " " , 19 ) . "word" , getline ( 1 )) 387exe "norm! I " 388norm ! << 389call assert_equal ( repeat ( " " , 19 ) . "word" , getline ( 1 )) 390norm ! << 391call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 392exe "norm! I " 393call assert_equal ( repeat ( " " , 2 ) . "word" , getline ( 1 )) 394norm ! << 395call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 396norm ! << 397call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 398 399set expandtab & shiftround & shiftwidth & vartabstop & 400bw ! 401endfunc 402 403" Test the V> and V< visual-mode commands. 404" 405" See ":help v_<" and ":help v_>". See also the last paragraph of "3. Simple 406" changes", ":help simple-change", immediately above "4. Complex changes", 407" ":help complex-change". 408" 409func Test_shift_vis () 410set expandtab " Don't want to worry about tabs vs. spaces in 411" results. 412 413set shiftwidth = 5 414set tabstop = 7 415 416call setline ( 1 , " word" ) 417 418" Shift by 'shiftwidth' right and left. 419 420norm ! V> 421call assert_equal ( repeat ( " " , 7 ) . "word" , getline ( 1 )) 422norm ! V2> 423call assert_equal ( repeat ( " " , 17 ) . "word" , getline ( 1 )) 424norm ! V3> 425call assert_equal ( repeat ( " " , 32 ) . "word" , getline ( 1 )) 426 427norm ! V< 428call assert_equal ( repeat ( " " , 27 ) . "word" , getline ( 1 )) 429norm ! V2< 430call assert_equal ( repeat ( " " , 17 ) . "word" , getline ( 1 )) 431norm ! V3< 432call assert_equal ( repeat ( " " , 2 ) . "word" , getline ( 1 )) 433norm ! V< 434call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 435norm ! V3< 436call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 437 438" Shift by 'tabstop' right and left. 439 440set shiftwidth = 0 441call setline ( 1 , " word" ) 442 443norm ! V> 444call assert_equal ( repeat ( " " , 9 ) . "word" , getline ( 1 )) 445norm ! V2> 446call assert_equal ( repeat ( " " , 23 ) . "word" , getline ( 1 )) 447norm ! V3> 448call assert_equal ( repeat ( " " , 44 ) . "word" , getline ( 1 )) 449 450norm ! V< 451call assert_equal ( repeat ( " " , 37 ) . "word" , getline ( 1 )) 452norm ! V2< 453call assert_equal ( repeat ( " " , 23 ) . "word" , getline ( 1 )) 454norm ! V3< 455call assert_equal ( repeat ( " " , 2 ) . "word" , getline ( 1 )) 456norm ! V< 457call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 458norm ! V3< 459call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 460 461set expandtab & shiftwidth & tabstop & 462bw ! 463endfunc 464 465" Test the V> and V< visual-mode commands, with 'vartabstop'. 466" 467" See ":help v_<" and ":help v_>". See also the last paragraph of "3. Simple 468" changes", ":help simple-change", immediately above "4. Complex changes", 469" ":help complex-change". 470" 471func Test_shift_vis_vartabs () 472CheckFeature vartabs 473set expandtab " Don't want to worry about tabs vs. spaces in 474" results. 475 476set shiftwidth = 0 477set vartabstop = 19,17,11 478 479" Shift by 'vartabstop' right and left. 480 481call setline ( 1 , " word" ) 482 483norm ! V> 484call assert_equal ( repeat ( " " , 21 ) . "word" , getline ( 1 )) 485norm ! V2> 486call assert_equal ( repeat ( " " , 49 ) . "word" , getline ( 1 )) 487norm ! V3> 488call assert_equal ( repeat ( " " , 82 ) . "word" , getline ( 1 )) 489 490norm ! V< 491call assert_equal ( repeat ( " " , 71 ) . "word" , getline ( 1 )) 492norm ! V2< 493call assert_equal ( repeat ( " " , 49 ) . "word" , getline ( 1 )) 494norm ! V3< 495call assert_equal ( repeat ( " " , 2 ) . "word" , getline ( 1 )) 496norm ! V< 497call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 498norm ! V3< 499call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 500 501set expandtab & shiftwidth & vartabstop & 502bw ! 503endfunc 504 505" Test the V> and V< visual-mode commands with 'shiftround'. 506" 507func Test_shift_vis_round () 508set expandtab " Don't want to worry about tabs vs. spaces in 509" results. 510 511set shiftround 512set shiftwidth = 5 513set tabstop = 7 514 515call setline ( 1 , "word" ) 516 517" Shift by 'shiftwidth' right and left. 518 519exe "norm! I " 520norm ! V> 521call assert_equal ( repeat ( " " , 5 ) . "word" , getline ( 1 )) 522exe "norm! I " 523norm ! V2> 524call assert_equal ( repeat ( " " , 15 ) . "word" , getline ( 1 )) 525exe "norm! I " 526norm ! V3> 527call assert_equal ( repeat ( " " , 30 ) . "word" , getline ( 1 )) 528 529exe "norm! I " 530norm ! V2< 531call assert_equal ( repeat ( " " , 25 ) . "word" , getline ( 1 )) 532norm ! V3< 533call assert_equal ( repeat ( " " , 10 ) . "word" , getline ( 1 )) 534norm ! V< 535call assert_equal ( repeat ( " " , 5 ) . "word" , getline ( 1 )) 536norm ! V< 537call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 538norm ! V3< 539call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 540 541" Shift by 'tabstop' right and left. 542 543set shiftwidth = 0 544call setline ( 1 , "word" ) 545 546exe "norm! I " 547norm ! V> 548call assert_equal ( repeat ( " " , 7 ) . "word" , getline ( 1 )) 549exe "norm! I " 550norm ! V2> 551call assert_equal ( repeat ( " " , 21 ) . "word" , getline ( 1 )) 552exe "norm! I " 553norm ! V3> 554call assert_equal ( repeat ( " " , 42 ) . "word" , getline ( 1 )) 555 556exe "norm! I " 557norm ! V< 558call assert_equal ( repeat ( " " , 42 ) . "word" , getline ( 1 )) 559norm ! V< 560call assert_equal ( repeat ( " " , 35 ) . "word" , getline ( 1 )) 561norm ! V2< 562call assert_equal ( repeat ( " " , 21 ) . "word" , getline ( 1 )) 563norm ! V3< 564call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 565norm ! V< 566call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 567norm ! V3< 568call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 569 570call setline ( 1 , " word" ) 571norm ! V< 572call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 573 574 575set expandtab & shiftround & shiftwidth & tabstop & 576bw ! 577endfunc 578 579" Test the V> and V< visual-mode commands with 'shiftround' and 'vartabstop'. 580" 581func Test_shift_vis_round_vartabs () 582CheckFeature vartabs 583set expandtab " Don't want to worry about tabs vs. spaces in 584" results. 585 586set shiftround 587set shiftwidth = 0 588set vartabstop = 19,17,11 589 590" Shift by 'vartabstop' right and left. 591 592call setline ( 1 , "word" ) 593 594exe "norm! I " 595norm ! V> 596call assert_equal ( repeat ( " " , 19 ) . "word" , getline ( 1 )) 597exe "norm! I " 598norm ! V3> 599call assert_equal ( repeat ( " " , 58 ) . "word" , getline ( 1 )) 600 601exe "norm! I " 602norm ! V2< 603call assert_equal ( repeat ( " " , 47 ) . "word" , getline ( 1 )) 604exe "norm! I " 605norm ! V3< 606call assert_equal ( repeat ( " " , 19 ) . "word" , getline ( 1 )) 607exe "norm! I " 608norm ! V3< 609call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 610exe "norm! I " 611norm ! V< 612call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 613 614set expandtab & shiftround & shiftwidth & vartabstop & 615bw ! 616endfunc 617 618" Test the :> and :< ex-mode commands. 619" 620func Test_shift_ex () 621set expandtab " Don't want to worry about tabs vs. spaces in 622" results. 623 624set shiftwidth = 5 625set tabstop = 7 626 627call setline ( 1 , " word" ) 628 629" Shift by 'shiftwidth' right and left. 630 631 > 632call assert_equal ( repeat ( " " , 7 ) . "word" , getline ( 1 )) 633 >> 634call assert_equal ( repeat ( " " , 17 ) . "word" , getline ( 1 )) 635 >>> 636call assert_equal ( repeat ( " " , 32 ) . "word" , getline ( 1 )) 637 638 <<<< 639call assert_equal ( repeat ( " " , 12 ) . "word" , getline ( 1 )) 640 < 641call assert_equal ( repeat ( " " , 7 ) . "word" , getline ( 1 )) 642 < 643call assert_equal ( repeat ( " " , 2 ) . "word" , getline ( 1 )) 644 < 645call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 646 647" Shift by 'tabstop' right and left. 648 649set shiftwidth = 0 650call setline ( 1 , " word" ) 651 652 > 653call assert_equal ( repeat ( " " , 9 ) . "word" , getline ( 1 )) 654 >> 655call assert_equal ( repeat ( " " , 23 ) . "word" , getline ( 1 )) 656 >>> 657call assert_equal ( repeat ( " " , 44 ) . "word" , getline ( 1 )) 658 659 <<<< 660call assert_equal ( repeat ( " " , 16 ) . "word" , getline ( 1 )) 661 << 662call assert_equal ( repeat ( " " , 2 ) . "word" , getline ( 1 )) 663 < 664call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 665 666set expandtab & shiftwidth & tabstop & 667bw ! 668endfunc 669 670" Test the :> and :< ex-mode commands, with vartabstop. 671" 672func Test_shift_ex_vartabs () 673CheckFeature vartabs 674set expandtab " Don't want to worry about tabs vs. spaces in 675" results. 676 677set shiftwidth = 0 678set vartabstop = 19,17,11 679 680" Shift by 'vartabstop' right and left. 681 682call setline ( 1 , " word" ) 683 684 > 685call assert_equal ( repeat ( " " , 21 ) . "word" , getline ( 1 )) 686 >> 687call assert_equal ( repeat ( " " , 49 ) . "word" , getline ( 1 )) 688 >>> 689call assert_equal ( repeat ( " " , 82 ) . "word" , getline ( 1 )) 690 691 <<<< 692call assert_equal ( repeat ( " " , 38 ) . "word" , getline ( 1 )) 693 << 694call assert_equal ( repeat ( " " , 2 ) . "word" , getline ( 1 )) 695 < 696call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 697 698set expandtab & shiftwidth & vartabstop & 699bw ! 700endfunc 701 702" Test the :> and :< ex-mode commands with 'shiftround'. 703" 704func Test_shift_ex_round () 705set expandtab " Don't want to worry about tabs vs. spaces in 706" results. 707 708set shiftround 709set shiftwidth = 5 710set tabstop = 7 711 712call setline ( 1 , "word" ) 713 714" Shift by 'shiftwidth' right and left. 715 716exe "norm! I " 717 > 718call assert_equal ( repeat ( " " , 5 ) . "word" , getline ( 1 )) 719exe "norm! I " 720 >> 721call assert_equal ( repeat ( " " , 15 ) . "word" , getline ( 1 )) 722exe "norm! I " 723 >>> 724call assert_equal ( repeat ( " " , 30 ) . "word" , getline ( 1 )) 725 726exe "norm! I " 727 <<<< 728call assert_equal ( repeat ( " " , 15 ) . "word" , getline ( 1 )) 729exe "norm! I " 730 << 731call assert_equal ( repeat ( " " , 10 ) . "word" , getline ( 1 )) 732 << 733call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 734 >> 735 <<< 736call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 737 738" Shift by 'tabstop' right and left. 739 740set shiftwidth = 0 741call setline ( 1 , "word" ) 742 743exe "norm! I " 744 > 745call assert_equal ( repeat ( " " , 7 ) . "word" , getline ( 1 )) 746exe "norm! I " 747 >> 748call assert_equal ( repeat ( " " , 21 ) . "word" , getline ( 1 )) 749exe "norm! I " 750 >>> 751call assert_equal ( repeat ( " " , 42 ) . "word" , getline ( 1 )) 752 753exe "norm! I " 754 <<<< 755call assert_equal ( repeat ( " " , 21 ) . "word" , getline ( 1 )) 756exe "norm! I " 757 << 758call assert_equal ( repeat ( " " , 14 ) . "word" , getline ( 1 )) 759exe "norm! I " 760 <<< 761call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 762 >> 763 <<< 764call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 765 766set expandtab & shiftround & shiftwidth & tabstop & 767bw ! 768endfunc 769 770" Test the :> and :< ex-mode commands with 'shiftround' and 'vartabstop'. 771" 772func Test_shift_ex_round_vartabs () 773CheckFeature vartabs 774set expandtab " Don't want to worry about tabs vs. spaces in 775" results. 776 777set shiftround 778set shiftwidth = 0 779set vartabstop = 19,17,11 780 781" Shift by 'vartabstop' right and left. 782 783call setline ( 1 , "word" ) 784 785exe "norm! I " 786 > 787call assert_equal ( repeat ( " " , 19 ) . "word" , getline ( 1 )) 788exe "norm! I " 789 >> 790call assert_equal ( repeat ( " " , 47 ) . "word" , getline ( 1 )) 791 >>> 792call assert_equal ( repeat ( " " , 80 ) . "word" , getline ( 1 )) 793 794 <<<< 795call assert_equal ( repeat ( " " , 36 ) . "word" , getline ( 1 )) 796exe "norm! I " 797 << 798call assert_equal ( repeat ( " " , 19 ) . "word" , getline ( 1 )) 799exe "norm! I " 800 << 801call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 802 < 803call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 804 805set expandtab & shiftround & shiftwidth & vartabstop & 806bw ! 807endfunc 808 809" Test shifting lines with <C-T> and <C-D>. 810" 811func Test_shift_ins () 812set expandtab " Don't want to worry about tabs vs. spaces in 813" results. 814 815set shiftwidth = 5 816set tabstop = 7 817 818" Shift by 'shiftwidth' right and left. 819 820call setline ( 1 , repeat ( " " , 7 ) . "word" ) 821exe "norm! 9|i\<C-T>" 822call assert_equal ( repeat ( " " , 10 ) . "word" , getline ( 1 )) 823exe "norm! A\<C-T>" 824call assert_equal ( repeat ( " " , 15 ) . "word" , getline ( 1 )) 825exe "norm! I \<C-T>" 826call assert_equal ( repeat ( " " , 20 ) . "word" , getline ( 1 )) 827 828exe "norm! I \<C-D>" 829call assert_equal ( repeat ( " " , 20 ) . "word" , getline ( 1 )) 830exe "norm! I " 831exe "norm! 24|i\<C-D>" 832call assert_equal ( repeat ( " " , 20 ) . "word" , getline ( 1 )) 833exe "norm! A\<C-D>" 834call assert_equal ( repeat ( " " , 15 ) . "word" , getline ( 1 )) 835exe "norm! I " 836exe "norm! A\<C-D>\<C-D>" 837call assert_equal ( repeat ( " " , 10 ) . "word" , getline ( 1 )) 838exe "norm! I\<C-D>\<C-D>\<C-D>" 839call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 840exe "norm! I\<C-D>" 841call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 842 843" Shift by 'tabstop' right and left. 844 845set shiftwidth = 0 846call setline ( 1 , "word" ) 847 848call setline ( 1 , repeat ( " " , 9 ) . "word" ) 849exe "norm! 11|i\<C-T>" 850call assert_equal ( repeat ( " " , 14 ) . "word" , getline ( 1 )) 851exe "norm! A\<C-T>" 852call assert_equal ( repeat ( " " , 21 ) . "word" , getline ( 1 )) 853exe "norm! I \<C-T>" 854call assert_equal ( repeat ( " " , 28 ) . "word" , getline ( 1 )) 855 856exe "norm! I \<C-D>" 857call assert_equal ( repeat ( " " , 28 ) . "word" , getline ( 1 )) 858exe "norm! I " 859exe "norm! 32|i\<C-D>" 860call assert_equal ( repeat ( " " , 28 ) . "word" , getline ( 1 )) 861exe "norm! A\<C-D>" 862call assert_equal ( repeat ( " " , 21 ) . "word" , getline ( 1 )) 863exe "norm! I " 864exe "norm! A\<C-D>\<C-D>" 865call assert_equal ( repeat ( " " , 14 ) . "word" , getline ( 1 )) 866exe "norm! I\<C-D>\<C-D>\<C-D>" 867call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 868exe "norm! I\<C-D>" 869call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 870 871set expandtab & shiftwidth & tabstop & 872bw ! 873endfunc 874 875" Test shifting lines with <C-T> and <C-D>, with 'vartabstop'. 876" 877func Test_shift_ins_vartabs () 878CheckFeature vartabs 879set expandtab " Don't want to worry about tabs vs. spaces in 880" results. 881 882set shiftwidth = 0 883set vartabstop = 19,17,11 884 885" Shift by 'vartabstop' right and left. 886 887call setline ( 1 , "word" ) 888 889call setline ( 1 , repeat ( " " , 9 ) . "word" ) 890exe "norm! 11|i\<C-T>" 891call assert_equal ( repeat ( " " , 19 ) . "word" , getline ( 1 )) 892exe "norm! A\<C-T>" 893call assert_equal ( repeat ( " " , 36 ) . "word" , getline ( 1 )) 894exe "norm! I \<C-T>" 895call assert_equal ( repeat ( " " , 47 ) . "word" , getline ( 1 )) 896 897exe "norm! I \<C-D>" 898call assert_equal ( repeat ( " " , 47 ) . "word" , getline ( 1 )) 899exe "norm! I " 900exe "norm! 51|i\<C-D>" 901call assert_equal ( repeat ( " " , 47 ) . "word" , getline ( 1 )) 902exe "norm! A\<C-D>" 903call assert_equal ( repeat ( " " , 36 ) . "word" , getline ( 1 )) 904exe "norm! I " 905exe "norm! A\<C-D>\<C-D>" 906call assert_equal ( repeat ( " " , 19 ) . "word" , getline ( 1 )) 907exe "norm! I\<C-D>\<C-D>\<C-D>" 908call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 909exe "norm! I\<C-D>" 910call assert_equal ( repeat ( " " , 0 ) . "word" , getline ( 1 )) 911 912set expandtab & shiftwidth & vartabstop & 913bw ! 914endfunc 915 916" vim: shiftwidth=2 sts=2 expandtab