ad1

Showing posts with label Vim. Show all posts
Showing posts with label Vim. Show all posts

Sunday, January 10, 2016

Make spectre netlist file (*.scs) syntaxed in Vim


  • Put spectre.vim into  ~/.vim/syntax directory
  • Add lines in  ~/.vim/filetype.vim

augroup filetypedetect
    au! BufRead,BufNewFile *.scs,*.SCS  setfiletype  spectre
augroup END

Friday, December 25, 2015

Friday, December 18, 2015

Convert ^M Linebreak to Linux Linebreak Using Vim

%s/<C-v><C-m>//

Recording In Vim

To record typed characters into register:
        q{0-9a-zA-Z"}
(uppercase to append).

To stop recording:
        q

To execute register content:
        @{0-9a-z".=*}
Note that register '%' (name of the current file) and '#' (name of the alternate file) cannot be used.

For "@=" you are prompted to enter an expression.  The result of the expression is then executed.



Saturday, December 12, 2015

Use Register in VI ex mode

:%y *  yank all and put it to * register
:4d x   delete line 4 and put to x register


"X Selection" and VI Register

There are three documented X selections:
  • PRIMARY (which is expected to represent the current visual selection); 
  • SECONDARY (which is ill-defined);
  • CLIPBOARD (which is expected to be used for cut, copy and paste operations).
Of these three, Vim uses
  • PRIMARY when reading and writing the "* register
  • CLIPBOARD when reading and writing the "+ register.  
  • Vim does not access the SECONDARY selection.

Friday, December 11, 2015

Register in Vim

Numbered Register 0 - 9
Vim fills numbered registers with text from yank and delete commands.

  • reg 0 contains the text from the most recent yank command;
  • reg 1 contains the text deleted by the most recent delete or change command;
  • With each successive deletion or change, Vim shifts the previous contents of reg 1 into reg 2, 2 into 3, and so forth, losing the previous contents of reg 9.


Named registers "a to "z or "A to "Z
Vim fills named registers only when you say so.

  • lowercase: replace their previous contents;
  • uppercase:  append to their previous contents.


Access Registers in Vim -- use "

Use quote (") before the registers name to access them, e.g.

  • "ay
  • "zP







Modus Operandi of Vim


  • command mode (normal mode);
  • insert mode;
  • ex mode (vi is actually the visual mode of a more general, underlying line editor, called ex);
  • ex commands are proceed by ":"




Text Object Motions in Vim (object-motions)

(   move to beginning of sentence;
)   move to end of sentence;

{   move to beginning of paragraph;
}   move to end of paragraph;

d)  delete up to end of sentence;
d}  delete up to end of paragraph;

A sentence is defined as ending at a '.', '!' or '?' followed by either the end of a line, or by a space or tab.  Any number of closing ')', ']', '"' and ''' characters may appear after the '.', '!' or '?' before the spaces, tabs or end of line.

Delete to the next occurrence of a string in VIM

d/Xyz<CR>: delete to the next occurrence of "Xyz"

Thursday, December 10, 2015

d{motion}c command -- VIM

dfc: delete up to c (including c)
dtc: delete up to c (not including c)
where c is any character

You can also delete backward:
dFc:
dTc:

f,t,F,T are called motions

Sunday, November 8, 2015

ct and c

["x]c{motion}
Delete {motion} text [into register x] and start insert.  When  'cpoptions' includes the 'E' flag and there is no text to delete (e.g., with "cTx" when the cursor is just after an 'x'), an error occurs and insert mode does not start (this is Vi compatible). When  'cpoptions' does not include the 'E' flag, the "c" command always starts insert mode, even if there is no text to delete.


Add "underscore _" in Word Operation in VIM

use iskeyword to include a character as part of a word
        :set iskeyword+=_
use iskeyword to include a character as part of a word
        :set iskeyword-=_