Eric Leenman wrote:
> entity HALFADDER is
> port(
> A, B : in bit;
> SUM, CARRY: out bit);
> end entity HALFADDER;
>
> component HALFADDER
> port(
> A, B : in bit;
> SUM, CARRY: out bit);
> end component;
>
> Is it then easy to replace the first and last line of these 5 lines of
> entity code to 5 lines of component code by pressing i.e. F5?
Sure!
Here it is, based on your examples:
:map <F5> j{/^entity<CR>cecomponent<ESC>/ is<CR>D/^end
entity<CR>wCcomponent;<ESC>0
It works when invoked inside the entity block or just before it.
Explanation (spaces added for clarity, literal spaces marked with ␣):
j { go down one line and up a paragraph (so that it
works inside the block or one line before it)
/^entity <CR> go to the next 'entity' at the start of a line
ce component <ESC> change that word to 'component'
/␣is <CR> go to the ' is'
D delete it (delete to the end of line)
/^end␣entity <CR> go to the next 'end entity'
w skip a word ('end')
C component; <ESC> change the rest of the line to 'component;'
0 go back to the start of the line
Tune it as needed :-)
Tobia