shortcut keys and application

vim fugitive installation

vim surround

blog

Delete surroundings

To delete we use ds, the next character determines the target to delete. Some examples:

Objective Original text Command Edited text
Delete quotes surrounding a sentence “Hello world!”    
[] <— cursor ds” Hello world!  
[] <— cursor now      
Delete surrounding tags <p>Start here</p>    
[] <— cursor dst Start here  
[] <— cursor now      
Delete surrounding parentheses in some code (var1, var2) ds( var1, var2
ObjectiveOriginal textCommandEdited text
Delete quotes surrounding a sentence
"Hello world!"
  [] <--- cursor
ds"
Hello world!
[] <--- cursor now
Delete surrounding tags
<p>Start here</p>
       [] <--- cursor
dst
Start here
[] <--- cursor now
Delete surrounding parentheses in some code
(var1, var2)
ds(
var1, var2

The cursor can be anywhere within the surrounding text object we’re operating on, when the command is complete the cursor moves to the start of the object we operated on. Also, unlike other text objects there’s no i or a option for changing how it selects the area.

Change surrounding

To change a surrounding we use cs, this deletes the supplied text-object and replaces it with the second argument. When used in this way the cursor does not enter Insert mode at the end of the command. There are two ways to use it:

Change one surround to another: cs Change one surround to another, putting the new ones on separate new lines: cS Examples of how to use it are:

| Objective | Original text | Command | Edited text | | ———————————————————– | —————————————————- | ——- | ————————————————– | | Change surrounding quotes from double to single quote marks | “My kingdom for a horse” [] <— cursor here | cs”’ | ‘My kingdom for a horse’ [] <— cursor here now | | Change to HTML paragraph with tags on separate lines | ‘Look, to the East’ | cS’<p> | <p> Look, to the East </p> |

ObjectiveOriginal textCommandEdited text
Change surrounding quotes from double to single quote marks
"My kingdom for a horse"
      [] <--- cursor here
cs"'
'My kingdom for a horse'
[] <--- cursor here now
Change to HTML paragraph with tags on separate lines
'Look, to the East'
cS'<p>
<p>
Look, to the East
</p>

Add surrounding

Often, rather than altering some existing mark-up or brackets, we want to add some additional surroundings. Add a surrounding uses ys, the following item is the additional mark-up, brackets or text that will placed either side. The ways it can be used are:

Wrap the vim motion or text object in the second argument: ys<motion|text-object> Change the current line and wrap it with the second argument: yss Change the specified motion, putting the new addition on new lines and indenting the text: yS Whole line and do the above: ySS Some examples of using these methods:

| Objective | Original text | Command | Edited text | | ———————————————————————————————————————– | ————————————————- | ——- | —————————————————- | | Put some quotes around some text at the end of a line. | he said, Boo! scary huh [] <— cursor | ys$” | he said, “Boo! scary huh” | | Put some square brackets around some variables. Note use of repetition in the motion. | print var1, var2 [] <— cursor | ys3w) | print (var1, var2) [] <— cursor | | Put some squiggly brackets around some code. This acts on the whole line with the cursor anywhere on the line | 34, 21, 7 [] <– cursor | yssB | { 34, 21, 7 } [] <– cursor moves | | Convert some speech into a HTML blockquote. Uses Vims search motion and surrounds ability to then put tags around that. | Jack said, “Done it!” [] <— cursor | ySf”t | Jack said, <blockquote> “Done it!” </blockquote> | | Put some brackets around a procedure and indent the text | defn -proc1 [] <— cursor | ySSb | ( defn -proc1 ) |

ObjectiveOriginal textCommandEdited text
Put some quotes around some text at the end of a line.
he said, Boo! scary huh
         [] <--- cursor
ys$"
he said, "Boo! scary huh"
Put some square brackets around some variables. Note use of repetition in the motion.
print var1, var2
      [] <--- cursor
ys3w)
print (var1, var2)
      [] <--- cursor
Put some squiggly brackets around some code. This acts on the whole line with the cursor anywhere on the line
34, 21, 7
  [] <-- cursor
yssB
{ 34, 21, 7 }
[] <-- cursor moves
Convert some speech into a HTML blockquote. Uses Vims search motion and surrounds ability to then put tags around that.
Jack said, "Done it!"
           [] <--- cursor
ySf"t
Jack said, <blockquote>
    "Done it!"
</blockquote>
Put some brackets around a procedure and indent the text
defn -proc1
    [] <--- cursor
ySSb
(
     defn -proc1
)

Visual surround

In visual mode, the surround object is called with S, and then an argument that wraps the visual selection. The keyboard usage is something like this:

v                         # Enter visual mode
<visually select>         # Use the keyboard to select the section of text
S                         # Press upper case S
"                         # Specify what you want to surround the visual selection with

In linewise visual mode the surrounding are placed on separate lines and indented: vS In block wise visual mode (Ctrl-v) each line is surrounded: vS

Objective Original text Command Edited text
Select a word and put rST italic marks around it Add two eggs    
[] <— cursor viwS* Add *two* eggs  
[] <— cursor now      
Put HTML paragraph around some lines.      

Uses linewise visual mode | Consider this, when we create an object we take more memory. | Shift-v,

S

|

Consider this, when we create an object we take more memory.

| | Put HTML list item on each line to create a list. Uses block wise visual mode | 6 eggs 4 apples 2 pints of milk | Ctrl-v S
  • |
  • 6 eggs
  • 4 apples
  • 2 pints of milk
  • |
    ObjectiveOriginal textCommandEdited text
    Select a word and put rST italic marks around it
    Add two eggs
       [] <--- cursor
    
    viwS*
    
    Add *two* eggs
    [] <--- cursor now
    

    Put HTML paragraph around some lines.

    Uses linewise visual mode

    Consider this, when
    we create an object
    we take more memory.
    
    Shift-v,
    <highlight the text>
    S<p>
    
    <p>
    Consider this, when
    we create an object
    we take more memory.
    </p>
    

    Put HTML list item on each line to create a list.

    Uses block wise visual mode

    6 eggs
    4 apples
    2 pints of milk
    
    Ctrl-v
    <highlight the text>
    S<li>
    
    <li>6 eggs</li>
    <li>4 apples</li>
    <li>2 pints of milk</li>
    ## cheatsheet ### reset diagram ![image](https://user-images.githubusercontent.com/42961200/180112510-13c7b9d5-58bc-4436-a9b7-5dad6fcd6d04.png)

    The following wiki, pages and posts are tagged with

    TitleTypeExcerpt
    using git with vim post shortcut keys and application
    2021-10-11-vim-ycm-python3.md post python2 좀 그만 쓰자
    Vim-Category.md post 카테고리 문서 1단계
    Vimrc-Category.md post 카테고리 2단계 (끝)
    Web-Category.md post 카테고리 2단계 (끝)
    Wiki-Setting-Category.md post 카테고리 1단계 (끝)
    Practical Vim post 손이 먼저 반응하는
    vim howtos page vim fugitive emmets shortcut keys and howtos
    template.md post python2 좀 그만 쓰자
    term-string-interpolation.md post 플릿 문자열, 백틱 문자열, f문자열
    test.md post python2 좀 그만 쓰자
    vim-basic.md post keep them by heart, fugitive
    vim-folding.md post vimrc가 점점 커진다면 폴딩을 적용해보자.
    vscode-configurations.md post vscode settings for theme and vim
    wiki-inWindows.md post on using Jekyll on windows, with ruby
    wiki-troubleshooting.md post 위키 운영하면서 생기는 문제 정리
    Vim Ycm Python3 post python2 좀 그만 쓰자
    [news]: news.html [yoga]: yoga.html [drones]: drones [freelancers]: freelancers [p1_landing_page]: p1_landing_page.html [p2_landing_page]: p2_landing_page.html [titlepage]: titlepage.html [tocpage]: tocpage.html [index]: index.html [mydoc_aboutsite]: mydoc_aboutsite.html [mydoc_supported_features]: mydoc_supported_features.html [mydoc_about]: mydoc_about.html [mydoc_support]: mydoc_support.html [mydoc_ansible]: mydoc_ansible.html [mydoc_webhook]: mydoc_webhook.html [mydoc_pipeline]: mydoc_pipeline.html [mydoc_docker]: mydoc_docker.html [mydoc_gitlab]: mydoc_gitlab.html [mydoc_django]: mydoc_django.html [mydoc_rostopic]: mydoc_rostopic.html [mydoc_gcs_web]: mydoc_gcs_web.html [mydoc_rqt]: mydoc_rqt.html [mydoc_webrtc]: mydoc_webrtc.html [mydoc_mqtt]: mydoc_mqtt.html [mydoc_actions]: mydoc_actions.html [mydoc_heroku]: mydoc_heroku.html [mydoc_others]: mydoc_others.html [mydoc_oscar]: mydoc_oscar.html [mydoc_raspi]: mydoc_raspi.html [mydoc_lora]: mydoc_lora.html [mydoc_drone]: mydoc_drone.html [mydoc_content_reuse]: mydoc_content_reuse.html [mydoc_collections]: mydoc_collections.html [mydoc_webstorm_text_editor]: mydoc_webstorm_text_editor.html [mydoc_atom_text_editor]: mydoc_atom_text_editor.html [mydoc_djangovue]: mydoc_djangovue.html [mydoc_weather]: mydoc_weather.html [mydoc_chatapp]: mydoc_chatapp.html [mydoc_bootstrap]: mydoc_bootstrap.html [mydoc_lightup]: mydoc_lightup.html [mydoc_lightupadmin]: mydoc_lightupadmin.html [mydoc_dalrc]: mydoc_dalrc.html [mydoc_skyhero]: mydoc_skyhero.html [mydoc_minicp]: mydoc_minicp.html [mydoc_devnazam]: mydoc_devnazam.html [xugong]: xugong.html [mydoc_labels]: mydoc_labels.html [mydoc_hyperlinks]: mydoc_hyperlinks.html [mydoc_navtabs]: mydoc_navtabs.html [mydoc_tables]: mydoc_tables.html [mydoc_syntax_highlighting]: mydoc_syntax_highlighting.html [mydoc_workflow_maps]: mydoc_workflow_maps.html [mydoc_pixhwak_overview]: mydoc_pixhwak_overview.html [rfly_starthere]: rfly_starthere.html [books_rflyintroduction]: books_rflyintroduction.html [mydoc_rfly_cube]: mydoc_rfly_cube.html [mydoc_apmdr]: mydoc_apmdr.html [mydoc_cube]: mydoc_cube.html [mydoc_quad]: mydoc_quad.html [mydoc_s1000]: mydoc_s1000.html [mydoc_s100a2]: mydoc_s100a2.html [mydoc_s900]: mydoc_s900.html [mydoc_nazam]: mydoc_nazam.html [mydoc_iterm_profiles]: mydoc_iterm_profiles.html [mydoc_push_build_to_server]: mydoc_push_build_to_server.html [mydoc_publishing_github_pages]: mydoc_publishing_github_pages.html [mydoc_yuneec]: mydoc_yuneec.html [mydoc_bebop]: mydoc_bebop.html [mydoc_jetbot]: mydoc_jetbot.html [mydoc_xavier]: mydoc_xavier.html [mydoc_vtol]: mydoc_vtol.html [mydoc_mycourse]: mydoc_mycourse.html [mydoc_deeplearning]: mydoc_deeplearning.html [mydoc_cplus]: mydoc_cplus.html [mydoc_webscraping]: mydoc_webscraping.html [mydoc_challenger-project]: mydoc_challenger-project.html [mydoc_aiotoverview]: mydoc_aiotoverview.html [mydoc_sensor_detection]: mydoc_sensor_detection.html [mydoc_realsense_drone]: mydoc_realsense_drone.html [mydoc_edison_arduino]: mydoc_edison_arduino.html [tag_collaboration]: tag_collaboration.html [tag_troubleshooting]: tag_troubleshooting.html [mydoc_jetson_nano]: mydoc_jetson_nano.html [mydoc_jetson_xavier]: mydoc_jetson_xavier.html [mydoc_raspi]: mydoc_raspi.html [mydoc_serializer]: mydoc_serializer.html [mydoc_lora_monitoring]: mydoc_lora_monitoring.html [mydoc_fiction]: mydoc_fiction.html [book-how-javascript-works]: book-how-javascript-works.html [book-effective-python-2nd]: book-effective-python-2nd.html [cplus]: cplus.html [mydoc_webdev]: mydoc_webdev.html [mydoc_twoscoops]: mydoc_twoscoops.html [books_revealjs]: books_revealjs.html [books_vim]: books_vim.html [books_robotswithros]: books_robotswithros.html [books_matlab_essential]: books_matlab_essential.html [mydoc_contact]: mydoc_contact.html [aigenerative_smartfarm]: aigenerative_smartfarm.html [quasar]: quasar.html [iot-network]: iot-network.html [smartfarm-backend]: smartfarm-backend.html [aigenerative_nodered]: aigenerative_nodered.html [iot-network]: iot-network.html [tag_collaboration]: tag_collaboration.html [tag_troubleshooting]: tag_troubleshooting.html [aigenerative_insights]: aigenerative_insights.html [HF-framework]: HF-framework.html [langchain]: langchain.html [gpt4all]: gpt4all.html [aigenerative_overview]: aigenerative_overview.html [aigenerative_rag]: aigenerative_rag.html [3d-human-pose-estimation]: 3d-human-pose-estimation.html [metafactory]: metafactory.html [digital-twin]: digital-twin.html [edge-ai]: edge-ai.html [vision-ai]: vision-ai.html [vision-ai]: vision-ai.html [titlepage]: titlepage.html [tocpage]: tocpage.html [p1_landing_page]: p1_landing_page.html [p1_sample1]: p1_sample1.html [p1_sample2]: p1_sample2.html [p1_sample3]: p1_sample3.html [p1_sample4]: p1_sample4.html [p1_sample5]: p1_sample5.html [p1_sample6]: p1_sample6.html [p1_sample7]: p1_sample7.html [titlepage]: titlepage.html [tocpage]: tocpage.html [p2_landing_page]: p2_landing_page.html [p2_sample1]: p2_sample1.html [p2_sample2]: p2_sample2.html [p2_sample3]: p2_sample3.html [p2_sample4]: p2_sample4.html [p2_sample5]: p2_sample5.html [p2_sample6]: p2_sample6.html [p2_sample7]: p2_sample7.html [p2_sample8]: p2_sample8.html [p2_sample9]: p2_sample9.html [p2_sample10]: p2_sample10.html [p2_sample11]: p2_sample11.html [p2_sample12]: p2_sample12.html [p2_sample13]: p2_sample13.html [p2_sample14]: p2_sample14.html [category]: category [tag]: tag.html [tags]: tags.html [tocpage]: tocpage.html [drones_overview]: drones_overview.html [freelancers]: freelancers.html [yoga]: yoga.html [bikram]: bikram.html [hatha]: hatha.html [mycourse]: mycourse.html [wiki]: wiki.html [book-how-javascript-works]: book-how-javascript-works.html [book-effective-python-2nd]: book-effective-python-2nd.html [cplus]: cplus.html [rflysim]: rflysim.html [vim-basic]: vim-basic.html [news]: news [2021-10-31-in-making-it]: 2021-10-31-in-making-it.html [mydoc_introduction]: mydoc_introduction.html [p2_mobis]: p2_mobis.html [p2_skydrones]: p2_skydrones.html [drones]: drones.html [freelancers]: freelancers.html [yoga]: yoga.html [mycourse]: mycourse.html [wiki]: wiki.html